Created system object

This commit is contained in:
Pierre 2017-05-21 18:18:29 +02:00
parent ba3f2fb246
commit 42cd5dcd1c
6 changed files with 82 additions and 51 deletions

View File

@ -14,6 +14,13 @@ var ComunicWeb = {
* Common functions * Common functions
*/ */
common:{ common:{
/**
* Application system functions
*/
system:{
//TODO: implement
},
/** /**
* API functions * API functions
*/ */

View File

@ -0,0 +1,57 @@
/**
* Application background system functions
*
* @author Pierre HUBERT
*/
ComunicWeb.common.system = {
/**
* Initializate the application
*
* @return {Boolean} True for a success
*/
init: function(){
//Start init
ComunicWeb.debug.logMessage("Start initialization...");
/**
* Prepare login
*/
//Clean current page content
ComunicWeb.common.page.emptyPage();
//Show a wait splash screen
ComunicWeb.common.page.showWaitSplashScreen();
/**
* Language initator
*/
ComunicWeb.common.langs.initLanguages();
/**
* What to do after login refresh
*/
var afterLoginRefresh = function(){
/**
* Open a page
*/
//Get current page URI
var currentPage = ComunicWeb.common.url.getCurrentWebsiteURL();
//Open a page
ComunicWeb.common.page.openPage(currentPage);
//End of init
ComunicWeb.debug.logMessage("Application is ready !");
}
/**
* Get login state
*/
ComunicWeb.user.userLogin.refreshLoginState(afterLoginRefresh);
//Sucess
return true;
},
};

View File

@ -29,4 +29,16 @@ function createElem(nodeType, appendTo){
*/ */
function byId(nodeName){ function byId(nodeName){
return document.getElementById(nodeName); return document.getElementById(nodeName);
}
/**
* Create a quick language access function shorcut
*/
function lang(stringName, stringParams){
//Check if any params has been specified
if(!stringParams)
var stringParams = [];
//Call translate function
return ComunicWeb.common.langs.getTranslatedText(stringName, stringParams);
} }

View File

@ -6,54 +6,6 @@
//Anonymous function //Anonymous function
(function(){ (function(){
//Launch app
//Start init ComunicWeb.common.system.init();
ComunicWeb.debug.logMessage("Start initialization..."); })();
/**
* Prepare login
*/
//Clean current page content
ComunicWeb.common.page.emptyPage();
//Show a wait splash screen
ComunicWeb.common.page.showWaitSplashScreen();
/**
* Language initator
*/
ComunicWeb.common.langs.initLanguages();
/**
* What to do after login refresh
*/
var afterLoginRefresh = function(){
/**
* Open a page
*/
//Get current page URI
var currentPage = ComunicWeb.common.url.getCurrentWebsiteURL();
//Open a page
ComunicWeb.common.page.openPage(currentPage);
}
/**
* Get login state
*/
ComunicWeb.user.userLogin.refreshLoginState(afterLoginRefresh);
//End of init
ComunicWeb.debug.logMessage("Application is ready !");
})();
//Create a quick language access function shorcut
function lang(stringName, stringParams){
//Check if any params has been specified
if(!stringParams)
var stringParams = [];
//Call function
return ComunicWeb.common.langs.getTranslatedText(stringName, stringParams);
}

View File

@ -70,5 +70,7 @@ ComunicWeb.pages.menuBar = {
ComunicWeb.common.page.openPage("home"); ComunicWeb.common.page.openPage("home");
}); });
//Now we need to know if user is logged in or not
}, },
}; };

View File

@ -50,6 +50,7 @@ $config['JSfiles'] = array(
"%PATH_ASSETS%js/common/page.js", "%PATH_ASSETS%js/common/page.js",
"%PATH_ASSETS%js/common/notifications.js", "%PATH_ASSETS%js/common/notifications.js",
"%PATH_ASSETS%js/common/formChecker.js", "%PATH_ASSETS%js/common/formChecker.js",
"%PATH_ASSETS%js/common/system.js",
//User scripts //User scripts
"%PATH_ASSETS%js/user/loginTokens.js", "%PATH_ASSETS%js/user/loginTokens.js",