diff options
-rw-r--r-- | itjs.php | 13 | ||||
-rw-r--r-- | itjs/boot.js | 35 |
2 files changed, 15 insertions, 33 deletions
@@ -40,16 +40,11 @@ else if (!ereg('\.html$', $file)) if ($checksum != $_SERVER['HTTP_IF_NONE_MATCH']) { - if ($_REQUEST['init']) - $data .= "window.it_boot_init();"; - if ($_REQUEST['boot']) - { - $data = itjs::strip($data); - echo itjs::serialize(array('code' => $data, 'len' => strlen($data))); - } - else - echo itjs::strip($data); + $data = preg_replace('/([\xa0-\xff])/e', 'sprintf("\\u%04x", ord("\\1"))', $data) . "window.it_boot_init();"; + + $data = itjs::strip($data); + echo $data; } else header("HTTP/1.0 304 Not Modified"); diff --git a/itjs/boot.js b/itjs/boot.js index 46c9dc5..cf28518 100644 --- a/itjs/boot.js +++ b/itjs/boot.js @@ -40,7 +40,6 @@ function it_panic(msg) return it_catcherr('panic ' + msg, '-', -1); } - function it_boot_report(msg, file, line, error) { window.clearTimeout(window.it_domtimer); @@ -95,7 +94,7 @@ function it_boot(file, isretry) if (loader) { - loader.open("GET", it_boot_addparam(file, "boot=1" + (isretry ? "&retry=1&t="+new Date().getTime() : ""))); + loader.open("GET", it_boot_addparam(file, "boot=1" + (isretry ? "&retry=1" : ""))); loader.onreadystatechange = function() { var error = ""; @@ -104,28 +103,16 @@ function it_boot(file, isretry) { if (loader.status < 400) // Opera gives back 304 if from cache { - try + if (loader.responseText.length && loader.responseText.lastIndexOf('it_boot_init()') > 0) { - var data = eval("(" + loader.responseText + ")"); - - if (data.code.length == data.len) - { - var code = "try {" + data.code + "} catch (e) { it_boot_report('Load error', '-', -1, e); };window.it_boot_init()"; // Wrapped in try/catch as Konqueror does not support window.onerror - isretry = true; // No further retry after this point - - if (window.execScript) - window.execScript(code, "javascript"); // IE work-around to get script executed in global scope - else - window.setTimeout(code, 0); // Standard compliant version - } + var code = "try {" + loader.responseText + "} catch (e) { it_boot_report('Script exec error', '-', -1, e); }"; // Wrapped in try/catch as Konqueror does not support window.onerror + if (window.execScript) + window.execScript(code, "javascript"); // IE work-around to get script executed in global scope else - error = "Length mismatch " + data.code.length + " != " + data.len; - } - catch (e) - { - for (i in e) - error += i + "=" + e[i] + ";"; + window.setTimeout(code, 0); // Standard compliant version } + else + error = "Incomplete script load @ status " + loader.status; } else error = loader.statusText; @@ -146,12 +133,12 @@ function it_boot(file, isretry) var doc = document; var dom = doc && (dom = doc.getElementById('it_boot_dom')); // HTML has been rendered - if (window.opera) - document.write('<sc'+'ript type="text/javascript" src="'+it_boot_addparam(file, 'init=1')+'"><\/sc'+'ript>'); + if (window.opera || (document.all && navigator.platform.indexOf("Mac") >= 0)) + document.write('<sc'+'ript type="text/javascript" src="'+it_boot_addparam(file, 'boot=1')+'"><\/sc'+'ript>'); else if (dom) { var tag = doc.createElement("script"); - tag.src = it_boot_addparam(file, 'init=1'); + tag.src = it_boot_addparam(file, 'boot=1'); dom.appendChild(tag); } else |