Mercurial > hg > webaudioevaluationtool
comparison interfaces/ABX.js @ 1255:dcbf87684e99
ABX Implemented.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Wed, 16 Mar 2016 16:16:05 +0000 |
parents | 8aa21ebd9b15 |
children | fd711d12dd14 |
comparison
equal
deleted
inserted
replaced
1254:6dbb9c24d53e | 1255:dcbf87684e99 |
---|---|
7 loadInterface(); | 7 loadInterface(); |
8 | 8 |
9 function loadInterface() { | 9 function loadInterface() { |
10 // Use this to do any one-time page / element construction. For instance, placing any stationary text objects, | 10 // Use this to do any one-time page / element construction. For instance, placing any stationary text objects, |
11 // holding div's, or setting up any nodes which are present for the entire test sequence | 11 // holding div's, or setting up any nodes which are present for the entire test sequence |
12 | |
13 interfaceContext.insertPoint.innerHTML = null; // Clear the current schema | |
12 | 14 |
13 // Custom comparator Object | 15 // Custom comparator Object |
14 Interface.prototype.comparator = null; | 16 Interface.prototype.comparator = null; |
15 | 17 |
16 // The injection point into the HTML page | 18 // The injection point into the HTML page |
98 }; | 100 }; |
99 | 101 |
100 function loadTest(page) | 102 function loadTest(page) |
101 { | 103 { |
102 // Called each time a new test page is to be build. The page specification node is the only item passed in | 104 // Called each time a new test page is to be build. The page specification node is the only item passed in |
105 document.getElementById('box-holders').innerHTML = null; | |
106 | |
107 var interfaceObj = page.interfaces; | |
108 if (interfaceObj.length > 1) | |
109 { | |
110 console.log("WARNING - This interface only supports one <interface> node per page. Using first interface node"); | |
111 } | |
112 interfaceObj = interfaceObj[0]; | |
113 | |
114 if(interfaceObj.title != null) | |
115 { | |
116 document.getElementById("pageTitle").textContent = interfaceObj.title; | |
117 } | |
118 | |
119 var interfaceOptions = specification.interfaces.options.concat(interfaceObj.options); | |
120 for (var option of interfaceOptions) | |
121 { | |
122 if (option.type == "show") | |
123 { | |
124 switch(option.name) { | |
125 case "playhead": | |
126 var playbackHolder = document.getElementById('playback-holder'); | |
127 if (playbackHolder == null) | |
128 { | |
129 playbackHolder = document.createElement('div'); | |
130 playbackHolder.style.width = "100%"; | |
131 playbackHolder.style.float = "left"; | |
132 playbackHolder.align = 'center'; | |
133 playbackHolder.appendChild(interfaceContext.playhead.object); | |
134 feedbackHolder.appendChild(playbackHolder); | |
135 } | |
136 break; | |
137 case "page-count": | |
138 var pagecountHolder = document.getElementById('page-count'); | |
139 if (pagecountHolder == null) | |
140 { | |
141 pagecountHolder = document.createElement('div'); | |
142 pagecountHolder.id = 'page-count'; | |
143 } | |
144 pagecountHolder.innerHTML = '<span>Page '+(testState.stateIndex+1)+' of '+testState.stateMap.length+'</span>'; | |
145 var inject = document.getElementById('interface-buttons'); | |
146 inject.appendChild(pagecountHolder); | |
147 break; | |
148 case "volume": | |
149 if (document.getElementById('master-volume-holder') == null) | |
150 { | |
151 feedbackHolder.appendChild(interfaceContext.volume.object); | |
152 } | |
153 break; | |
154 } | |
155 } | |
156 } | |
157 | |
103 interfaceContext.comparator = new comparator(page); | 158 interfaceContext.comparator = new comparator(page); |
159 resizeWindow(null); | |
104 } | 160 } |
105 | 161 |
106 function comparator(page) | 162 function comparator(page) |
107 { | 163 { |
108 // Build prototype constructor | 164 // Build prototype constructor |
324 this.boxHolders.appendChild(node.box); | 380 this.boxHolders.appendChild(node.box); |
325 } | 381 } |
326 | 382 |
327 function resizeWindow(event) | 383 function resizeWindow(event) |
328 { | 384 { |
329 // Called on every window resize event, use this to scale your page properly | 385 document.getElementById('submit').style.left = (window.innerWidth-250)/2 + 'px'; |
386 var numObj = 3; | |
387 var boxW = numObj*312; | |
388 var diff = window.innerWidth - boxW; | |
389 while (diff < 0) | |
390 { | |
391 numObj = Math.ceil(numObj/2); | |
392 boxW = numObj*312; | |
393 diff = window.innerWidth - boxW; | |
394 } | |
395 document.getElementById('box-holders').style.marginLeft = diff/2 + 'px'; | |
396 document.getElementById('box-holders').style.marginRight = diff/2 + 'px'; | |
397 document.getElementById('box-holders').style.width = boxW + 'px'; | |
330 } | 398 } |
331 | 399 |
332 function buttonSubmitClick() | 400 function buttonSubmitClick() |
333 { | 401 { |
334 testState.advanceState(); | 402 var checks = []; |
403 checks = checks.concat(testState.currentStateMap.interfaces[0].options); | |
404 checks = checks.concat(specification.interfaces.options); | |
405 var canContinue = true; | |
406 | |
407 for (var i=0; i<checks.length; i++) { | |
408 if (checks[i].type == 'check') | |
409 { | |
410 switch(checks[i].name) { | |
411 case 'fragmentPlayed': | |
412 // Check if all fragments have been played | |
413 var checkState = interfaceContext.checkAllPlayed(); | |
414 if (checkState == false) {canContinue = false;} | |
415 break; | |
416 case 'fragmentFullPlayback': | |
417 // Check all fragments have been played to their full length | |
418 var checkState = interfaceContext.checkFragmentsFullyPlayed(); | |
419 if (checkState == false) {canContinue = false;} | |
420 break; | |
421 case 'fragmentMoved': | |
422 // Check all fragment sliders have been moved. | |
423 var checkState = interfaceContext.checkAllMoved(); | |
424 if (checkState == false) {canContinue = false;} | |
425 break; | |
426 case 'fragmentComments': | |
427 // Check all fragment sliders have been moved. | |
428 var checkState = interfaceContext.checkAllCommented(); | |
429 if (checkState == false) {canContinue = false;} | |
430 break; | |
431 default: | |
432 console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface"); | |
433 break; | |
434 } | |
435 | |
436 } | |
437 if (!canContinue) {break;} | |
438 } | |
439 if (canContinue) | |
440 { | |
441 if (audioEngineContext.status == 1) { | |
442 var playback = document.getElementById('playback-button'); | |
443 playback.click(); | |
444 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options | |
445 } else | |
446 { | |
447 if (audioEngineContext.timer.testStarted == false) | |
448 { | |
449 alert('You have not started the test! Please press start to begin the test!'); | |
450 return; | |
451 } | |
452 } | |
453 testState.advanceState(); | |
454 } | |
335 } | 455 } |
336 | 456 |
337 function pageXMLSave(store, pageSpecification) | 457 function pageXMLSave(store, pageSpecification) |
338 { | 458 { |
339 // MANDATORY | 459 // MANDATORY |