Avoid using the nano applet in perf/index.html if it isn't needed.

Former-commit-id: 342983337140dd5608848b7f09d24038ea61d1a1
This commit is contained in:
John-David Dalton
2012-08-19 15:35:38 -07:00
parent 7cb37411c9
commit 260ff6de3e

View File

@@ -27,8 +27,23 @@
<script src="perf.js"></script> <script src="perf.js"></script>
<script> <script>
(function() { (function() {
var useApplet = !/[?&]nojava=true(?:&|$)/.test(location.search); if (/[?&]nojava=true(?:&|$)/.test(location.search)) {
return;
}
var measured,
perfNow,
begin = new Date;
// is the applet really needed?
while (!(measured = new Date - begin)) { }
if (measured != 1 && !((perfNow = window.performance) && typeof (perfNow.webkitNow || perfNow.now) == 'function')) {
// load applet
document.write('<applet code="nano" archive="../vendor/benchmark.js/nano.jar"></applet>');
}
}());
</script>
<script>
(function() {
function init() { function init() {
var fbUI = document.getElementById('FirebugUI'), var fbUI = document.getElementById('FirebugUI'),
fbDoc = fbUI && (fbDoc = fbUI.contentWindow || fbUI.contentDocument).document || fbDoc, fbDoc = fbUI && (fbDoc = fbUI.contentWindow || fbUI.contentDocument).document || fbDoc,
@@ -38,16 +53,7 @@
return setTimeout(init, 15); return setTimeout(init, 15);
} }
fbUI.style.height = fbDoc.body.style.height = fbDoc.documentElement.style.height = '100%'; fbUI.style.height = fbDoc.body.style.height = fbDoc.documentElement.style.height = '100%';
setTimeout(run, 15);
// give applet time to initialize
lodash.delay(run, useApplet ? 500 : 15);
}
if (useApplet) {
// using innerHTML avoids an alert in some versions of IE6
var div = document.createElement('div');
div.innerHTML = '<applet code=nano archive="../vendor/benchmark.js/nano.jar">';
document.body.insertBefore(div.lastChild, document.body.firstChild);
} }
window.onload = init; window.onload = init;