ComunicWeb/assets/js/common/system.js

117 lines
2.5 KiB
JavaScript
Raw Normal View History

2017-05-21 16:18:29 +00:00
/**
* Application background system functions
*
* @author Pierre HUBERT
*/
ComunicWeb.common.system = {
/**
* Initializate the application
*
2017-06-14 09:46:10 +00:00
* @param {String} Specify a page to open
2017-05-21 16:18:29 +00:00
* @return {Boolean} True for a success
*/
2017-06-14 09:46:10 +00:00
init: function(openPage){
//Display Comunic logo
ComunicWeb.debug.displayComunicLogo();
2017-05-21 16:18:29 +00:00
//Start init
ComunicWeb.debug.logMessage("Start initialization...");
2017-06-05 14:29:28 +00:00
//Disable tooltips
$(function () {
$(document.body).tooltip("disable");
});
2017-05-21 16:18:29 +00:00
/**
* Prepare login
*/
//Clean current page content
ComunicWeb.common.page.emptyPage();
//Show a wait splash screen
2017-06-14 09:46:10 +00:00
ComunicWeb.common.page.showWaitSplashScreen("Starting up...");
2017-05-21 16:18:29 +00:00
/**
* Language initator
*/
ComunicWeb.common.langs.initLanguages();
/**
* What to do after login refresh
*/
var afterLoginRefresh = function(){
/**
* Open a page
*/
2017-06-14 09:46:10 +00:00
if(!openPage){
//Get current page URI
var currentPage = ComunicWeb.common.url.getCurrentWebsiteURL();
2017-05-21 16:18:29 +00:00
2017-06-14 09:46:10 +00:00
//Open a page
ComunicWeb.common.page.openPage(currentPage);
}
else
//Open specified page
ComunicWeb.common.page.openPage(openPage);
2017-05-21 16:18:29 +00:00
//End of init
ComunicWeb.debug.logMessage("Application is ready !");
}
/**
* Get login state
*/
ComunicWeb.user.userLogin.refreshLoginState(afterLoginRefresh);
2017-06-03 12:37:59 +00:00
/**
* Automaticaly refresh login state
*/
var autoRefresh = setInterval((function(){
ComunicWeb.user.userLogin.refreshLoginState();
2017-06-03 13:41:04 +00:00
}), 20000);
2017-06-14 09:46:10 +00:00
ComunicWeb.common.cacheManager.registerInterval(autoRefresh);
2017-06-03 12:37:59 +00:00
2017-06-14 09:46:10 +00:00
//Success
2017-05-21 16:18:29 +00:00
return true;
},
2017-05-21 16:26:18 +00:00
/**
* Restart the application
*
* @return {Boolean} True for a success
*/
restart: function(){
//Show a wait splashscreen message
ComunicWeb.common.page.showWaitSplashScreen("Restarting...");
//Reload the page
location.href = document.location;
2017-06-14 09:46:10 +00:00
},
/**
* Reset the application
*
* @param {Boolean} complete Specify wether the cache cleaning has to be complete or not (for logout)
* @param {String} openPage Specify a page to open once the application is restarted
* @return {Boolean} True for a success
*/
reset: function(complete, openPage){
//Show a wait splashscreen message
ComunicWeb.common.page.showWaitSplashScreen("Reset the application in progress...");
//Clear intervals
ComunicWeb.common.cacheManager.cleanIntervals();
//Clean caches
ComunicWeb.common.cacheManager.cleanCaches(complete);
//Init the page again
this.init(openPage);
//Success
return true;
},
2017-05-21 16:18:29 +00:00
};