Added utilities

This commit is contained in:
Pierre 2017-05-21 17:25:41 +02:00
parent 55f0e55bbd
commit 6ecd49d1b0
3 changed files with 48 additions and 2 deletions

View File

@ -124,19 +124,31 @@ ComunicWeb.common.page = {
ComunicWeb.common.url.changeURI(document.title, pageURI);
//Get the main contener of the page
//var mainContenerElem = document.getElementById("wrapper");
var mainContenerElem = document.getElementById("wrapper");
//If we didn't get anything, clean the page and create a wrapper element
if(!mainContenerElem){
var mainContenerElem = this.emptyPage(true);
}
//We check if the page is a full screen page
if(pageInfos.disableMenus){
//We force the screen to be cleaned
var mainContenerElem = this.emptyPage(true);
var pageTarget = mainContenerElem;
}
//Else
else {
//We try to locate menubar
}
//Check if some additionnal data was specified
if(!additionnalData)
additionnalData = {};
//Call the method related to the page
eval(pageInfos.methodHandler + ("(additionnalData, mainContenerElem);"));
eval(pageInfos.methodHandler + ("(additionnalData, pageTarget);"));
},

32
assets/js/common/utils.js Normal file
View File

@ -0,0 +1,32 @@
/**
* Utilities functions
*
* @author Pierre HUBERT
*/
/**
* Create a new HTML node
*
* @param {String} nodeType The type of the HTML node
* @param {HTMLElement} appendTo Optionnal, defines node on which the new node will be applied
* @return {HTMLElement} The newly created element
*/
function createElem(nodeType, appendTo){
var newElem = document.createElement(nodeType);
if(appendTo)
appendTo.appendChild(newElem);
//Return result
return newElem;
}
/**
* Get an HTML element specified by an ID
*
* @param {String} nodeName The ID of the element
* @return {HTMLElement} The elemnt / False for a failure
*/
function byId(nodeName){
return document.getElementById(nodeName);
}

View File

@ -11,6 +11,7 @@ ComunicWeb.pagesList = {
home: {
pageTitle: "Comunic, v2",
methodHandler: "ComunicWeb.pages.home.home.openHomePage",
disableMenus: false,
},
/**
@ -19,6 +20,7 @@ ComunicWeb.pagesList = {
login: {
pageTitle: "Login page",
methodHandler: "ComunicWeb.pages.login.openLoginPage",
disableMenus: true,
},
/**