diff --git a/files/sys/system.js b/files/sys/system.js index aa7e965..fb021bb 100644 --- a/files/sys/system.js +++ b/files/sys/system.js @@ -1,7 +1,7 @@ var system = null; //mother object -function SYSTEM(endpoint, group,start_state){ +function SYSTEM(endpoint, group,start_state,hashchange){ system = this; this.LOG_START = 0; @@ -12,21 +12,29 @@ function SYSTEM(endpoint, group,start_state){ this.group = group; this.pages = null; this.state = {}; + this.state_info = {}; this.start_state = start_state; this.go_state(start_state); $(window).bind('hashchange', function( event ) { - system.go_state();}); + system.go_state(); + //user callback + if(hashchange){ + hashchange(system.cur_state());} + }); } //internal function to handle pagestate results -SYSTEM.prototype.handle_call_pages = function (data,id,forced) { +SYSTEM.prototype.handle_call_pages = function (data,id,forced,cached) { if(data['status']){ - system.log_info('load pages: endpoint '+system.endpoint+' group:'+system.group+' state:'+id+' - success'); + system.log_info('load pages: endpoint '+system.endpoint+' group:'+system.group+' state:'+id+' - '+(cached ? 'cached ' : 'success')); //state not found? if(data['result'].length === 0){ system.log_error('load pages: endpoint '+system.endpoint+' group:'+system.group+' state:'+id+' - state not found - redirecting to start state: '+system.start_state); system.load(system.start_state); return;} + //cache state info data + system.state_info[id] = data; + //update history? if(id !== system.cur_state()){ window.history.pushState(null, "", '#!'+id);} data['result'].forEach(function(entry) { @@ -109,20 +117,14 @@ SYSTEM.prototype.log_info = function(msg){ this.log(this.LOG_INFO,msg);} SYSTEM.prototype.log_error = function(msg){ this.log(this.LOG_ERROR,msg);} -//get the pages and save em -SYSTEM.prototype.load_page = function(){ - result = false; - newps = this.pages; - if(!this.pages){ - this.call('call=pages&group='+this.group,this.handle_call_pages,{},"json",false); - } else { result = true;} - this.pages = newps; - return result; -}; //load a pagestatewith given id SYSTEM.prototype.load = function(id,forced){ - system.log(system.LOG_START,'load page '+id); - this.call('call=pages&group='+this.group+'&state='+id,function(data){system.handle_call_pages(data,id,forced);},{},"json",false);}; + this.log(system.LOG_START,'load page: '+id+(forced ? ' - forced' : '')); + if(!forced && this.state_info[id]){ + this.handle_call_pages(this.state_info[id],id,forced,true); + }else { + this.call('call=pages&group='+this.group+'&state='+id,function(data){system.handle_call_pages(data,id,forced,false);},{},"json",false);} +}; SYSTEM.prototype.load_css = function loadCSS(csssrc) { var snode = document.createElement('link'); diff --git a/sai/modules/saimod_sys_api/saimod_sys_api.php b/sai/modules/saimod_sys_api/saimod_sys_api.php index d738458..ca20564 100644 --- a/sai/modules/saimod_sys_api/saimod_sys_api.php +++ b/sai/modules/saimod_sys_api/saimod_sys_api.php @@ -91,7 +91,7 @@ class saimod_sys_api extends \SYSTEM\SAI\SaiModule { } } - public static function html_li_menu(){return '
  • API
  • ';} + public static function html_li_menu(){return '
  • API
  • ';} public static function right_public(){return false;} public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI) && \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_API);} diff --git a/sai/modules/saimod_sys_cache/saimod_sys_cache.php b/sai/modules/saimod_sys_cache/saimod_sys_cache.php index f55788f..3720746 100644 --- a/sai/modules/saimod_sys_cache/saimod_sys_cache.php +++ b/sai/modules/saimod_sys_cache/saimod_sys_cache.php @@ -39,7 +39,7 @@ class saimod_sys_cache extends \SYSTEM\SAI\SaiModule { return 'success'; } - public static function html_li_menu(){return '
  • Cache
  • ';} + public static function html_li_menu(){return '
  • Cache
  • ';} public static function right_public(){return false;} public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);} diff --git a/sai/modules/saimod_sys_config/saimod_sys_config.php b/sai/modules/saimod_sys_config/saimod_sys_config.php index afec207..87016ef 100644 --- a/sai/modules/saimod_sys_config/saimod_sys_config.php +++ b/sai/modules/saimod_sys_config/saimod_sys_config.php @@ -30,7 +30,7 @@ class saimod_sys_config extends \SYSTEM\SAI\SaiModule { return $result; } - public static function html_li_menu(){return '
  • Config
  • ';} + public static function html_li_menu(){return '
  • Config
  • ';} public static function right_public(){return false;} public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);} diff --git a/sai/modules/saimod_sys_cron/saimod_sys_cron.php b/sai/modules/saimod_sys_cron/saimod_sys_cron.php index 62006d8..d7a9e43 100644 --- a/sai/modules/saimod_sys_cron/saimod_sys_cron.php +++ b/sai/modules/saimod_sys_cron/saimod_sys_cron.php @@ -39,7 +39,7 @@ class saimod_sys_cron extends \SYSTEM\SAI\SaiModule { \SYSTEM\DBD\SYS_SAIMOD_CRON_DEL::QI(array($cls)); return \SYSTEM\LOG\JsonResult::ok();} - public static function html_li_menu(){return '
  • Cron
  • ';} + public static function html_li_menu(){return '
  • Cron
  • ';} public static function right_public(){return false;} public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_CRON);} diff --git a/sai/modules/saimod_sys_docu/saimod_sys_docu.php b/sai/modules/saimod_sys_docu/saimod_sys_docu.php index 3e49a14..29eaf9d 100644 --- a/sai/modules/saimod_sys_docu/saimod_sys_docu.php +++ b/sai/modules/saimod_sys_docu/saimod_sys_docu.php @@ -41,7 +41,7 @@ class saimod_sys_docu extends \SYSTEM\SAI\SaiModule { return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_docu/tpl/tabs.tpl'), $vars); } - public static function html_li_menu(){return '
  • Docu
  • ';} + public static function html_li_menu(){return '
  • Docu
  • ';} public static function right_public(){return false;} public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);} diff --git a/sai/modules/saimod_sys_files/saimod_sys_files.php b/sai/modules/saimod_sys_files/saimod_sys_files.php index 287083d..b6b0762 100644 --- a/sai/modules/saimod_sys_files/saimod_sys_files.php +++ b/sai/modules/saimod_sys_files/saimod_sys_files.php @@ -42,7 +42,7 @@ class saimod_sys_files extends \SYSTEM\SAI\SaiModule { $result .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_files/tpl/saimod_sys_files_tableentry.tpl'), array('i' => $i++, 'cat' => $name, 'name' => $file, 'extension' => substr($file,-3,3), 'url' => 'api.php?call=files&cat='.$name.'&id='.$file));} return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_files/tpl/saimod_sys_files_tabfull.tpl'), array('cat' => $name, 'content' => $result));} - public static function html_li_menu(){return '
  • Files
  • ';} + public static function html_li_menu(){return '
  • Files
  • ';} public static function right_public(){return false;} public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI) && \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_FILES);} diff --git a/sai/modules/saimod_sys_log/saimod_sys_log.php b/sai/modules/saimod_sys_log/saimod_sys_log.php index 3a026bc..7e735be 100644 --- a/sai/modules/saimod_sys_log/saimod_sys_log.php +++ b/sai/modules/saimod_sys_log/saimod_sys_log.php @@ -342,7 +342,7 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule { } } - public static function html_li_menu(){return '
  • Log
  • ';} + public static function html_li_menu(){return '
  • Log
  • ';} public static function right_public(){return false;} public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);} diff --git a/sai/modules/saimod_sys_login/saimod_sys_login.php b/sai/modules/saimod_sys_login/saimod_sys_login.php index e3481f0..094e235 100644 --- a/sai/modules/saimod_sys_login/saimod_sys_login.php +++ b/sai/modules/saimod_sys_login/saimod_sys_login.php @@ -44,7 +44,7 @@ class saimod_sys_login extends \SYSTEM\SAI\SaiModule { \SYSTEM\locale::getStrings(\SYSTEM\DBD\system_locale_string::VALUE_CATEGORY_BASIC)); return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/tpl/register.tpl'), $vars);} - public static function html_li_menu(){return '