From 42cd5dcd1cdaad40bbeb4d4c93b52f75dd7c8769 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 21 May 2017 18:18:29 +0200 Subject: [PATCH] Created system object --- assets/js/common/functionsSchema.js | 7 ++++ assets/js/common/system.js | 57 +++++++++++++++++++++++++++++ assets/js/common/utils.js | 12 ++++++ assets/js/init.js | 54 ++------------------------- assets/js/pages/menuBar.js | 2 + corePage/config/dev.config.php | 1 + 6 files changed, 82 insertions(+), 51 deletions(-) create mode 100644 assets/js/common/system.js diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 47329393..d23a9d60 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -14,6 +14,13 @@ var ComunicWeb = { * Common functions */ common:{ + /** + * Application system functions + */ + system:{ + //TODO: implement + }, + /** * API functions */ diff --git a/assets/js/common/system.js b/assets/js/common/system.js new file mode 100644 index 00000000..5e6525fa --- /dev/null +++ b/assets/js/common/system.js @@ -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; + }, +}; \ No newline at end of file diff --git a/assets/js/common/utils.js b/assets/js/common/utils.js index 24689f83..9c05cf3b 100644 --- a/assets/js/common/utils.js +++ b/assets/js/common/utils.js @@ -29,4 +29,16 @@ function createElem(nodeType, appendTo){ */ function byId(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); } \ No newline at end of file diff --git a/assets/js/init.js b/assets/js/init.js index a051e835..dc18c933 100644 --- a/assets/js/init.js +++ b/assets/js/init.js @@ -6,54 +6,6 @@ //Anonymous function (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); - } - - /** - * 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); -} \ No newline at end of file + //Launch app + ComunicWeb.common.system.init(); +})(); \ No newline at end of file diff --git a/assets/js/pages/menuBar.js b/assets/js/pages/menuBar.js index 0bb260ac..c1867807 100644 --- a/assets/js/pages/menuBar.js +++ b/assets/js/pages/menuBar.js @@ -70,5 +70,7 @@ ComunicWeb.pages.menuBar = { ComunicWeb.common.page.openPage("home"); }); + //Now we need to know if user is logged in or not + }, }; \ No newline at end of file diff --git a/corePage/config/dev.config.php b/corePage/config/dev.config.php index a23d57c5..c4a60055 100644 --- a/corePage/config/dev.config.php +++ b/corePage/config/dev.config.php @@ -50,6 +50,7 @@ $config['JSfiles'] = array( "%PATH_ASSETS%js/common/page.js", "%PATH_ASSETS%js/common/notifications.js", "%PATH_ASSETS%js/common/formChecker.js", + "%PATH_ASSETS%js/common/system.js", //User scripts "%PATH_ASSETS%js/user/loginTokens.js",