117 lines
2.5 KiB
JavaScript
Raw Normal View History

2017-05-21 18:18:29 +02:00
/**
* Application background system functions
*
* @author Pierre HUBERT
*/
ComunicWeb.common.system = {
/**
* Initializate the application
*
2018-01-07 19:17:50 +01:00
* @param {String} openPage Specify a page to open
2017-05-21 18:18:29 +02:00
* @return {Boolean} True for a success
*/
2017-06-14 11:46:10 +02:00
init: function(openPage){
//Display Comunic logo
ComunicWeb.debug.displayComunicLogo();
2017-05-21 18:18:29 +02:00
//Start init
ComunicWeb.debug.logMessage("Start initialization...");
2017-06-05 16:29:28 +02:00
//Disable tooltips
$(function () {
$(document.body).tooltip("disable");
});
2017-05-21 18:18:29 +02:00
/**
* Prepare login
*/
//Clean current page content
ComunicWeb.common.page.emptyPage();
//Show a wait splash screen
2017-06-14 11:46:10 +02:00
ComunicWeb.common.page.showWaitSplashScreen("Starting up...");
2017-05-21 18:18:29 +02:00
/**
* Language initator
*/
ComunicWeb.common.langs.initLanguages();
/**
* What to do after login refresh
*/
var afterLoginRefresh = function(){
/**
* Open a page
*/
2017-06-14 11:46:10 +02:00
if(!openPage){
//Get current page URI
var currentPage = ComunicWeb.common.url.getCurrentWebsiteURL();
2017-05-21 18:18:29 +02:00
2017-06-14 11:46:10 +02:00
//Open a page
ComunicWeb.common.page.openPage(currentPage);
}
else
//Open specified page
ComunicWeb.common.page.openPage(openPage);
2017-05-21 18:18:29 +02:00
//End of init
ComunicWeb.debug.logMessage("Application is ready !");
}
/**
* Get login state
*/
ComunicWeb.user.userLogin.refreshLoginState(afterLoginRefresh);
2017-06-03 14:37:59 +02:00
/**
* Automaticaly refresh login state
*/
var autoRefresh = setInterval((function(){
ComunicWeb.user.userLogin.refreshLoginState();
2017-06-24 15:07:23 +02:00
}), 25000);
2017-06-14 11:46:10 +02:00
ComunicWeb.common.cacheManager.registerInterval(autoRefresh);
2017-06-03 14:37:59 +02:00
2017-06-14 11:46:10 +02:00
//Success
2017-05-21 18:18:29 +02:00
return true;
},
2017-05-21 18:26:18 +02: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 11:46:10 +02: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 18:18:29 +02:00
};