mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 12:14:12 +00:00 
			
		
		
		
	Created friendList component
This commit is contained in:
		@@ -441,7 +441,12 @@ var ComunicWeb = {
 | 
			
		||||
			//TODO : implement
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * Friends list
 | 
			
		||||
		 */
 | 
			
		||||
		friendsList: {
 | 
			
		||||
			//TODO : implement
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										59
									
								
								assets/js/components/friendsList/friendsList.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								assets/js/components/friendsList/friendsList.js
									
									
									
									
									
										Normal 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;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user