Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
jsperf: Minor ui.js cleanup. [jddalton]
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 13, 2011
1 parent 9f9d8a5 commit bc4b7cf
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions examples/jsperf/ui.js
Expand Up @@ -13,7 +13,7 @@
/** CSS clasName used for `js enabled` styles */
JS_CLASS = 'js',

/** CSS class name used to display error-info */
/** CSS class name used to make content visible */
SHOW_CLASS = 'show',

/** CSS class name used to reset result styles */
Expand Down Expand Up @@ -242,8 +242,8 @@
* @private
*/
function onLoad() {
addClass('controls', 'show');
addClass('calgroup', 'show');
addClass('controls', SHOW_CLASS);
addClass('calgroup', SHOW_CLASS);

addListener('calibrate', 'click', onSetCalibrationState);
addListener('run', 'click', onRun);
Expand All @@ -263,7 +263,7 @@
$('calibrate').checked = false;
onSetCalibrationState();
addClass('controls', 'reduce');
addClass('firebug', 'show');
addClass('firebug', SHOW_CLASS);
}
// evaluate hash values
onHashChange();
Expand Down Expand Up @@ -306,15 +306,18 @@
* Parses the window.location.hash value into an object assigned to `ui.params`.
* @static
* @member ui
* @returns {Object} The suite instance.
*/
function parseHash() {
var hashes = location.hash.slice(1).split('&'),
params = this.params = { };
var me = this,
hashes = location.hash.slice(1).split('&'),
params = me.params = { };

each(hashes[0] && hashes, function(hash) {
var pair = hashes[length].split('=');
params[pair[0]] = pair[1];
});
return me;
}

/**
Expand Down Expand Up @@ -389,13 +392,10 @@
ui.benchmarks.push(bench);
ui.render();
})
.on('start', function() {
.on('start cycle', function() {
ui.render();
setHTML('run', RUN_TEXT.RUNNING);
})
.on('cycle', function() {
ui.render();
})
.on('complete', function() {
var benches = filter(ui.benchmarks, 'successful'),
fastest = filter(benches, 'fastest'),
Expand Down Expand Up @@ -439,9 +439,6 @@

/*--------------------------------------------------------------------------*/

// expose
window.ui = ui;

Benchmark.extend(ui, {

/**
Expand All @@ -456,7 +453,7 @@
*/
'params': {},

// parse query params into ui.params[] hash
// parse query params into ui.params hash
'parseHash': parseHash,

// (re)render the results of one or more benchmarks
Expand All @@ -465,12 +462,15 @@

/*--------------------------------------------------------------------------*/

// signal JavaScript detected
addClass(document.documentElement, JS_CLASS);
// expose
window.ui = ui;

// don't let users alert, confirm, prompt, or open new windows
window.alert = window.confirm = window.prompt = window.open = Benchmark.noop;

// signal JavaScript detected
addClass(document.documentElement, JS_CLASS);

// re-parse hash query params when it changes
addListener(window, 'hashchange', onHashChange);

Expand Down

0 comments on commit bc4b7cf

Please sign in to comment.