comparison core.js @ 921:533d51508e93

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