ComunicWeb/assets/js/common/system.js

139 lines
2.9 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
*
2018-01-07 18:17:50 +00:00
* @param {String} openPage 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...");
2018-07-03 06:32:55 +00:00
//Enable error reporting
window.addEventListener("error", function(e){
ComunicWeb.common.error.syntaxtError(e.error);
});
2017-06-05 14:29:28 +00:00
//Disable tooltips
$(function () {
$(document.body).tooltip("disable");
});
//Enable page URLs detection
window.location.changed = function(e){
ComunicWeb.common.page.location_updated(e);
}
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();
2019-01-11 13:50:06 +00:00
/**
* Initialize incognito mode detection
*/
ComunicWeb.components.incognito.management.init();
/**
* Refresh dark theme mode
*/
ComunicWeb.components.darkTheme.refresh();
/**
* Initialize call system
*/
ComunicWeb.components.calls.controller.init();
2017-05-21 16:18:29 +00:00
/**
* What to do after login refresh
*/
var afterLoginRefresh = function(){
/**
* Open a page
*/
2017-06-14 09:46:10 +00:00
if(!openPage){
2018-05-12 10:34:39 +00:00
//Refresh current page
ComunicWeb.common.page.refresh_current_page();
2017-06-14 09:46:10 +00:00
}
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-24 13:07:23 +00:00
}), 25000);
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
};