nickjillings@1596
|
1 /**
|
nickjillings@1596
|
2 * core.js
|
nickjillings@1596
|
3 *
|
nickjillings@1596
|
4 * Main script to run, calls all other core functions and manages loading/store to backend.
|
nickjillings@1596
|
5 * Also contains all global variables.
|
nickjillings@1596
|
6 */
|
nickjillings@1596
|
7
|
nickjillings@1596
|
8 /* create the web audio API context and store in audioContext*/
|
nickjillings@1596
|
9 var audioContext; // Hold the browser web audio API
|
nickjillings@1596
|
10 var projectXML; // Hold the parsed setup XML
|
nickjillings@1596
|
11 var popup; // Hold the interfacePopup object
|
nickjillings@1596
|
12 var testState;
|
nickjillings@1596
|
13 var currentState; // Keep track of the current state (pre/post test, which test, final test? first test?)
|
nickjillings@1596
|
14 //var testXMLSetups = []; // Hold the parsed test instances
|
nickjillings@1596
|
15 //var testResultsHolders =[]; // Hold the results from each test for publishing to XML
|
nickjillings@1596
|
16 var currentTrackOrder = []; // Hold the current XML tracks in their (randomised) order
|
nickjillings@1596
|
17 //var currentTestHolder; // Hold any intermediate results during test - metrics
|
nickjillings@1596
|
18 var audioEngineContext; // The custome AudioEngine object
|
nickjillings@1596
|
19 var projectReturn; // Hold the URL for the return
|
nickjillings@1596
|
20 //var preTestQuestions = document.createElement('PreTest'); // Store any pre-test question response
|
nickjillings@1596
|
21 //var postTestQuestions = document.createElement('PostTest'); // Store any post-test question response
|
nickjillings@1596
|
22
|
nickjillings@1596
|
23 // Add a prototype to the bufferSourceNode to reference to the audioObject holding it
|
nickjillings@1596
|
24 AudioBufferSourceNode.prototype.owner = undefined;
|
nickjillings@1596
|
25
|
nickjillings@1596
|
26 window.onload = function() {
|
nickjillings@1596
|
27 // Function called once the browser has loaded all files.
|
nickjillings@1596
|
28 // This should perform any initial commands such as structure / loading documents
|
nickjillings@1596
|
29
|
nickjillings@1596
|
30 // Create a web audio API context
|
nickjillings@1596
|
31 // Fixed for cross-browser support
|
nickjillings@1596
|
32 var AudioContext = window.AudioContext || window.webkitAudioContext;
|
nickjillings@1596
|
33 audioContext = new AudioContext;
|
nickjillings@1596
|
34
|
nickjillings@1596
|
35 // Create test state
|
nickjillings@1596
|
36 testState = new stateMachine();
|
nickjillings@1596
|
37
|
nickjillings@1596
|
38 // Create the audio engine object
|
nickjillings@1596
|
39 audioEngineContext = new AudioEngine();
|
nickjillings@1596
|
40
|
nickjillings@1596
|
41 // Create the popup interface object
|
nickjillings@1596
|
42 popup = new interfacePopup();
|
nickjillings@1596
|
43 };
|
nickjillings@1596
|
44
|
nickjillings@1596
|
45 function interfacePopup() {
|
nickjillings@1596
|
46 // Creates an object to manage the popup
|
nickjillings@1596
|
47 this.popup = null;
|
nickjillings@1596
|
48 this.popupContent = null;
|
nickjillings@1596
|
49 this.popupButton = null;
|
nickjillings@1596
|
50 this.popupOptions = null;
|
nickjillings@1596
|
51 this.currentIndex = null;
|
nickjillings@1596
|
52 this.responses = null;
|
nickjillings@1596
|
53 this.createPopup = function(){
|
nickjillings@1596
|
54 // Create popup window interface
|
nickjillings@1596
|
55 var insertPoint = document.getElementById("topLevelBody");
|
nickjillings@1596
|
56 var blank = document.createElement('div');
|
nickjillings@1596
|
57 blank.className = 'testHalt';
|
nickjillings@1596
|
58
|
nickjillings@1596
|
59 this.popup = document.createElement('div');
|
nickjillings@1596
|
60 this.popup.id = 'popupHolder';
|
nickjillings@1596
|
61 this.popup.className = 'popupHolder';
|
nickjillings@1596
|
62 this.popup.style.position = 'absolute';
|
nickjillings@1596
|
63 this.popup.style.left = (window.innerWidth/2)-250 + 'px';
|
nickjillings@1596
|
64 this.popup.style.top = (window.innerHeight/2)-125 + 'px';
|
nickjillings@1596
|
65
|
nickjillings@1596
|
66 this.popupContent = document.createElement('div');
|
nickjillings@1596
|
67 this.popupContent.id = 'popupContent';
|
nickjillings@1596
|
68 this.popupContent.style.marginTop = '25px';
|
nickjillings@1596
|
69 this.popupContent.align = 'center';
|
nickjillings@1596
|
70 this.popup.appendChild(this.popupContent);
|
nickjillings@1596
|
71
|
nickjillings@1596
|
72 this.popupButton = document.createElement('button');
|
nickjillings@1596
|
73 this.popupButton.className = 'popupButton';
|
nickjillings@1596
|
74 this.popupButton.innerHTML = 'Next';
|
nickjillings@1596
|
75 this.popupButton.onclick = function(){popup.buttonClicked();};
|
nickjillings@1596
|
76 insertPoint.appendChild(this.popup);
|
nickjillings@1596
|
77 insertPoint.appendChild(blank);
|
nickjillings@1596
|
78 };
|
nickjillings@1596
|
79
|
nickjillings@1596
|
80 this.showPopup = function(){
|
nickjillings@1596
|
81 if (this.popup == null || this.popup == undefined) {
|
nickjillings@1596
|
82 this.createPopup();
|
nickjillings@1596
|
83 }
|
nickjillings@1596
|
84 this.popup.style.zIndex = 3;
|
nickjillings@1596
|
85 this.popup.style.visibility = 'visible';
|
nickjillings@1596
|
86 var blank = document.getElementsByClassName('testHalt')[0];
|
nickjillings@1596
|
87 blank.style.zIndex = 2;
|
nickjillings@1596
|
88 blank.style.visibility = 'visible';
|
nickjillings@1596
|
89 };
|
nickjillings@1596
|
90
|
nickjillings@1596
|
91 this.hidePopup = function(){
|
nickjillings@1596
|
92 this.popup.style.zIndex = -1;
|
nickjillings@1596
|
93 this.popup.style.visibility = 'hidden';
|
nickjillings@1596
|
94 var blank = document.getElementsByClassName('testHalt')[0];
|
nickjillings@1596
|
95 blank.style.zIndex = -2;
|
nickjillings@1596
|
96 blank.style.visibility = 'hidden';
|
nickjillings@1596
|
97 };
|
nickjillings@1596
|
98
|
nickjillings@1596
|
99 this.postNode = function() {
|
nickjillings@1596
|
100 // This will take the node from the popupOptions and display it
|
nickjillings@1596
|
101 var node = this.popupOptions[this.currentIndex];
|
nickjillings@1596
|
102 this.popupContent.innerHTML = null;
|
nickjillings@1596
|
103 if (node.nodeName == 'statement') {
|
nickjillings@1596
|
104 var span = document.createElement('span');
|
nickjillings@1596
|
105 span.textContent = node.textContent;
|
nickjillings@1596
|
106 this.popupContent.appendChild(span);
|
nickjillings@1596
|
107 } else if (node.nodeName == 'question') {
|
nickjillings@1596
|
108 var span = document.createElement('span');
|
nickjillings@1596
|
109 span.textContent = node.textContent;
|
nickjillings@1596
|
110 var textArea = document.createElement('textarea');
|
nickjillings@1596
|
111 var br = document.createElement('br');
|
nickjillings@1596
|
112 this.popupContent.appendChild(span);
|
nickjillings@1596
|
113 this.popupContent.appendChild(br);
|
nickjillings@1596
|
114 this.popupContent.appendChild(textArea);
|
nickjillings@1596
|
115 }
|
nickjillings@1596
|
116 this.popupContent.appendChild(this.popupButton);
|
nickjillings@1596
|
117 }
|
nickjillings@1596
|
118
|
nickjillings@1596
|
119 this.initState = function(node) {
|
nickjillings@1596
|
120 //Call this with your preTest and postTest nodes when needed to
|
nickjillings@1596
|
121 // initialise the popup procedure.
|
nickjillings@1596
|
122 this.popupOptions = $(node).children();
|
nickjillings@1596
|
123 if (this.popupOptions.length > 0) {
|
nickjillings@1596
|
124 if (node.nodeName == 'preTest' || node.nodeName == 'PreTest') {
|
nickjillings@1596
|
125 this.responses = document.createElement('PreTest');
|
nickjillings@1596
|
126 } else if (node.nodeName == 'postTest' || node.nodeName == 'PostTest') {
|
nickjillings@1596
|
127 this.responses = document.createElement('PostTest');
|
nickjillings@1596
|
128 } else {
|
nickjillings@1596
|
129 console.log ('WARNING - popup node neither pre or post!');
|
nickjillings@1596
|
130 this.responses = document.createElement('responses');
|
nickjillings@1596
|
131 }
|
nickjillings@1596
|
132 this.currentIndex = 0;
|
nickjillings@1596
|
133 this.showPopup();
|
nickjillings@1596
|
134 this.postNode();
|
nickjillings@1596
|
135 }
|
nickjillings@1596
|
136 }
|
nickjillings@1596
|
137
|
nickjillings@1596
|
138 this.buttonClicked = function() {
|
nickjillings@1596
|
139 // Each time the popup button is clicked!
|
nickjillings@1596
|
140 var node = this.popupOptions[this.currentIndex];
|
nickjillings@1596
|
141 if (node.nodeName == 'question') {
|
nickjillings@1596
|
142 // Must extract the question data
|
nickjillings@1596
|
143 var mandatory = node.attributes['mandatory'];
|
nickjillings@1596
|
144 if (mandatory == undefined) {
|
nickjillings@1596
|
145 mandatory = false;
|
nickjillings@1596
|
146 } else {
|
nickjillings@1596
|
147 if (mandatory.value == 'true'){mandatory = true;}
|
nickjillings@1596
|
148 else {mandatory = false;}
|
nickjillings@1596
|
149 }
|
nickjillings@1596
|
150 var textArea = $(popup.popupContent).find('textarea')[0];
|
nickjillings@1596
|
151 if (mandatory == true && textArea.value.length == 0) {
|
nickjillings@1596
|
152 alert('This question is mandatory');
|
nickjillings@1596
|
153 return;
|
nickjillings@1596
|
154 } else {
|
nickjillings@1596
|
155 // Save the text content
|
nickjillings@1596
|
156 var hold = document.createElement('comment');
|
nickjillings@1596
|
157 hold.id = node.attributes['id'].value;
|
nickjillings@1596
|
158 hold.innerHTML = textArea.value;
|
nickjillings@1596
|
159 console.log("Question: "+ node.textContent);
|
nickjillings@1596
|
160 console.log("Question Response: "+ textArea.value);
|
nickjillings@1596
|
161 this.responses.appendChild(hold);
|
nickjillings@1596
|
162 }
|
nickjillings@1596
|
163 }
|
nickjillings@1596
|
164 this.currentIndex++;
|
nickjillings@1596
|
165 if (this.currentIndex < this.popupOptions.length) {
|
nickjillings@1596
|
166 this.postNode();
|
nickjillings@1596
|
167 } else {
|
nickjillings@1596
|
168 // Reached the end of the popupOptions
|
nickjillings@1596
|
169 this.hidePopup();
|
nickjillings@1596
|
170 if (this.responses.nodeName == testState.stateResults[testState.stateIndex].nodeName) {
|
nickjillings@1596
|
171 testState.stateResults[testState.stateIndex] = this.responses;
|
nickjillings@1596
|
172 } else {
|
nickjillings@1596
|
173 testState.stateResults[testState.stateIndex].appendChild(this.responses);
|
nickjillings@1596
|
174 }
|
nickjillings@1596
|
175 advanceState();
|
nickjillings@1596
|
176 }
|
nickjillings@1596
|
177 }
|
nickjillings@1596
|
178 }
|
nickjillings@1596
|
179
|
nickjillings@1596
|
180 function advanceState()
|
nickjillings@1596
|
181 {
|
nickjillings@1596
|
182 // Just for complete clarity
|
nickjillings@1596
|
183 testState.advanceState();
|
nickjillings@1596
|
184 }
|
nickjillings@1596
|
185
|
nickjillings@1596
|
186 function stateMachine()
|
nickjillings@1596
|
187 {
|
nickjillings@1596
|
188 // Object prototype for tracking and managing the test state
|
nickjillings@1596
|
189 this.stateMap = [];
|
nickjillings@1596
|
190 this.stateIndex = null;
|
nickjillings@1596
|
191 this.currentStateMap = [];
|
nickjillings@1596
|
192 this.currentIndex = null;
|
nickjillings@1596
|
193 this.currentTestId = 0;
|
nickjillings@1596
|
194 this.stateResults = [];
|
nickjillings@1596
|
195 this.timerCallBackHolders = null;
|
nickjillings@1596
|
196 this.initialise = function(){
|
nickjillings@1596
|
197 if (this.stateMap.length > 0) {
|
nickjillings@1596
|
198 if(this.stateIndex != null) {
|
nickjillings@1596
|
199 console.log('NOTE - State already initialise');
|
nickjillings@1596
|
200 }
|
nickjillings@1596
|
201 this.stateIndex = -1;
|
nickjillings@1596
|
202 var that = this;
|
nickjillings@1596
|
203 for (var id=0; id<this.stateMap.length; id++){
|
nickjillings@1596
|
204 var name = this.stateMap[id].nodeName;
|
nickjillings@1596
|
205 var obj = document.createElement(name);
|
nickjillings@1600
|
206 if (name == "audioHolder") {
|
nickjillings@1600
|
207 obj.id = this.stateMap[id].id;
|
nickjillings@1600
|
208 }
|
nickjillings@1596
|
209 this.stateResults.push(obj);
|
nickjillings@1596
|
210 }
|
nickjillings@1596
|
211 } else {
|
nickjillings@1596
|
212 conolse.log('FATAL - StateMap not correctly constructed. EMPTY_STATE_MAP');
|
nickjillings@1596
|
213 }
|
nickjillings@1596
|
214 };
|
nickjillings@1596
|
215 this.advanceState = function(){
|
nickjillings@1596
|
216 if (this.stateIndex == null) {
|
nickjillings@1596
|
217 this.initialise();
|
nickjillings@1596
|
218 }
|
nickjillings@1596
|
219 if (this.stateIndex == -1) {
|
nickjillings@1596
|
220 console.log('Starting test...');
|
nickjillings@1596
|
221 }
|
nickjillings@1596
|
222 if (this.currentIndex == null){
|
nickjillings@1596
|
223 if (this.currentStateMap.nodeName == "audioHolder") {
|
nickjillings@1596
|
224 // Save current page
|
nickjillings@1596
|
225 this.testPageCompleted(this.stateResults[this.stateIndex],this.currentStateMap,this.currentTestId);
|
nickjillings@1596
|
226 this.currentTestId++;
|
nickjillings@1596
|
227 }
|
nickjillings@1596
|
228 this.stateIndex++;
|
nickjillings@1596
|
229 if (this.stateIndex >= this.stateMap.length) {
|
nickjillings@1596
|
230 console.log('Test Completed');
|
nickjillings@1596
|
231 createProjectSave(projectReturn);
|
nickjillings@1596
|
232 } else {
|
nickjillings@1596
|
233 this.currentStateMap = this.stateMap[this.stateIndex];
|
nickjillings@1596
|
234 if (this.currentStateMap.nodeName == "audioHolder") {
|
nickjillings@1596
|
235 console.log('Loading test page');
|
nickjillings@1596
|
236 loadTest(this.currentStateMap);
|
nickjillings@1596
|
237 this.initialiseInnerState(this.currentStateMap);
|
nickjillings@1596
|
238 } else if (this.currentStateMap.nodeName == "PreTest" || this.currentStateMap.nodeName == "PostTest") {
|
nickjillings@1596
|
239 if (this.currentStateMap.childElementCount >= 1) {
|
nickjillings@1596
|
240 popup.initState(this.currentStateMap);
|
nickjillings@1596
|
241 } else {
|
nickjillings@1596
|
242 this.advanceState();
|
nickjillings@1596
|
243 }
|
nickjillings@1596
|
244 } else {
|
nickjillings@1596
|
245 this.advanceState();
|
nickjillings@1596
|
246 }
|
nickjillings@1596
|
247 }
|
nickjillings@1596
|
248 } else {
|
nickjillings@1596
|
249 this.advanceInnerState();
|
nickjillings@1596
|
250 }
|
nickjillings@1596
|
251 };
|
nickjillings@1596
|
252
|
nickjillings@1596
|
253 this.testPageCompleted = function(store, testXML, testId) {
|
nickjillings@1596
|
254 // Function called each time a test page has been completed
|
nickjillings@1596
|
255 // Can be used to over-rule default behaviour
|
nickjillings@1596
|
256
|
nickjillings@1596
|
257 pageXMLSave(store, testXML, testId);
|
nickjillings@1596
|
258 }
|
nickjillings@1596
|
259
|
nickjillings@1596
|
260 this.initialiseInnerState = function(testXML) {
|
nickjillings@1596
|
261 // Parses the received testXML for pre and post test options
|
nickjillings@1596
|
262 this.currentStateMap = [];
|
nickjillings@1596
|
263 var preTest = $(testXML).find('PreTest')[0];
|
nickjillings@1596
|
264 var postTest = $(testXML).find('PostTest')[0];
|
nickjillings@1596
|
265 if (preTest == undefined) {preTest = document.createElement("preTest");}
|
nickjillings@1596
|
266 if (postTest == undefined){postTest= document.createElement("postTest");}
|
nickjillings@1596
|
267 this.currentStateMap.push(preTest);
|
nickjillings@1596
|
268 this.currentStateMap.push(testXML);
|
nickjillings@1596
|
269 this.currentStateMap.push(postTest);
|
nickjillings@1596
|
270 this.currentIndex = -1;
|
nickjillings@1596
|
271 this.advanceInnerState();
|
nickjillings@1596
|
272 }
|
nickjillings@1596
|
273
|
nickjillings@1596
|
274 this.advanceInnerState = function() {
|
nickjillings@1596
|
275 this.currentIndex++;
|
nickjillings@1596
|
276 if (this.currentIndex >= this.currentStateMap.length) {
|
nickjillings@1596
|
277 this.currentIndex = null;
|
nickjillings@1596
|
278 this.currentStateMap = this.stateMap[this.stateIndex];
|
nickjillings@1596
|
279 this.advanceState();
|
nickjillings@1596
|
280 } else {
|
nickjillings@1596
|
281 if (this.currentStateMap[this.currentIndex].nodeName == "audioHolder") {
|
nickjillings@1596
|
282 console.log("Loading test page"+this.currentTestId);
|
nickjillings@1596
|
283 } else if (this.currentStateMap[this.currentIndex].nodeName == "PreTest") {
|
nickjillings@1596
|
284 popup.initState(this.currentStateMap[this.currentIndex]);
|
nickjillings@1596
|
285 } else if (this.currentStateMap[this.currentIndex].nodeName == "PostTest") {
|
nickjillings@1596
|
286 popup.initState(this.currentStateMap[this.currentIndex]);
|
nickjillings@1596
|
287 } else {
|
nickjillings@1596
|
288 this.advanceInnerState();
|
nickjillings@1596
|
289 }
|
nickjillings@1596
|
290 }
|
nickjillings@1596
|
291 }
|
nickjillings@1596
|
292
|
nickjillings@1596
|
293 this.previousState = function(){};
|
nickjillings@1596
|
294 }
|
nickjillings@1596
|
295
|
nickjillings@1596
|
296 function testEnded(testId)
|
nickjillings@1596
|
297 {
|
nickjillings@1596
|
298 pageXMLSave(testId);
|
nickjillings@1596
|
299 if (testXMLSetups.length-1 > testId)
|
nickjillings@1596
|
300 {
|
nickjillings@1596
|
301 // Yes we have another test to perform
|
nickjillings@1596
|
302 testId = (Number(testId)+1);
|
nickjillings@1596
|
303 currentState = 'testRun-'+testId;
|
nickjillings@1596
|
304 loadTest(testId);
|
nickjillings@1596
|
305 } else {
|
nickjillings@1596
|
306 console.log('Testing Completed!');
|
nickjillings@1596
|
307 currentState = 'postTest';
|
nickjillings@1596
|
308 // Check for any post tests
|
nickjillings@1596
|
309 var xmlSetup = projectXML.find('setup');
|
nickjillings@1596
|
310 var postTest = xmlSetup.find('PostTest')[0];
|
nickjillings@1596
|
311 popup.initState(postTest);
|
nickjillings@1596
|
312 }
|
nickjillings@1596
|
313 }
|
nickjillings@1596
|
314
|
nickjillings@1596
|
315 function loadProjectSpec(url) {
|
nickjillings@1596
|
316 // Load the project document from the given URL, decode the XML and instruct audioEngine to get audio data
|
nickjillings@1596
|
317 // If url is null, request client to upload project XML document
|
nickjillings@1596
|
318 var r = new XMLHttpRequest();
|
nickjillings@1596
|
319 r.open('GET',url,true);
|
nickjillings@1596
|
320 r.onload = function() {
|
nickjillings@1596
|
321 loadProjectSpecCallback(r.response);
|
nickjillings@1596
|
322 };
|
nickjillings@1596
|
323 r.send();
|
nickjillings@1596
|
324 };
|
nickjillings@1596
|
325
|
nickjillings@1596
|
326 function loadProjectSpecCallback(response) {
|
nickjillings@1596
|
327 // Function called after asynchronous download of XML project specification
|
nickjillings@1596
|
328 var decode = $.parseXML(response);
|
nickjillings@1596
|
329 projectXML = $(decode);
|
nickjillings@1596
|
330
|
nickjillings@1596
|
331 // Now extract the setup tag
|
nickjillings@1596
|
332 var xmlSetup = projectXML.find('setup');
|
nickjillings@1596
|
333 // Detect the interface to use and load the relevant javascripts.
|
nickjillings@1596
|
334 var interfaceType = xmlSetup[0].attributes['interface'];
|
nickjillings@1596
|
335 var interfaceJS = document.createElement('script');
|
nickjillings@1596
|
336 interfaceJS.setAttribute("type","text/javascript");
|
nickjillings@1596
|
337 if (interfaceType.value == 'APE') {
|
nickjillings@1596
|
338 interfaceJS.setAttribute("src","ape.js");
|
nickjillings@1596
|
339
|
nickjillings@1596
|
340 // APE comes with a css file
|
nickjillings@1596
|
341 var css = document.createElement('link');
|
nickjillings@1596
|
342 css.rel = 'stylesheet';
|
nickjillings@1596
|
343 css.type = 'text/css';
|
nickjillings@1596
|
344 css.href = 'ape.css';
|
nickjillings@1596
|
345
|
nickjillings@1596
|
346 document.getElementsByTagName("head")[0].appendChild(css);
|
nickjillings@1596
|
347 }
|
nickjillings@1596
|
348 document.getElementsByTagName("head")[0].appendChild(interfaceJS);
|
nickjillings@1596
|
349
|
nickjillings@1596
|
350 // Define window callbacks for interface
|
nickjillings@1596
|
351 window.onresize = function(event){resizeWindow(event);};
|
nickjillings@1596
|
352 }
|
nickjillings@1596
|
353
|
nickjillings@1596
|
354 function createProjectSave(destURL) {
|
nickjillings@1596
|
355 // Save the data from interface into XML and send to destURL
|
nickjillings@1596
|
356 // If destURL is null then download XML in client
|
nickjillings@1596
|
357 // Now time to render file locally
|
nickjillings@1596
|
358 var xmlDoc = interfaceXMLSave();
|
nickjillings@1596
|
359 var parent = document.createElement("div");
|
nickjillings@1596
|
360 parent.appendChild(xmlDoc);
|
nickjillings@1596
|
361 var file = [parent.innerHTML];
|
nickjillings@1596
|
362 if (destURL == "null" || destURL == undefined) {
|
nickjillings@1596
|
363 var bb = new Blob(file,{type : 'application/xml'});
|
nickjillings@1596
|
364 var dnlk = window.URL.createObjectURL(bb);
|
nickjillings@1596
|
365 var a = document.createElement("a");
|
nickjillings@1596
|
366 a.hidden = '';
|
nickjillings@1596
|
367 a.href = dnlk;
|
nickjillings@1596
|
368 a.download = "save.xml";
|
nickjillings@1596
|
369 a.textContent = "Save File";
|
nickjillings@1596
|
370
|
nickjillings@1596
|
371 var submitDiv = document.getElementById('download-point');
|
nickjillings@1596
|
372 submitDiv.appendChild(a);
|
nickjillings@1596
|
373 popup.showPopup();
|
nickjillings@1596
|
374 popup.popupContent.innerHTML = null;
|
nickjillings@1596
|
375 popup.popupContent.appendChild(submitDiv)
|
nickjillings@1596
|
376 } else {
|
nickjillings@1596
|
377 var xmlhttp = new XMLHttpRequest;
|
nickjillings@1596
|
378 xmlhttp.open("POST",destURL,true);
|
nickjillings@1596
|
379 xmlhttp.setRequestHeader('Content-Type', 'text/xml');
|
nickjillings@1596
|
380 xmlhttp.onerror = function(){
|
nickjillings@1596
|
381 console.log('Error saving file to server! Presenting download locally');
|
nickjillings@1596
|
382 createProjectSave(null);
|
nickjillings@1596
|
383 };
|
nickjillings@1596
|
384 xmlhttp.send(file);
|
nickjillings@1596
|
385 }
|
nickjillings@1596
|
386 return submitDiv;
|
nickjillings@1596
|
387 }
|
nickjillings@1596
|
388
|
nickjillings@1596
|
389 // Only other global function which must be defined in the interface class. Determines how to create the XML document.
|
nickjillings@1596
|
390 function interfaceXMLSave(){
|
nickjillings@1596
|
391 // Create the XML string to be exported with results
|
nickjillings@1596
|
392 var xmlDoc = document.createElement("BrowserEvaluationResult");
|
nickjillings@1596
|
393 xmlDoc.appendChild(returnDateNode());
|
nickjillings@1596
|
394 for (var i=0; i<testState.stateResults.length; i++)
|
nickjillings@1596
|
395 {
|
nickjillings@1596
|
396 xmlDoc.appendChild(testState.stateResults[i]);
|
nickjillings@1596
|
397 }
|
nickjillings@1596
|
398
|
nickjillings@1596
|
399 return xmlDoc;
|
nickjillings@1596
|
400 }
|
nickjillings@1596
|
401
|
nickjillings@1596
|
402 function AudioEngine() {
|
nickjillings@1596
|
403
|
nickjillings@1596
|
404 // Create two output paths, the main outputGain and fooGain.
|
nickjillings@1596
|
405 // Output gain is default to 1 and any items for playback route here
|
nickjillings@1596
|
406 // Foo gain is used for analysis to ensure paths get processed, but are not heard
|
nickjillings@1596
|
407 // because web audio will optimise and any route which does not go to the destination gets ignored.
|
nickjillings@1596
|
408 this.outputGain = audioContext.createGain();
|
nickjillings@1596
|
409 this.fooGain = audioContext.createGain();
|
nickjillings@1596
|
410 this.fooGain.gain = 0;
|
nickjillings@1596
|
411
|
nickjillings@1596
|
412 // Use this to detect playback state: 0 - stopped, 1 - playing
|
nickjillings@1596
|
413 this.status = 0;
|
nickjillings@1596
|
414 this.audioObjectsReady = false;
|
nickjillings@1596
|
415
|
nickjillings@1596
|
416 // Connect both gains to output
|
nickjillings@1596
|
417 this.outputGain.connect(audioContext.destination);
|
nickjillings@1596
|
418 this.fooGain.connect(audioContext.destination);
|
nickjillings@1596
|
419
|
nickjillings@1596
|
420 // Create the timer Object
|
nickjillings@1596
|
421 this.timer = new timer();
|
nickjillings@1596
|
422 // Create session metrics
|
nickjillings@1596
|
423 this.metric = new sessionMetrics(this);
|
nickjillings@1596
|
424
|
nickjillings@1596
|
425 this.loopPlayback = false;
|
nickjillings@1596
|
426
|
nickjillings@1596
|
427 // Create store for new audioObjects
|
nickjillings@1596
|
428 this.audioObjects = [];
|
nickjillings@1596
|
429
|
nickjillings@1596
|
430 this.play = function() {
|
nickjillings@1596
|
431 // Start the timer and set the audioEngine state to playing (1)
|
nickjillings@1596
|
432 if (this.status == 0) {
|
nickjillings@1596
|
433 // Check if all audioObjects are ready
|
nickjillings@1596
|
434 if (this.audioObjectsReady == false) {
|
nickjillings@1596
|
435 this.audioObjectsReady = this.checkAllReady();
|
nickjillings@1596
|
436 }
|
nickjillings@1596
|
437 if (this.audioObjectsReady == true) {
|
nickjillings@1596
|
438 this.timer.startTest();
|
nickjillings@1596
|
439 if (this.loopPlayback) {
|
nickjillings@1596
|
440 for(var i=0; i<this.audioObjects.length; i++) {
|
nickjillings@1596
|
441 this.audioObjects[i].play(this.timer.getTestTime()+1);
|
nickjillings@1596
|
442 }
|
nickjillings@1596
|
443 }
|
nickjillings@1596
|
444 this.status = 1;
|
nickjillings@1596
|
445 }
|
nickjillings@1596
|
446 }
|
nickjillings@1596
|
447 };
|
nickjillings@1596
|
448
|
nickjillings@1596
|
449 this.stop = function() {
|
nickjillings@1596
|
450 // Send stop and reset command to all playback buffers and set audioEngine state to stopped (1)
|
nickjillings@1596
|
451 if (this.status == 1) {
|
nickjillings@1596
|
452 for (var i=0; i<this.audioObjects.length; i++)
|
nickjillings@1596
|
453 {
|
nickjillings@1596
|
454 this.audioObjects[i].stop();
|
nickjillings@1596
|
455 }
|
nickjillings@1596
|
456 this.status = 0;
|
nickjillings@1596
|
457 }
|
nickjillings@1596
|
458 };
|
nickjillings@1596
|
459
|
nickjillings@1596
|
460
|
nickjillings@1596
|
461 this.newTrack = function(url) {
|
nickjillings@1596
|
462 // Pull data from given URL into new audio buffer
|
nickjillings@1596
|
463 // URLs must either be from the same source OR be setup to 'Access-Control-Allow-Origin'
|
nickjillings@1596
|
464
|
nickjillings@1596
|
465 // Create the audioObject with ID of the new track length;
|
nickjillings@1596
|
466 audioObjectId = this.audioObjects.length;
|
nickjillings@1596
|
467 this.audioObjects[audioObjectId] = new audioObject(audioObjectId);
|
nickjillings@1596
|
468
|
nickjillings@1596
|
469 // AudioObject will get track itself.
|
nickjillings@1596
|
470 this.audioObjects[audioObjectId].constructTrack(url);
|
nickjillings@1596
|
471 };
|
nickjillings@1596
|
472
|
nickjillings@1596
|
473 this.newTestPage = function() {
|
nickjillings@1596
|
474 this.state = 0;
|
nickjillings@1596
|
475 this.audioObjectsReady = false;
|
nickjillings@1596
|
476 this.metric.reset();
|
nickjillings@1596
|
477 this.audioObjects = [];
|
nickjillings@1596
|
478 };
|
nickjillings@1596
|
479
|
nickjillings@1596
|
480 this.checkAllPlayed = function() {
|
nickjillings@1596
|
481 arr = [];
|
nickjillings@1596
|
482 for (var id=0; id<this.audioObjects.length; id++) {
|
nickjillings@1596
|
483 if (this.audioObjects[id].metric.wasListenedTo == false) {
|
nickjillings@1596
|
484 arr.push(this.audioObjects[id].id);
|
nickjillings@1596
|
485 }
|
nickjillings@1596
|
486 }
|
nickjillings@1596
|
487 return arr;
|
nickjillings@1596
|
488 };
|
nickjillings@1596
|
489
|
nickjillings@1596
|
490 this.checkAllReady = function() {
|
nickjillings@1596
|
491 var ready = true;
|
nickjillings@1596
|
492 for (var i=0; i<this.audioObjects.length; i++) {
|
nickjillings@1596
|
493 if (this.audioObjects[i].state == 0) {
|
nickjillings@1596
|
494 // Track not ready
|
nickjillings@1596
|
495 console.log('WAIT -- audioObject '+i+' not ready yet!');
|
nickjillings@1596
|
496 ready = false;
|
nickjillings@1596
|
497 };
|
nickjillings@1596
|
498 }
|
nickjillings@1596
|
499 if (ready == false) {
|
nickjillings@1596
|
500 var holder = document.getElementById('testWaitIndicator');
|
nickjillings@1596
|
501 holder.style.visibility = "visible";
|
nickjillings@1596
|
502 setInterval(function() {
|
nickjillings@1596
|
503 document.getElementById('testWaitIndicator').style.visibility = "hidden";
|
nickjillings@1596
|
504 }, 10000);
|
nickjillings@1596
|
505 }
|
nickjillings@1596
|
506 return ready;
|
nickjillings@1596
|
507 };
|
nickjillings@1596
|
508
|
nickjillings@1596
|
509 }
|
nickjillings@1596
|
510
|
nickjillings@1596
|
511 function audioObject(id) {
|
nickjillings@1596
|
512 // The main buffer object with common control nodes to the AudioEngine
|
nickjillings@1596
|
513
|
nickjillings@1596
|
514 this.id = id;
|
nickjillings@1596
|
515 this.state = 0; // 0 - no data, 1 - ready
|
nickjillings@1596
|
516 this.url = null; // Hold the URL given for the output back to the results.
|
nickjillings@1596
|
517 this.metric = new metricTracker(this);
|
nickjillings@1596
|
518
|
nickjillings@1596
|
519 // Create a buffer and external gain control to allow internal patching of effects and volume leveling.
|
nickjillings@1596
|
520 this.bufferNode = undefined;
|
nickjillings@1596
|
521 this.outputGain = audioContext.createGain();
|
nickjillings@1596
|
522
|
nickjillings@1596
|
523 // Default output gain to be zero
|
nickjillings@1596
|
524 this.outputGain.gain.value = 0.0;
|
nickjillings@1596
|
525
|
nickjillings@1596
|
526 // Connect buffer to the audio graph
|
nickjillings@1596
|
527 this.outputGain.connect(audioEngineContext.outputGain);
|
nickjillings@1596
|
528
|
nickjillings@1596
|
529 // the audiobuffer is not designed for multi-start playback
|
nickjillings@1596
|
530 // When stopeed, the buffer node is deleted and recreated with the stored buffer.
|
nickjillings@1596
|
531 this.buffer;
|
nickjillings@1596
|
532
|
nickjillings@1596
|
533 this.loopStart = function() {
|
nickjillings@1596
|
534 this.outputGain.gain.value = 1.0;
|
nickjillings@1596
|
535 this.metric.startListening(audioEngineContext.timer.getTestTime());
|
nickjillings@1596
|
536 }
|
nickjillings@1596
|
537
|
nickjillings@1596
|
538 this.loopStop = function() {
|
nickjillings@1596
|
539 if (this.outputGain.gain.value != 0.0) {
|
nickjillings@1596
|
540 this.outputGain.gain.value = 0.0;
|
nickjillings@1596
|
541 this.metric.stopListening(audioEngineContext.timer.getTestTime());
|
nickjillings@1596
|
542 }
|
nickjillings@1596
|
543 }
|
nickjillings@1596
|
544
|
nickjillings@1596
|
545 this.play = function(startTime) {
|
nickjillings@1596
|
546 this.bufferNode = audioContext.createBufferSource();
|
nickjillings@1596
|
547 this.bufferNode.owner = this;
|
nickjillings@1596
|
548 this.bufferNode.connect(this.outputGain);
|
nickjillings@1596
|
549 this.bufferNode.buffer = this.buffer;
|
nickjillings@1596
|
550 this.bufferNode.loop = audioEngineContext.loopPlayback;
|
nickjillings@1596
|
551 this.bufferNode.onended = function() {
|
nickjillings@1596
|
552 // Safari does not like using 'this' to reference the calling object!
|
nickjillings@1596
|
553 event.srcElement.owner.metric.stopListening(audioEngineContext.timer.getTestTime());
|
nickjillings@1596
|
554 };
|
nickjillings@1596
|
555 if (this.bufferNode.loop == false) {
|
nickjillings@1596
|
556 this.metric.startListening(audioEngineContext.timer.getTestTime());
|
nickjillings@1596
|
557 }
|
nickjillings@1596
|
558 this.bufferNode.start(startTime);
|
nickjillings@1596
|
559 };
|
nickjillings@1596
|
560
|
nickjillings@1596
|
561 this.stop = function() {
|
nickjillings@1596
|
562 if (this.bufferNode != undefined)
|
nickjillings@1596
|
563 {
|
nickjillings@1596
|
564 this.bufferNode.stop(0);
|
nickjillings@1596
|
565 this.bufferNode = undefined;
|
nickjillings@1596
|
566 this.metric.stopListening(audioEngineContext.timer.getTestTime());
|
nickjillings@1596
|
567 }
|
nickjillings@1596
|
568 };
|
nickjillings@1596
|
569
|
nickjillings@1596
|
570 this.constructTrack = function(url) {
|
nickjillings@1596
|
571 var request = new XMLHttpRequest();
|
nickjillings@1596
|
572 this.url = url;
|
nickjillings@1596
|
573 request.open('GET',url,true);
|
nickjillings@1596
|
574 request.responseType = 'arraybuffer';
|
nickjillings@1596
|
575
|
nickjillings@1596
|
576 var audioObj = this;
|
nickjillings@1596
|
577
|
nickjillings@1596
|
578 // Create callback to decode the data asynchronously
|
nickjillings@1596
|
579 request.onloadend = function() {
|
nickjillings@1596
|
580 audioContext.decodeAudioData(request.response, function(decodedData) {
|
nickjillings@1596
|
581 audioObj.buffer = decodedData;
|
nickjillings@1596
|
582 audioObj.state = 1;
|
nickjillings@1596
|
583 }, function(){
|
nickjillings@1596
|
584 // Should only be called if there was an error, but sometimes gets called continuously
|
nickjillings@1596
|
585 // Check here if the error is genuine
|
nickjillings@1596
|
586 if (audioObj.state == 0 || audioObj.buffer == undefined) {
|
nickjillings@1596
|
587 // Genuine error
|
nickjillings@1596
|
588 console.log('FATAL - Error loading buffer on '+audioObj.id);
|
nickjillings@1596
|
589 }
|
nickjillings@1596
|
590 });
|
nickjillings@1596
|
591 };
|
nickjillings@1596
|
592 request.send();
|
nickjillings@1596
|
593 };
|
nickjillings@1596
|
594
|
nickjillings@1596
|
595 }
|
nickjillings@1596
|
596
|
nickjillings@1596
|
597 function timer()
|
nickjillings@1596
|
598 {
|
nickjillings@1596
|
599 /* Timer object used in audioEngine to keep track of session timings
|
nickjillings@1596
|
600 * Uses the timer of the web audio API, so sample resolution
|
nickjillings@1596
|
601 */
|
nickjillings@1596
|
602 this.testStarted = false;
|
nickjillings@1596
|
603 this.testStartTime = 0;
|
nickjillings@1596
|
604 this.testDuration = 0;
|
nickjillings@1596
|
605 this.minimumTestTime = 0; // No minimum test time
|
nickjillings@1596
|
606 this.startTest = function()
|
nickjillings@1596
|
607 {
|
nickjillings@1596
|
608 if (this.testStarted == false)
|
nickjillings@1596
|
609 {
|
nickjillings@1596
|
610 this.testStartTime = audioContext.currentTime;
|
nickjillings@1596
|
611 this.testStarted = true;
|
nickjillings@1596
|
612 this.updateTestTime();
|
nickjillings@1596
|
613 audioEngineContext.metric.initialiseTest();
|
nickjillings@1596
|
614 }
|
nickjillings@1596
|
615 };
|
nickjillings@1596
|
616 this.stopTest = function()
|
nickjillings@1596
|
617 {
|
nickjillings@1596
|
618 if (this.testStarted)
|
nickjillings@1596
|
619 {
|
nickjillings@1596
|
620 this.testDuration = this.getTestTime();
|
nickjillings@1596
|
621 this.testStarted = false;
|
nickjillings@1596
|
622 } else {
|
nickjillings@1596
|
623 console.log('ERR: Test tried to end before beginning');
|
nickjillings@1596
|
624 }
|
nickjillings@1596
|
625 };
|
nickjillings@1596
|
626 this.updateTestTime = function()
|
nickjillings@1596
|
627 {
|
nickjillings@1596
|
628 if (this.testStarted)
|
nickjillings@1596
|
629 {
|
nickjillings@1596
|
630 this.testDuration = audioContext.currentTime - this.testStartTime;
|
nickjillings@1596
|
631 }
|
nickjillings@1596
|
632 };
|
nickjillings@1596
|
633 this.getTestTime = function()
|
nickjillings@1596
|
634 {
|
nickjillings@1596
|
635 this.updateTestTime();
|
nickjillings@1596
|
636 return this.testDuration;
|
nickjillings@1596
|
637 };
|
nickjillings@1596
|
638 }
|
nickjillings@1596
|
639
|
nickjillings@1596
|
640 function sessionMetrics(engine)
|
nickjillings@1596
|
641 {
|
nickjillings@1596
|
642 /* Used by audioEngine to link to audioObjects to minimise the timer call timers;
|
nickjillings@1596
|
643 */
|
nickjillings@1596
|
644 this.engine = engine;
|
nickjillings@1596
|
645 this.lastClicked = -1;
|
nickjillings@1596
|
646 this.data = -1;
|
nickjillings@1596
|
647 this.reset = function() {
|
nickjillings@1596
|
648 this.lastClicked = -1;
|
nickjillings@1596
|
649 this.data = -1;
|
nickjillings@1596
|
650 };
|
nickjillings@1596
|
651 this.initialiseTest = function(){};
|
nickjillings@1596
|
652 }
|
nickjillings@1596
|
653
|
nickjillings@1596
|
654 function metricTracker(caller)
|
nickjillings@1596
|
655 {
|
nickjillings@1596
|
656 /* Custom object to track and collect metric data
|
nickjillings@1596
|
657 * Used only inside the audioObjects object.
|
nickjillings@1596
|
658 */
|
nickjillings@1596
|
659
|
nickjillings@1596
|
660 this.listenedTimer = 0;
|
nickjillings@1596
|
661 this.listenStart = 0;
|
nickjillings@1596
|
662 this.listenHold = false;
|
nickjillings@1596
|
663 this.initialPosition = -1;
|
nickjillings@1596
|
664 this.movementTracker = [];
|
nickjillings@1596
|
665 this.wasListenedTo = false;
|
nickjillings@1596
|
666 this.wasMoved = false;
|
nickjillings@1596
|
667 this.hasComments = false;
|
nickjillings@1596
|
668 this.parent = caller;
|
nickjillings@1596
|
669
|
nickjillings@1596
|
670 this.initialised = function(position)
|
nickjillings@1596
|
671 {
|
nickjillings@1596
|
672 if (this.initialPosition == -1) {
|
nickjillings@1596
|
673 this.initialPosition = position;
|
nickjillings@1596
|
674 }
|
nickjillings@1596
|
675 };
|
nickjillings@1596
|
676
|
nickjillings@1596
|
677 this.moved = function(time,position)
|
nickjillings@1596
|
678 {
|
nickjillings@1596
|
679 this.wasMoved = true;
|
nickjillings@1596
|
680 this.movementTracker[this.movementTracker.length] = [time, position];
|
nickjillings@1596
|
681 };
|
nickjillings@1596
|
682
|
nickjillings@1596
|
683 this.startListening = function(time)
|
nickjillings@1596
|
684 {
|
nickjillings@1596
|
685 if (this.listenHold == false)
|
nickjillings@1596
|
686 {
|
nickjillings@1596
|
687 this.wasListenedTo = true;
|
nickjillings@1596
|
688 this.listenStart = time;
|
nickjillings@1596
|
689 this.listenHold = true;
|
nickjillings@1596
|
690 console.log('slider ' + this.parent.id + ' played (' + time + ')'); // DEBUG/SAFETY: show played slider id
|
nickjillings@1596
|
691 }
|
nickjillings@1596
|
692 };
|
nickjillings@1596
|
693
|
nickjillings@1596
|
694 this.stopListening = function(time)
|
nickjillings@1596
|
695 {
|
nickjillings@1596
|
696 if (this.listenHold == true)
|
nickjillings@1596
|
697 {
|
nickjillings@1596
|
698 this.listenedTimer += (time - this.listenStart);
|
nickjillings@1596
|
699 this.listenStart = 0;
|
nickjillings@1596
|
700 this.listenHold = false;
|
nickjillings@1596
|
701 }
|
nickjillings@1596
|
702 };
|
nickjillings@1596
|
703 }
|
nickjillings@1596
|
704
|
nickjillings@1596
|
705 function randomiseOrder(input)
|
nickjillings@1596
|
706 {
|
nickjillings@1596
|
707 // This takes an array of information and randomises the order
|
nickjillings@1596
|
708 var N = input.length;
|
nickjillings@1596
|
709 var K = N;
|
nickjillings@1596
|
710 var holdArr = [];
|
nickjillings@1596
|
711 for (var n=0; n<N; n++)
|
nickjillings@1596
|
712 {
|
nickjillings@1596
|
713 // First pick a random number
|
nickjillings@1596
|
714 var r = Math.random();
|
nickjillings@1596
|
715 // Multiply and floor by the number of elements left
|
nickjillings@1596
|
716 r = Math.floor(r*input.length);
|
nickjillings@1596
|
717 // Pick out that element and delete from the array
|
nickjillings@1596
|
718 holdArr.push(input.splice(r,1)[0]);
|
nickjillings@1596
|
719 }
|
nickjillings@1596
|
720 return holdArr;
|
nickjillings@1596
|
721 }
|
nickjillings@1596
|
722
|
nickjillings@1596
|
723 function returnDateNode()
|
nickjillings@1596
|
724 {
|
nickjillings@1596
|
725 // Create an XML Node for the Date and Time a test was conducted
|
nickjillings@1596
|
726 // Structure is
|
nickjillings@1596
|
727 // <datetime>
|
nickjillings@1596
|
728 // <date year="##" month="##" day="##">DD/MM/YY</date>
|
nickjillings@1596
|
729 // <time hour="##" minute="##" sec="##">HH:MM:SS</time>
|
nickjillings@1596
|
730 // </datetime>
|
nickjillings@1596
|
731 var dateTime = new Date();
|
nickjillings@1596
|
732 var year = document.createAttribute('year');
|
nickjillings@1596
|
733 var month = document.createAttribute('month');
|
nickjillings@1596
|
734 var day = document.createAttribute('day');
|
nickjillings@1596
|
735 var hour = document.createAttribute('hour');
|
nickjillings@1596
|
736 var minute = document.createAttribute('minute');
|
nickjillings@1596
|
737 var secs = document.createAttribute('secs');
|
nickjillings@1596
|
738
|
nickjillings@1596
|
739 year.nodeValue = dateTime.getFullYear();
|
nickjillings@1596
|
740 month.nodeValue = dateTime.getMonth()+1;
|
nickjillings@1596
|
741 day.nodeValue = dateTime.getDate();
|
nickjillings@1596
|
742 hour.nodeValue = dateTime.getHours();
|
nickjillings@1596
|
743 minute.nodeValue = dateTime.getMinutes();
|
nickjillings@1596
|
744 secs.nodeValue = dateTime.getSeconds();
|
nickjillings@1596
|
745
|
nickjillings@1596
|
746 var hold = document.createElement("datetime");
|
nickjillings@1596
|
747 var date = document.createElement("date");
|
nickjillings@1596
|
748 date.textContent = year.nodeValue+'/'+month.nodeValue+'/'+day.nodeValue;
|
nickjillings@1596
|
749 var time = document.createElement("time");
|
nickjillings@1596
|
750 time.textContent = hour.nodeValue+':'+minute.nodeValue+':'+secs.nodeValue;
|
nickjillings@1596
|
751
|
nickjillings@1596
|
752 date.setAttributeNode(year);
|
nickjillings@1596
|
753 date.setAttributeNode(month);
|
nickjillings@1596
|
754 date.setAttributeNode(day);
|
nickjillings@1596
|
755 time.setAttributeNode(hour);
|
nickjillings@1596
|
756 time.setAttributeNode(minute);
|
nickjillings@1596
|
757 time.setAttributeNode(secs);
|
nickjillings@1596
|
758
|
nickjillings@1596
|
759 hold.appendChild(date);
|
nickjillings@1596
|
760 hold.appendChild(time);
|
nickjillings@1596
|
761 return hold
|
nickjillings@1596
|
762
|
nickjillings@1596
|
763 }
|
nickjillings@1596
|
764
|
nickjillings@1596
|
765 function testWaitIndicator() {
|
nickjillings@1596
|
766 var hold = document.createElement("div");
|
nickjillings@1596
|
767 hold.id = "testWaitIndicator";
|
nickjillings@1596
|
768 hold.style.position = "absolute";
|
nickjillings@1596
|
769 hold.style.left = "100px";
|
nickjillings@1596
|
770 hold.style.top = "10px";
|
nickjillings@1596
|
771 hold.style.width = "500px";
|
nickjillings@1596
|
772 hold.style.height = "100px";
|
nickjillings@1596
|
773 hold.style.padding = "20px";
|
nickjillings@1596
|
774 hold.style.backgroundColor = "rgb(100,200,200)";
|
nickjillings@1596
|
775 hold.style.visibility = "hidden";
|
nickjillings@1596
|
776 var span = document.createElement("span");
|
nickjillings@1596
|
777 span.textContent = "Please wait! Elements still loading";
|
nickjillings@1596
|
778 hold.appendChild(span);
|
nickjillings@1596
|
779 var body = document.getElementsByTagName('body')[0];
|
nickjillings@1596
|
780 body.appendChild(hold);
|
nickjillings@1596
|
781 }
|
nickjillings@1596
|
782
|
nickjillings@1596
|
783 var hidetestwait = null;
|