Page loader alpha version

This commit is contained in:
Pierre 2017-01-22 13:03:31 +01:00
parent ff3318409f
commit 677b4c33d7
3 changed files with 98 additions and 1 deletions

View File

@ -7,8 +7,12 @@
ComunicWeb.common.page = {
/**
* Empty current page content
*
* @param {Boolean} createWrapper Optionnal, define if it is required to add a wrapper
* container to the page
* @return {Object} Wrapper element if it is created
*/
emptyPage: function(){
emptyPage: function(createWrapper){
//Empty body tag
document.body.innerHTML = "";
@ -19,6 +23,17 @@ ComunicWeb.common.page = {
//Log message
ComunicWeb.debug.logMessage("Clean the screen.");
//If required, create the wrapper element
if(createWrapper){
var wrapper = document.createElement("div");
wrapper.className = "wrapper";
wrapper.id = "wrapper";
document.body.appendChild(wrapper);
//Return link to wrapper
return(wrapper);
}
},
@ -50,5 +65,63 @@ ComunicWeb.common.page = {
openPage: function(pageURI){
//Log message
ComunicWeb.debug.logMessage("Open the following page: " + pageURI);
//Extract the first part of the URL
var firstPartURI = pageURI;
//Check if pageURI is empty
if(firstPartURI == ""){
firstPartURI = "home";
}
//Check if there is also subfolders
if(firstPartURI.indexOf("/") != "/"){
firstPartURI = firstPartURI.split("/")[0];
}
//Check if specied page exists
if(ComunicWeb.pagesList[firstPartURI]){
var pageInfos = ComunicWeb.pagesList[firstPartURI];
}
//Else we include the 404 not found page
else{
var pageInfos = ComunicWeb.pagesList.notFound;
}
//Change page title
document.title = pageInfos.pageTitle;
//Get the main contener of the page
var mainContenerElem = document.getElementById("wrapper");
//If we didn't get anything, clean the page and create a wrapper element
if(!mainContenerElem){
mainConterElem = this.emptyPage(true);
}
},
/**
* Prepare a template load by specifiying datas
*
* @return {Object} The object contener with all required infos
*/
prepareLoadTemplate: function(){
//Create an object
var obj = {
templateURL: "",
templateDatas: "",
};
//Return object
return obj;
}
/**
* Load, parse and show a template
*
* @param {Object} targetElem The target element where the template will be applied
* @param {Object} ResumeHERE
*/
};

23
assets/js/pagesList.js Normal file
View File

@ -0,0 +1,23 @@
/**
* Differents pages listing
*
* @author Pierre HUBERT
*/
ComunicWeb.pagesList = {
/**
* Home page
*/
home: {
pageTitle: "Comunic, v2",
},
/**
* 404 Page not found
*/
notFound: {
pageTitle: "404 page not found"
}
};

View File

@ -29,6 +29,7 @@ $config['JSfiles'] = array(
//App scripts
"%PATH_ASSETS%js/common/functionsSchema.js",
"%PATH_ASSETS%js/pagesList.js",
"%PATH_ASSETS%js/common/api.js",
"%PATH_ASSETS%js/common/errors.js",
"%PATH_ASSETS%js/common/messages.js",