includes/clientside/static/enano-lib-basic.js
changeset 586 234ddd896555
parent 585 35e91d16ecf5
child 588 20484deb89cd
equal deleted inserted replaced
585:35e91d16ecf5 586:234ddd896555
    13  * Unless otherwise noted, all of the code in these script files may be used freely so long as the above license block
    13  * Unless otherwise noted, all of the code in these script files may be used freely so long as the above license block
    14  * is displayed and your modified code is distributed in compliance with the GPL. See the special page "About Enano" on
    14  * is displayed and your modified code is distributed in compliance with the GPL. See the special page "About Enano" on
    15  * this website for more information.
    15  * this website for more information.
    16  */
    16  */
    17 
    17 
    18 if(typeof title != 'string')
    18 if ( typeof(title) != 'string')
    19 {
    19 {
    20   alert('There was a problem loading the PHP-generated Javascript variables that control parameters for AJAX applets. Most on-page functionality will be very badly broken.\n\nTheme developers, ensure that you are using {JS_DYNAMIC_VARS} *before* you include jsres.php.');
    20   alert('There was a problem loading the PHP-generated Javascript variables that control parameters for AJAX applets. Most on-page functionality will be very badly broken.\n\nTheme developers, ensure that you are using {JS_DYNAMIC_VARS} *before* you include jsres.php.');
       
    21 }
       
    22 
       
    23 if ( typeof(ENANO_JSRES_COMPRESSED) == undefined )
       
    24 {
       
    25   var ENANO_JSRES_COMPRESSED = false;
    21 }
    26 }
    22 
    27 
    23 // Run-time variables
    28 // Run-time variables
    24 
    29 
    25 var detect = navigator.userAgent.toLowerCase();
    30 var detect = navigator.userAgent.toLowerCase();
   194     }
   199     }
   195   }
   200   }
   196 }
   201 }
   197 
   202 
   198 var loaded_components = {};
   203 var loaded_components = {};
       
   204 var _load_component_running = false;
   199 function load_component(file)
   205 function load_component(file)
   200 {
   206 {
       
   207   _load_component_running = true;
   201   file = file.replace(/\.js$/, '');
   208   file = file.replace(/\.js$/, '');
   202   
   209   
   203   console.info('Loading component %s via AJAX', file);
   210   console.info('Loading component %s via AJAX', file);
   204   
   211   
   205   if ( loaded_components[file] )
   212   if ( loaded_components[file] )
   212   
   219   
   213   // get an XHR instance
   220   // get an XHR instance
   214   var ajax = ajaxMakeXHR();
   221   var ajax = ajaxMakeXHR();
   215   
   222   
   216   file = file + '.js';
   223   file = file + '.js';
   217   var uri = scriptPath + '/includes/clientside/static/' + file;
   224   var uri = ( ENANO_JSRES_COMPRESSED ) ? scriptPath + '/includes/clientside/jsres.php?f=' + file : scriptPath + '/includes/clientside/static/' + file;
   218   ajax.open('GET', uri, false);
   225   ajax.open('GET', uri, false);
   219   ajax.send(null);
   226   ajax.send(null);
   220   if ( ajax.readyState == 4 && ajax.status == 200 )
   227   if ( ajax.readyState == 4 && ajax.status == 200 )
   221   {
   228   {
   222     onload_hooks = new Array();
   229     onload_hooks = new Array();
   224     load_hide_win();
   231     load_hide_win();
   225     runOnloadHooks();
   232     runOnloadHooks();
   226   }
   233   }
   227   
   234   
   228   loaded_components[file] = true;
   235   loaded_components[file] = true;
       
   236   _load_component_running = false;
   229   return true;
   237   return true;
   230 }
   238 }
   231 
   239 
   232 function load_show_win(file)
   240 function load_show_win(file)
   233 {
   241 {
   349   'dynano.js',
   357   'dynano.js',
   350   'functions.js',
   358   'functions.js',
   351   'dropdown.js',
   359   'dropdown.js',
   352   'json.js',
   360   'json.js',
   353   'sliders.js',
   361   'sliders.js',
   354   'pwstrength.js',
       
   355   'loader.js'
   362   'loader.js'
   356 ];
   363 ];
   357 
       
   358 var problem_scripts = {
       
   359   'json.js' : true,
       
   360   'template-compiler.js' : true
       
   361 };
       
   362 
   364 
   363 for(var f in thefiles)
   365 for(var f in thefiles)
   364 {
   366 {
   365   if ( typeof(thefiles[f]) != 'string' )
   367   if ( typeof(thefiles[f]) != 'string' )
   366     continue;
   368     continue;
   367   var script = document.createElement('script');
   369   var script = document.createElement('script');
   368   script.type="text/javascript";
   370   script.type="text/javascript";
   369   if ( problem_scripts[thefiles[f]] && KILL_SWITCH )
   371   if ( thefiles[f] == 'json.js' && KILL_SWITCH )
   370   {
   372   {
   371     // alert('kill switch and problem script');
   373     // alert('kill switch and problem script');
   372     continue;
   374     continue;
   373   }
   375   }
   374   script.src=scriptPath+"/includes/clientside/static/"+thefiles[f];
   376   script.src=scriptPath+"/includes/clientside/static/"+thefiles[f];
   441   ajaxOpenACLManager: 'acl.js',
   443   ajaxOpenACLManager: 'acl.js',
   442   ajaxAdminPage: 'login.js',
   444   ajaxAdminPage: 'login.js',
   443   ajaxInitLogout: 'login.js',
   445   ajaxInitLogout: 'login.js',
   444   ajaxStartLogin: 'login.js',
   446   ajaxStartLogin: 'login.js',
   445   ajaxStartAdminLogin: 'login.js',
   447   ajaxStartAdminLogin: 'login.js',
       
   448   ajaxLoginNavTo: 'login.js',
   446   ajaxAdminPage: 'login.js',
   449   ajaxAdminPage: 'login.js',
   447   mb_logout: 'login.js',
   450   mb_logout: 'login.js',
   448   selectButtonMajor: 'toolbar.js',
   451   selectButtonMajor: 'toolbar.js',
   449   selectButtonMinor: 'toolbar.js',
   452   selectButtonMinor: 'toolbar.js',
   450   unselectAllButtonsMajor: 'toolbar.js',
   453   unselectAllButtonsMajor: 'toolbar.js',
   451   unselectAllButtonsMinor: 'toolbar.js',
   454   unselectAllButtonsMinor: 'toolbar.js',
   452   darken: 'fadefilter.js',
   455   darken: 'fadefilter.js',
   453   enlighten: 'fadefilter.js',
   456   enlighten: 'fadefilter.js',
   454   autofill_onload: 'autofill.js',
   457   autofill_onload: 'autofill.js',
       
   458   password_score: 'pwstrength.js',
       
   459   password_score_field: 'pwstrength.js',
   455 }
   460 }
   456 
   461 
   457 var placeholder_instances = {};
   462 var placeholder_instances = {};
   458 
   463 
   459 for ( var i in placeholder_list )
   464 for ( var i in placeholder_list )