2017-05-21 16:18:29 +00:00
|
|
|
/**
|
|
|
|
* Application background system functions
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
2021-02-13 14:23:43 +00:00
|
|
|
const System = {
|
2017-05-21 16:18:29 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2020-04-01 08:23:45 +00:00
|
|
|
init: async function(openPage){
|
2017-06-07 13:53:39 +00:00
|
|
|
|
|
|
|
//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");
|
|
|
|
});
|
|
|
|
|
2018-03-14 18:41:45 +00:00
|
|
|
//Enable page URLs detection
|
|
|
|
window.location.changed = function(e){
|
2021-02-20 09:53:21 +00:00
|
|
|
Page.location_updated(e);
|
2018-03-14 18:41:45 +00:00
|
|
|
}
|
|
|
|
|
2017-05-21 16:18:29 +00:00
|
|
|
/**
|
|
|
|
* Prepare login
|
|
|
|
*/
|
|
|
|
//Clean current page content
|
2021-02-20 09:53:21 +00:00
|
|
|
Page.emptyPage();
|
2017-05-21 16:18:29 +00:00
|
|
|
|
|
|
|
//Show a wait splash screen
|
2021-02-20 09:53:21 +00:00
|
|
|
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();
|
|
|
|
|
2017-05-21 16:18:29 +00:00
|
|
|
/**
|
2021-02-13 14:14:45 +00:00
|
|
|
* Get login state
|
2017-05-21 16:18:29 +00:00
|
|
|
*/
|
2021-02-13 14:14:45 +00:00
|
|
|
await UserLogin.refreshLoginState();
|
|
|
|
|
|
|
|
// Initialize Websocket if user is connected
|
|
|
|
if(signed_in()) {
|
|
|
|
await UserWebSocket.Connect();
|
|
|
|
await UserWebSocket.WaitForConnected();
|
2017-05-21 16:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-13 14:14:45 +00:00
|
|
|
* Open a page
|
2017-05-21 16:18:29 +00:00
|
|
|
*/
|
2021-02-13 14:14:45 +00:00
|
|
|
if(!openPage){
|
|
|
|
//Refresh current page
|
|
|
|
ComunicWeb.common.page.refresh_current_page();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
//Open specified page
|
|
|
|
ComunicWeb.common.page.openPage(openPage);
|
2017-05-21 16:18:29 +00:00
|
|
|
|
2021-02-13 14:14:45 +00:00
|
|
|
//End of init
|
|
|
|
ComunicWeb.debug.logMessage("Application is ready !");
|
2017-05-21 16:18:29 +00:00
|
|
|
},
|
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
|
2021-02-13 14:23:43 +00:00
|
|
|
location.href = document.location.href.split("#")[0];
|
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;
|
|
|
|
},
|
2021-02-13 14:23:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ComunicWeb.common.system = System;
|