includes/clientside/jsres.php
changeset 1046 cfc6c30c5e2d
parent 865 7f8262b2004a
child 1053 bdbb49cf6f1b
--- a/includes/clientside/jsres.php	Wed Jul 08 18:53:45 2009 -0400
+++ b/includes/clientside/jsres.php	Wed Jul 08 22:27:24 2009 -0400
@@ -40,12 +40,7 @@
 $local_start = microtime_float();
 
 // Disable for IE, it causes problems.
-if ( ( strstr(@$_SERVER['HTTP_USER_AGENT'], 'MSIE') || defined('ENANO_JS_DEBUG') ) && !isset($_GET['early']) )
-{
-  header('HTTP/1.1 302 Redirect');
-  header('Location: static/enano-lib-basic.js');
-  exit();
-}
+$disable_compress = ( strstr(@$_SERVER['HTTP_USER_AGENT'], 'MSIE') || defined('ENANO_JS_DEBUG') ) && !isset($_GET['early']);
 
 // Setup Enano
 
@@ -135,10 +130,12 @@
 // note - obfuscated for optimization purposes. The exact same code except properly indented is in enano-lib-basic.
 if ( isset($_GET['early']) )
 {
-  header('ETag: enanocms-lib-early-r2');
+  header('ETag: enanocms-lib-early-r3');
   header('Expires: Wed, 1 Jan 2020 00:00:00 GMT');
   
   echo <<<JSEOF
+window.loaded_components = window.loaded_components || {};
+window.onload_complete = false;
 var onload_hooks = new Array();function addOnloadHook(func){if ( typeof ( func ) == 'function' ){if ( typeof(onload_hooks.push) == 'function' ){onload_hooks.push(func);}else{onload_hooks[onload_hooks.length] = func;};};}
 JSEOF;
   
@@ -198,8 +195,9 @@
       $apex = filemtime("includes/clientside/static/$js_file");
       
       $file_contents = file_get_contents("includes/clientside/static/$js_file");
-      $everything .= jsres_cache_check($js_file, $file_contents) . ' loaded_components[\'' . $js_file . '\'] = true; if ( onload_complete ) { runOnloadHooks(); onload_hooks = []; };';
+      $everything .= jsres_cache_check($js_file, $file_contents) . ' loaded_components[\'' . $js_file . '\'] = true;';
     }
+    $everything .= 'if ( onload_complete ) { console.debug("running hooks from jsres"); runOnloadHooks(); onload_hooks = []; };';
   }
   else
   {
@@ -212,7 +210,7 @@
     $apex = filemtime("includes/clientside/static/$js_file");
     
     $file_contents = file_get_contents("includes/clientside/static/$js_file");
-    $everything = jsres_cache_check($js_file, $file_contents) . ' loaded_components[\'' . $js_file . '\'] = true; if ( onload_complete ) { runOnloadHooks(); onload_hooks = []; };';
+    $everything = jsres_cache_check($js_file, $file_contents) . ' loaded_components[\'' . $js_file . '\'] = true; if ( onload_complete ) { console.debug("running hooks from jsres"); runOnloadHooks(); onload_hooks = []; };';
   }
 }
 else
@@ -292,6 +290,10 @@
 function jsres_cache_check($js_file, $file_contents)
 {
   global $full_compress_safe, $compress_unsafe;
+  global $disable_compress;
+  
+  if ( $disable_compress )
+    return $file_contents;
   
   $file_md5 = md5($file_contents);