Created friendList component

This commit is contained in:
Pierre 2017-05-28 13:48:19 +02:00
parent 09e34a8969
commit 34ce3f9c13
4 changed files with 78 additions and 2 deletions

View File

@ -441,7 +441,12 @@ var ComunicWeb = {
//TODO : implement //TODO : implement
}, },
/**
* Friends list
*/
friendsList: {
//TODO : implement
}
}, },
/** /**

View File

@ -107,6 +107,11 @@ ComunicWeb.common.page = {
firstPartURI = firstPartURI.split("#")[0]; firstPartURI = firstPartURI.split("#")[0];
} }
//Check if there are $_GET parametres included with the URL
if(firstPartURI.includes("?") != -1){
firstPartURI = firstPartURI.split("?")[0];
}
//Check if pageURI is empty //Check if pageURI is empty
if(firstPartURI == ""){ if(firstPartURI == ""){
firstPartURI = "home"; firstPartURI = "home";
@ -134,7 +139,7 @@ ComunicWeb.common.page = {
ComunicWeb.common.url.changeURI(document.title, pageURI); ComunicWeb.common.url.changeURI(document.title, pageURI);
//Get the main contener of the page //Get the main contener of the page
var mainContenerElem =byId("wrapper"); var mainContenerElem = byId("wrapper");
//If we didn't get anything, clean the page and create a wrapper element //If we didn't get anything, clean the page and create a wrapper element
if(!mainContenerElem){ if(!mainContenerElem){
@ -178,6 +183,12 @@ ComunicWeb.common.page = {
//We load the menubar //We load the menubar
ComunicWeb.components.menuBar.common.display(); ComunicWeb.components.menuBar.common.display();
//We load specific components for logged in users
if(ComunicWeb.user.userLogin.getUserLoginState()){
//We load frieds list (if user is logged in)
ComunicWeb.components.friendsList.display();
}
} }
//Check if some additionnal data was specified //Check if some additionnal data was specified

View File

@ -0,0 +1,59 @@
/**
* Friends list
*
* @author Pierre HUBERT
*/
ComunicWeb.components.friendsList = {
/**
* Display friends list
*
* @return {Boolean} True for a success
*/
display: function(){
//Log action
ComunicWeb.debug.logMessage("Initialize friends list.");
//Check if friends list already exists or not
var friendsListContainer = byId("friendsList");
//We check if the friend list already exists or not
if(friendsListContainer){
ComunicWeb.debug.logMessage("Notice: friend list already present on the page. Nothing to be done.");
return true;
}
//Create and apply friends list element
var friendsListContainer = createElem("div");
//Check if "pageTarget" already exists or not
var pageTarget = byId("pageTarget");
if(pageTarget){
//Insert friends list just before pageTarget
byId("wrapper").insertBefore(friendsListContainer, pageTarget);
}
else{
byId("wrapper").appendChild(friendsListContainer); //Just happend the menubar
}
//Initializate friends list
this.init(friendsListContainer);
//Success
return true;
},
/**
* Initializate a friend list
*
* @param {HTMLElement} friendsListContainer The container of the friend list
* @return {Boolean} True for a success
*/
init: function(friendsListContainer){
//Success
return true;
}
}

View File

@ -68,6 +68,7 @@ $config['JSfiles'] = array(
"%PATH_ASSETS%js/components/menuBar/common.js", "%PATH_ASSETS%js/components/menuBar/common.js",
"%PATH_ASSETS%js/components/menuBar/notAuthenticated.js", "%PATH_ASSETS%js/components/menuBar/notAuthenticated.js",
"%PATH_ASSETS%js/components/menuBar/authenticated.js", "%PATH_ASSETS%js/components/menuBar/authenticated.js",
"%PATH_ASSETS%js/components/friendsList/friendsList.js",
//User scripts //User scripts
"%PATH_ASSETS%js/user/loginTokens.js", "%PATH_ASSETS%js/user/loginTokens.js",