mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Page loader alpha version
This commit is contained in:
parent
ff3318409f
commit
677b4c33d7
@ -7,8 +7,12 @@
|
|||||||
ComunicWeb.common.page = {
|
ComunicWeb.common.page = {
|
||||||
/**
|
/**
|
||||||
* Empty current page content
|
* 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
|
//Empty body tag
|
||||||
document.body.innerHTML = "";
|
document.body.innerHTML = "";
|
||||||
|
|
||||||
@ -19,6 +23,17 @@ ComunicWeb.common.page = {
|
|||||||
|
|
||||||
//Log message
|
//Log message
|
||||||
ComunicWeb.debug.logMessage("Clean the screen.");
|
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){
|
openPage: function(pageURI){
|
||||||
//Log message
|
//Log message
|
||||||
ComunicWeb.debug.logMessage("Open the following page: " + pageURI);
|
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
23
assets/js/pagesList.js
Normal 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"
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
@ -29,6 +29,7 @@ $config['JSfiles'] = array(
|
|||||||
|
|
||||||
//App scripts
|
//App scripts
|
||||||
"%PATH_ASSETS%js/common/functionsSchema.js",
|
"%PATH_ASSETS%js/common/functionsSchema.js",
|
||||||
|
"%PATH_ASSETS%js/pagesList.js",
|
||||||
"%PATH_ASSETS%js/common/api.js",
|
"%PATH_ASSETS%js/common/api.js",
|
||||||
"%PATH_ASSETS%js/common/errors.js",
|
"%PATH_ASSETS%js/common/errors.js",
|
||||||
"%PATH_ASSETS%js/common/messages.js",
|
"%PATH_ASSETS%js/common/messages.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user