mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Split refresh list method and create box method
This commit is contained in:
parent
ec13b6902b
commit
b9cc47f05d
@ -43,15 +43,33 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
class: "box-body no-padding"
|
class: "box-body no-padding"
|
||||||
});
|
});
|
||||||
|
|
||||||
//Loading message
|
//Load the list of conversations
|
||||||
|
this.refresh_list(boxBody, args);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh the list of conversations
|
||||||
|
*
|
||||||
|
* @param {HTMLElement} target The target for the list
|
||||||
|
* @param {Object} args Additionnal arguments
|
||||||
|
*/
|
||||||
|
refresh_list: function(target, args){
|
||||||
|
|
||||||
|
//Loading message, if required
|
||||||
|
if(target.childElementCount == 0){
|
||||||
var loadingMsg = createElem2({
|
var loadingMsg = createElem2({
|
||||||
appendTo: boxBody,
|
appendTo: target,
|
||||||
type: "div",
|
type: "div",
|
||||||
class: "conv-list-loading-msg",
|
class: "conv-list-loading-msg",
|
||||||
innerHTML: "Loading, please wait..."
|
innerHTML: "Loading, please wait..."
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
//Create empty division
|
||||||
|
var loadingMsg = document.createElement("div");
|
||||||
|
|
||||||
//Load the list of conversations
|
|
||||||
|
//Perform a request over the interface
|
||||||
ComunicWeb.components.conversations.interface.getList(function(result){
|
ComunicWeb.components.conversations.interface.getList(function(result){
|
||||||
|
|
||||||
//Check for errors
|
//Check for errors
|
||||||
@ -62,11 +80,12 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
|
|
||||||
//Remove loading message
|
//Remove loading message
|
||||||
loadingMsg.remove();
|
loadingMsg.remove();
|
||||||
emptyElem(boxBody); //Remove any previously shown list
|
emptyElem(target); //Remove any previously shown list
|
||||||
|
|
||||||
//Display the list of conversations
|
//Display the list of conversations
|
||||||
ComunicWeb.pages.conversations.listPane._display_list(boxBody, result, args);
|
ComunicWeb.pages.conversations.listPane._display_list(target, result, args);
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -128,7 +147,7 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Check if it is the current conversation
|
//Check if it is the current conversation
|
||||||
if(args.currConvID == info.ID)
|
if(args.getCurrentID() == info.ID)
|
||||||
convLink.className = " selected";
|
convLink.className = " selected";
|
||||||
|
|
||||||
//Add conversation last activity on the rigth
|
//Add conversation last activity on the rigth
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ComunicWeb.pages.conversations.main = {
|
ComunicWeb.pages.conversations.main = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open settings page
|
* Open settings page
|
||||||
*
|
*
|
||||||
@ -56,22 +57,34 @@ ComunicWeb.pages.conversations.main = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Check if a conversation has to be opened
|
//Check if a conversation has to be opened
|
||||||
var currConvID = 0;
|
|
||||||
if(args.subfolder){
|
if(args.subfolder){
|
||||||
|
|
||||||
//Determine conversation ID
|
|
||||||
var convID = args.subfolder;
|
|
||||||
if(convID.includes("/"))
|
|
||||||
convID = convID.split("/")[0];
|
|
||||||
currConvID = Number(convID);
|
|
||||||
//Open the conversation
|
//Open the conversation
|
||||||
conversationOpener(currConvID);
|
conversationOpener(ComunicWeb.pages.conversations.main.getCurrentConversationID());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Display the list of conversation
|
//Display the list of conversation
|
||||||
ComunicWeb.pages.conversations.listPane.display(leftArea, {
|
ComunicWeb.pages.conversations.listPane.display(leftArea, {
|
||||||
opener: conversationOpener,
|
opener: conversationOpener,
|
||||||
currConvID: currConvID
|
getCurrentID: this.getCurrentConversationID
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the current conversation ID
|
||||||
|
*
|
||||||
|
* @return {Number} The ID of the current conversation (0 if none found)
|
||||||
|
*/
|
||||||
|
getCurrentConversationID: function(){
|
||||||
|
|
||||||
|
var id = location.toString().split("/conversations/");
|
||||||
|
id = id[id.length - 1];
|
||||||
|
|
||||||
|
//Check if no ID is specified
|
||||||
|
if(id.length < 1)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return Number(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user