Mercurial > bugzilla-dashboard
changeset 106:aad1c0a17ba4
added JSON support for iphone.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Thu, 29 Apr 2010 11:11:04 -0700 |
parents | e309abd8ceca |
children | 9a524c01b0f1 |
files | js/black-box.js |
diffstat | 1 files changed, 46 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/js/black-box.js Thu Apr 29 10:41:59 2010 -0700 +++ b/js/black-box.js Thu Apr 29 11:11:04 2010 -0700 @@ -62,44 +62,52 @@ iframe.src = "index.html?testing=1"; } +function initialize() { + $(".test-button").click( + function() { + var testButton = this; + var testFunc = window[testButton.id]; + var cmds = []; + const COMMAND_DELAY = 500; + + function queueNextCommand() { + if (cmds.length) + window.setTimeout(nextCommand, COMMAND_DELAY); + else { + $(testButton).removeClass("running"); + } + } + + function nextCommand() { + var cmd = cmds.shift(); + cmd(); + queueNextCommand(); + } + + $(testButton).addClass("running"); + + resetDashboard( + function(method, args) { + switch (method) { + case "blackBox.onDashboardLoaded": + var dashboard = args[0]; + var options = args[1]; + cmds = testFunc(options.jQuery); + break; + case "blackBox.afterInit": + queueNextCommand(); + break; + } + }); + }); + + resetDashboard(function() {}); +} + $(window).ready( function() { - $(".test-button").click( - function() { - var testButton = this; - var testFunc = window[testButton.id]; - var cmds = []; - const COMMAND_DELAY = 500; - - function queueNextCommand() { - if (cmds.length) - window.setTimeout(nextCommand, COMMAND_DELAY); - else { - $(testButton).removeClass("running"); - } - } - - function nextCommand() { - var cmd = cmds.shift(); - cmd(); - queueNextCommand(); - } - - $(testButton).addClass("running"); - - resetDashboard( - function(method, args) { - switch (method) { - case "blackBox.onDashboardLoaded": - var dashboard = args[0]; - var options = args[1]; - cmds = testFunc(options.jQuery); - break; - case "blackBox.afterInit": - queueNextCommand(); - break; - } - }); - }); - resetDashboard(function() {}); + if (!('JSON' in window)) + Require.preload(document, ["js/json2.js"], initialize); + else + initialize(); });