From 34ce3f9c13b2b8c54b1ece8f0edcacd437eae335 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 28 May 2017 13:48:19 +0200 Subject: [PATCH] Created friendList component --- assets/js/common/functionsSchema.js | 7 ++- assets/js/common/page.js | 13 +++- .../js/components/friendsList/friendsList.js | 59 +++++++++++++++++++ corePage/config/dev.config.php | 1 + 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 assets/js/components/friendsList/friendsList.js diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 808bc6b6..992d2ff2 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -441,7 +441,12 @@ var ComunicWeb = { //TODO : implement }, - + /** + * Friends list + */ + friendsList: { + //TODO : implement + } }, /** diff --git a/assets/js/common/page.js b/assets/js/common/page.js index a3d831d0..0d003d46 100644 --- a/assets/js/common/page.js +++ b/assets/js/common/page.js @@ -107,6 +107,11 @@ ComunicWeb.common.page = { 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 if(firstPartURI == ""){ firstPartURI = "home"; @@ -134,7 +139,7 @@ ComunicWeb.common.page = { ComunicWeb.common.url.changeURI(document.title, pageURI); //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(!mainContenerElem){ @@ -178,6 +183,12 @@ ComunicWeb.common.page = { //We load the menubar 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 diff --git a/assets/js/components/friendsList/friendsList.js b/assets/js/components/friendsList/friendsList.js new file mode 100644 index 00000000..21bc0052 --- /dev/null +++ b/assets/js/components/friendsList/friendsList.js @@ -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; + } +} \ No newline at end of file diff --git a/corePage/config/dev.config.php b/corePage/config/dev.config.php index 1d46ed26..27ccbb75 100644 --- a/corePage/config/dev.config.php +++ b/corePage/config/dev.config.php @@ -68,6 +68,7 @@ $config['JSfiles'] = array( "%PATH_ASSETS%js/components/menuBar/common.js", "%PATH_ASSETS%js/components/menuBar/notAuthenticated.js", "%PATH_ASSETS%js/components/menuBar/authenticated.js", + "%PATH_ASSETS%js/components/friendsList/friendsList.js", //User scripts "%PATH_ASSETS%js/user/loginTokens.js",