comparison js/black-box.js @ 106:aad1c0a17ba4

added JSON support for iphone.
author Atul Varma <avarma@mozilla.com>
date Thu, 29 Apr 2010 11:11:04 -0700
parents a994fc89f341
children 3ad618d3370f
comparison
equal deleted inserted replaced
105:e309abd8ceca 106:aad1c0a17ba4
60 setDashboardLoaded(delegate, window); 60 setDashboardLoaded(delegate, window);
61 var iframe = $("#dashboard").get(0); 61 var iframe = $("#dashboard").get(0);
62 iframe.src = "index.html?testing=1"; 62 iframe.src = "index.html?testing=1";
63 } 63 }
64 64
65 function initialize() {
66 $(".test-button").click(
67 function() {
68 var testButton = this;
69 var testFunc = window[testButton.id];
70 var cmds = [];
71 const COMMAND_DELAY = 500;
72
73 function queueNextCommand() {
74 if (cmds.length)
75 window.setTimeout(nextCommand, COMMAND_DELAY);
76 else {
77 $(testButton).removeClass("running");
78 }
79 }
80
81 function nextCommand() {
82 var cmd = cmds.shift();
83 cmd();
84 queueNextCommand();
85 }
86
87 $(testButton).addClass("running");
88
89 resetDashboard(
90 function(method, args) {
91 switch (method) {
92 case "blackBox.onDashboardLoaded":
93 var dashboard = args[0];
94 var options = args[1];
95 cmds = testFunc(options.jQuery);
96 break;
97 case "blackBox.afterInit":
98 queueNextCommand();
99 break;
100 }
101 });
102 });
103
104 resetDashboard(function() {});
105 }
106
65 $(window).ready( 107 $(window).ready(
66 function() { 108 function() {
67 $(".test-button").click( 109 if (!('JSON' in window))
68 function() { 110 Require.preload(document, ["js/json2.js"], initialize);
69 var testButton = this; 111 else
70 var testFunc = window[testButton.id]; 112 initialize();
71 var cmds = [];
72 const COMMAND_DELAY = 500;
73
74 function queueNextCommand() {
75 if (cmds.length)
76 window.setTimeout(nextCommand, COMMAND_DELAY);
77 else {
78 $(testButton).removeClass("running");
79 }
80 }
81
82 function nextCommand() {
83 var cmd = cmds.shift();
84 cmd();
85 queueNextCommand();
86 }
87
88 $(testButton).addClass("running");
89
90 resetDashboard(
91 function(method, args) {
92 switch (method) {
93 case "blackBox.onDashboardLoaded":
94 var dashboard = args[0];
95 var options = args[1];
96 cmds = testFunc(options.jQuery);
97 break;
98 case "blackBox.afterInit":
99 queueNextCommand();
100 break;
101 }
102 });
103 });
104 resetDashboard(function() {});
105 }); 113 });