nickjillings@1341
|
1 // Once this is loaded and parsed, begin execution
|
nickjillings@1341
|
2 loadInterface();
|
nickjillings@1341
|
3
|
nickjillings@1341
|
4 function loadInterface() {
|
nickjillings@1341
|
5 // Get the dimensions of the screen available to the page
|
nickjillings@1341
|
6 var width = window.innerWidth;
|
nickjillings@1341
|
7 var height = window.innerHeight;
|
nicholas@2381
|
8 interfaceContext.insertPoint.innerHTML = ""; // Clear the current schema
|
nickjillings@1341
|
9
|
nickjillings@2110
|
10 // Custom comparator Object
|
nickjillings@2110
|
11 Interface.prototype.comparator = null;
|
nicholas@2359
|
12
|
nicholas@2359
|
13 Interface.prototype.checkScaleRange = function(min, max) {
|
nicholas@2359
|
14 var page = testState.getCurrentTestPage();
|
nicholas@2359
|
15 var audioObjects = audioEngineContext.audioObjects;
|
nicholas@2359
|
16 var state = true;
|
nicholas@2359
|
17 var str = "Please keep listening. ";
|
nicholas@2359
|
18 var minRanking = Infinity;
|
nicholas@2359
|
19 var maxRanking = -Infinity;
|
nicholas@2359
|
20 for (var ao of audioObjects) {
|
nicholas@2359
|
21 var rank = ao.interfaceDOM.getValue();
|
nicholas@2359
|
22 if (rank < minRanking) {minRanking = rank;}
|
nicholas@2359
|
23 if (rank > maxRanking) {maxRanking = rank;}
|
nicholas@2359
|
24 }
|
nicholas@2359
|
25 if (maxRanking*100 < max) {
|
nicholas@2359
|
26 str += "At least one fragment must be selected."
|
nicholas@2359
|
27 state = false;
|
nicholas@2359
|
28 }
|
nicholas@2359
|
29 if (!state) {
|
nicholas@2359
|
30 console.log(str);
|
nicholas@2359
|
31 this.storeErrorNode(str);
|
nicholas@2362
|
32 interfaceContext.lightbox.post("Message",str);
|
nicholas@2359
|
33 }
|
nicholas@2359
|
34 return state;
|
nicholas@2359
|
35 }
|
nickjillings@1341
|
36
|
nickjillings@1341
|
37 // The injection point into the HTML page
|
nickjillings@1341
|
38 interfaceContext.insertPoint = document.getElementById("topLevelBody");
|
nickjillings@1341
|
39 var testContent = document.createElement('div');
|
nickjillings@1341
|
40 testContent.id = 'testContent';
|
nickjillings@1341
|
41
|
nickjillings@1341
|
42 // Create the top div for the Title element
|
nickjillings@1341
|
43 var titleAttr = specification.title;
|
nickjillings@1341
|
44 var title = document.createElement('div');
|
nickjillings@1341
|
45 title.className = "title";
|
nickjillings@1341
|
46 title.align = "center";
|
nickjillings@1341
|
47 var titleSpan = document.createElement('span');
|
nickjillings@1341
|
48
|
nickjillings@1341
|
49 // Set title to that defined in XML, else set to default
|
nickjillings@1341
|
50 if (titleAttr != undefined) {
|
nickjillings@1341
|
51 titleSpan.textContent = titleAttr;
|
nickjillings@1341
|
52 } else {
|
nickjillings@1341
|
53 titleSpan.textContent = 'Listening test';
|
nickjillings@1341
|
54 }
|
nickjillings@1341
|
55 // Insert the titleSpan element into the title div element.
|
nickjillings@1341
|
56 title.appendChild(titleSpan);
|
nickjillings@1341
|
57
|
nickjillings@1341
|
58 var pagetitle = document.createElement('div');
|
nickjillings@1341
|
59 pagetitle.className = "pageTitle";
|
nickjillings@1341
|
60 pagetitle.align = "center";
|
nickjillings@1341
|
61 var titleSpan = document.createElement('span');
|
nickjillings@1341
|
62 titleSpan.id = "pageTitle";
|
nickjillings@1341
|
63 pagetitle.appendChild(titleSpan);
|
nickjillings@1341
|
64
|
nickjillings@1341
|
65 // Create Interface buttons!
|
nickjillings@1341
|
66 var interfaceButtons = document.createElement('div');
|
nickjillings@1341
|
67 interfaceButtons.id = 'interface-buttons';
|
nickjillings@1341
|
68 interfaceButtons.style.height = '25px';
|
nickjillings@1341
|
69
|
nickjillings@1341
|
70 // Create playback start/stop points
|
nickjillings@1341
|
71 var playback = document.createElement("button");
|
nickjillings@1341
|
72 playback.innerHTML = 'Stop';
|
nickjillings@1341
|
73 playback.id = 'playback-button';
|
nickjillings@1341
|
74 playback.style.float = 'left';
|
nickjillings@1341
|
75 // onclick function. Check if it is playing or not, call the correct function in the
|
nickjillings@1341
|
76 // audioEngine, change the button text to reflect the next state.
|
nickjillings@1341
|
77 playback.onclick = function() {
|
nickjillings@1341
|
78 if (audioEngineContext.status == 1) {
|
nickjillings@1341
|
79 audioEngineContext.stop();
|
nickjillings@1341
|
80 this.innerHTML = 'Stop';
|
nickjillings@1341
|
81 var time = audioEngineContext.timer.getTestTime();
|
nickjillings@1341
|
82 console.log('Stopped at ' + time); // DEBUG/SAFETY
|
nickjillings@1341
|
83 }
|
nickjillings@1341
|
84 };
|
nickjillings@1341
|
85 // Append the interface buttons into the interfaceButtons object.
|
nickjillings@1341
|
86 interfaceButtons.appendChild(playback);
|
nickjillings@1341
|
87
|
nickjillings@1341
|
88 // Global parent for the comment boxes on the page
|
nickjillings@1341
|
89 var feedbackHolder = document.createElement('div');
|
nickjillings@1341
|
90 feedbackHolder.id = 'feedbackHolder';
|
nickjillings@1341
|
91
|
nickjillings@1341
|
92 // Construct the AB Boxes
|
nickjillings@1341
|
93 var boxes = document.createElement('div');
|
nickjillings@1341
|
94 boxes.align = "center";
|
nickjillings@1341
|
95 boxes.id = "box-holders";
|
nickjillings@1341
|
96 boxes.style.float = "left";
|
nickjillings@1341
|
97
|
nickjillings@1341
|
98 var submit = document.createElement('button');
|
nickjillings@1341
|
99 submit.id = "submit";
|
nickjillings@1341
|
100 submit.onclick = buttonSubmitClick;
|
nickjillings@1341
|
101 submit.className = "big-button";
|
nickjillings@1341
|
102 submit.textContent = "submit";
|
nickjillings@1341
|
103 submit.style.position = "relative";
|
nickjillings@1341
|
104 submit.style.left = (window.innerWidth-250)/2 + 'px';
|
nickjillings@1341
|
105
|
nickjillings@1341
|
106 feedbackHolder.appendChild(boxes);
|
nickjillings@1341
|
107
|
nickjillings@1341
|
108 // Inject into HTML
|
nickjillings@1341
|
109 testContent.appendChild(title); // Insert the title
|
nickjillings@1341
|
110 testContent.appendChild(pagetitle);
|
nickjillings@1341
|
111 testContent.appendChild(interfaceButtons);
|
nickjillings@1341
|
112 testContent.appendChild(feedbackHolder);
|
nickjillings@1341
|
113 testContent.appendChild(submit);
|
nickjillings@1341
|
114 interfaceContext.insertPoint.appendChild(testContent);
|
nickjillings@1341
|
115
|
nickjillings@1341
|
116 // Load the full interface
|
nickjillings@1341
|
117 testState.initialise();
|
nickjillings@1341
|
118 testState.advanceState();
|
nickjillings@1341
|
119 }
|
nickjillings@1341
|
120
|
nickjillings@1341
|
121 function loadTest(audioHolderObject)
|
nickjillings@1341
|
122 {
|
nickjillings@1341
|
123 var feedbackHolder = document.getElementById('feedbackHolder');
|
nickjillings@1341
|
124 var interfaceObj = audioHolderObject.interfaces;
|
nickjillings@1341
|
125 if (interfaceObj.length > 1)
|
nickjillings@1341
|
126 {
|
nickjillings@1341
|
127 console.log("WARNING - This interface only supports one <interface> node per page. Using first interface node");
|
nickjillings@1341
|
128 }
|
nickjillings@1341
|
129 interfaceObj = interfaceObj[0];
|
nickjillings@1341
|
130
|
nickjillings@1341
|
131 if(interfaceObj.title != null)
|
nickjillings@1341
|
132 {
|
nickjillings@1341
|
133 document.getElementById("pageTitle").textContent = interfaceObj.title;
|
nickjillings@1341
|
134 }
|
nickjillings@1356
|
135
|
nickjillings@1356
|
136 var interfaceOptions = specification.interfaces.options.concat(interfaceObj.options);
|
nickjillings@1356
|
137 for (var option of interfaceOptions)
|
nickjillings@1356
|
138 {
|
nickjillings@1356
|
139 if (option.type == "show")
|
nickjillings@1356
|
140 {
|
nickjillings@1356
|
141 switch(option.name) {
|
nickjillings@1356
|
142 case "playhead":
|
nickjillings@1356
|
143 var playbackHolder = document.getElementById('playback-holder');
|
nickjillings@1356
|
144 if (playbackHolder == null)
|
nickjillings@1356
|
145 {
|
nickjillings@1356
|
146 playbackHolder = document.createElement('div');
|
nickjillings@1356
|
147 playbackHolder.style.width = "100%";
|
nickjillings@1356
|
148 playbackHolder.style.float = "left";
|
nickjillings@1356
|
149 playbackHolder.align = 'center';
|
nickjillings@1356
|
150 playbackHolder.appendChild(interfaceContext.playhead.object);
|
nickjillings@1356
|
151 feedbackHolder.appendChild(playbackHolder);
|
nickjillings@1356
|
152 }
|
nickjillings@1356
|
153 break;
|
nickjillings@1356
|
154 case "page-count":
|
nickjillings@1356
|
155 var pagecountHolder = document.getElementById('page-count');
|
nickjillings@1356
|
156 if (pagecountHolder == null)
|
nickjillings@1356
|
157 {
|
nickjillings@1356
|
158 pagecountHolder = document.createElement('div');
|
nickjillings@1356
|
159 pagecountHolder.id = 'page-count';
|
nickjillings@1356
|
160 }
|
nickjillings@2125
|
161 pagecountHolder.innerHTML = '<span>Page '+(testState.stateIndex+1)+' of '+testState.stateMap.length+'</span>';
|
nickjillings@1356
|
162 var inject = document.getElementById('interface-buttons');
|
nickjillings@1356
|
163 inject.appendChild(pagecountHolder);
|
nickjillings@1356
|
164 break;
|
nickjillings@1356
|
165 case "volume":
|
nickjillings@1356
|
166 if (document.getElementById('master-volume-holder') == null)
|
nickjillings@1356
|
167 {
|
nickjillings@1356
|
168 feedbackHolder.appendChild(interfaceContext.volume.object);
|
nickjillings@1356
|
169 }
|
nickjillings@1356
|
170 break;
|
nickjillings@1356
|
171 }
|
nickjillings@1356
|
172 }
|
nickjillings@1356
|
173 }
|
nickjillings@1341
|
174
|
nickjillings@2110
|
175 // Populate the comparator object
|
nickjillings@2110
|
176 interfaceContext.comparator = new comparator(audioHolderObject);
|
nickjillings@1316
|
177 if (audioHolderObject.showElementComments)
|
nickjillings@1316
|
178 {
|
nickjillings@1316
|
179 var commentHolder = document.createElement('div');
|
nickjillings@1316
|
180 commentHolder.id = 'commentHolder';
|
nickjillings@1316
|
181 document.getElementById('testContent').appendChild(commentHolder);
|
nickjillings@1316
|
182 // Generate one comment box per presented page
|
nickjillings@1316
|
183 for (var element of audioEngineContext.audioObjects)
|
nickjillings@1316
|
184 {
|
nickjillings@2117
|
185 interfaceContext.commentBoxes.createCommentBox(element);
|
nickjillings@1316
|
186 }
|
nickjillings@2117
|
187 interfaceContext.commentBoxes.showCommentBoxes(commentHolder,true);
|
nickjillings@1316
|
188 }
|
nickjillings@1341
|
189 resizeWindow(null);
|
nicholas@2356
|
190
|
nicholas@2356
|
191 $(audioHolderObject.commentQuestions).each(function(index,element) {
|
nicholas@2356
|
192 var node = interfaceContext.createCommentQuestion(element);
|
nicholas@2356
|
193 commentHolder.appendChild(node.holder);
|
nicholas@2356
|
194 });
|
nickjillings@1341
|
195 }
|
nickjillings@1341
|
196
|
nickjillings@2110
|
197 function comparator(audioHolderObject)
|
nickjillings@1341
|
198 {
|
nickjillings@2110
|
199 this.comparatorBox = function(audioElement,id,text)
|
nickjillings@1341
|
200 {
|
nickjillings@1341
|
201 this.parent = audioElement;
|
nickjillings@1341
|
202 this.id = id;
|
nickjillings@1341
|
203 this.value = 0;
|
nickjillings@1341
|
204 this.disabled = true;
|
nickjillings@1341
|
205 this.box = document.createElement('div');
|
nickjillings@2110
|
206 this.box.className = 'comparator-holder';
|
nickjillings@1341
|
207 this.box.setAttribute('track-id',audioElement.id);
|
nickjillings@2110
|
208 this.box.id = 'comparator-'+text;
|
nickjillings@1341
|
209 this.selector = document.createElement('div');
|
nickjillings@2110
|
210 this.selector.className = 'comparator-selector disabled';
|
nickjillings@1341
|
211 var selectorText = document.createElement('span');
|
nickjillings@1341
|
212 selectorText.textContent = text;
|
nickjillings@1341
|
213 this.selector.appendChild(selectorText);
|
nickjillings@1341
|
214 this.playback = document.createElement('button');
|
nickjillings@2110
|
215 this.playback.className = 'comparator-button';
|
nickjillings@1341
|
216 this.playback.disabled = true;
|
nickjillings@1341
|
217 this.playback.textContent = "Listen";
|
nickjillings@1341
|
218 this.box.appendChild(this.selector);
|
nickjillings@1341
|
219 this.box.appendChild(this.playback);
|
nickjillings@1349
|
220 this.selector.onclick = function(event)
|
nickjillings@1341
|
221 {
|
nickjillings@1341
|
222 var time = audioEngineContext.timer.getTestTime();
|
nickjillings@1341
|
223 if ($(event.currentTarget).hasClass('disabled'))
|
nickjillings@1341
|
224 {
|
nickjillings@1341
|
225 console.log("Please wait until sample has loaded");
|
nickjillings@1341
|
226 return;
|
nickjillings@1341
|
227 }
|
nickjillings@1341
|
228 if (audioEngineContext.status == 0)
|
nickjillings@1341
|
229 {
|
nicholas@2362
|
230 interfaceContext.lightbox.post("Message","Please listen to the samples before making a selection");
|
nickjillings@1341
|
231 console.log("Please listen to the samples before making a selection");
|
nickjillings@1341
|
232 return;
|
nickjillings@2112
|
233 }
|
nickjillings@1341
|
234 var id = event.currentTarget.parentElement.getAttribute('track-id');
|
nickjillings@2110
|
235 interfaceContext.comparator.selected = id;
|
nickjillings@2112
|
236 if ($(event.currentTarget).hasClass("selected")) {
|
nickjillings@2112
|
237 $(".comparator-selector").removeClass('selected');
|
nickjillings@2112
|
238 for (var i=0; i<interfaceContext.comparator.comparators.length; i++)
|
nickjillings@2112
|
239 {
|
nicholas@2307
|
240 var obj = interfaceContext.comparator.comparators[i];
|
nickjillings@2112
|
241 obj.parent.metric.moved(time,0);
|
nicholas@2307
|
242 obj.value = 0;
|
nickjillings@2112
|
243 }
|
nickjillings@2112
|
244 } else {
|
nickjillings@2112
|
245 $(".comparator-selector").removeClass('selected');
|
nickjillings@2112
|
246 $(event.currentTarget).addClass('selected');
|
nickjillings@2112
|
247 for (var i=0; i<interfaceContext.comparator.comparators.length; i++)
|
nickjillings@2112
|
248 {
|
nickjillings@2112
|
249 var obj = interfaceContext.comparator.comparators[i];
|
nickjillings@2112
|
250 if (i == id) {
|
nickjillings@2112
|
251 obj.value = 1;
|
nickjillings@2112
|
252 } else {
|
nickjillings@2112
|
253 obj.value = 0;
|
nickjillings@2112
|
254 }
|
nickjillings@2112
|
255 obj.parent.metric.moved(time,obj.value);
|
nickjillings@2112
|
256 }
|
nickjillings@2112
|
257 console.log("Selected "+id+' ('+time+')');
|
nickjillings@2112
|
258 }
|
nickjillings@1341
|
259 };
|
nickjillings@1376
|
260 this.playback.setAttribute("playstate","ready");
|
nickjillings@1349
|
261 this.playback.onclick = function(event)
|
nickjillings@1341
|
262 {
|
nickjillings@1341
|
263 var id = event.currentTarget.parentElement.getAttribute('track-id');
|
nickjillings@1376
|
264 if (event.currentTarget.getAttribute("playstate") == "ready")
|
nickjillings@1376
|
265 {
|
nickjillings@1376
|
266 audioEngineContext.play(id);
|
nickjillings@1376
|
267 } else if (event.currentTarget.getAttribute("playstate") == "playing") {
|
nickjillings@1376
|
268 audioEngineContext.stop();
|
nickjillings@1376
|
269 }
|
nickjillings@1376
|
270
|
nickjillings@1341
|
271 };
|
nickjillings@1341
|
272
|
nickjillings@1341
|
273 this.enable = function()
|
nickjillings@1341
|
274 {
|
nickjillings@1341
|
275 if (this.parent.state == 1)
|
nickjillings@1341
|
276 {
|
nickjillings@1341
|
277 $(this.selector).removeClass('disabled');
|
nickjillings@1341
|
278 this.playback.disabled = false;
|
nickjillings@1341
|
279 }
|
nickjillings@1341
|
280 };
|
nickjillings@1341
|
281 this.updateLoading = function(progress)
|
nickjillings@1341
|
282 {
|
nickjillings@1341
|
283 if (progress != 100)
|
nickjillings@1341
|
284 {
|
nickjillings@1341
|
285 progress = String(progress);
|
nickjillings@1341
|
286 progress = progress.split('.')[0];
|
nickjillings@1341
|
287 this.playback.textContent = progress+'%';
|
nickjillings@1341
|
288 } else {
|
nickjillings@1376
|
289 this.playback.textContent = "Play";
|
nickjillings@1341
|
290 }
|
nickjillings@1341
|
291 };
|
nickjillings@2113
|
292 this.error = function() {
|
nickjillings@2113
|
293 // audioObject has an error!!
|
nickjillings@2113
|
294 this.playback.textContent = "Error";
|
nickjillings@2113
|
295 $(this.playback).addClass("error-colour");
|
nickjillings@2113
|
296 }
|
nickjillings@1360
|
297 this.startPlayback = function()
|
nickjillings@1360
|
298 {
|
nickjillings@2110
|
299 $('.comparator-button').text('Listen');
|
nickjillings@1376
|
300 $(this.playback).text('Stop');
|
nickjillings@1376
|
301 this.playback.setAttribute("playstate","playing");
|
nickjillings@1360
|
302 };
|
nickjillings@1360
|
303 this.stopPlayback = function()
|
nickjillings@1360
|
304 {
|
nickjillings@1360
|
305 $(this.playback).text('Listen');
|
nickjillings@1376
|
306 this.playback.setAttribute("playstate","ready");
|
nickjillings@1360
|
307 };
|
nickjillings@1341
|
308 this.exportXMLDOM = function(audioObject)
|
nickjillings@1341
|
309 {
|
nickjillings@1341
|
310 var node = storage.document.createElement('value');
|
nickjillings@1341
|
311 node.textContent = this.value;
|
nickjillings@1341
|
312 return node;
|
nickjillings@1341
|
313 };
|
nickjillings@1341
|
314 this.getValue = function() {
|
nickjillings@1341
|
315 return this.value;
|
nickjillings@1341
|
316 };
|
nickjillings@1341
|
317 this.getPresentedId = function()
|
nickjillings@1341
|
318 {
|
nickjillings@1341
|
319 return this.selector.children[0].textContent;
|
nickjillings@1341
|
320 };
|
nickjillings@1341
|
321 this.canMove = function()
|
nickjillings@1341
|
322 {
|
nickjillings@1341
|
323 return false;
|
nickjillings@1341
|
324 };
|
nickjillings@1341
|
325 };
|
nickjillings@1341
|
326
|
nickjillings@1341
|
327 this.boxHolders = document.getElementById('box-holders');
|
nicholas@2381
|
328 this.boxHolders.innerHTML = "";
|
nickjillings@2110
|
329 this.comparators = [];
|
nickjillings@1341
|
330 this.selected = null;
|
nickjillings@1341
|
331
|
nickjillings@1341
|
332 // First generate the Audio Objects for the Audio Engine
|
nickjillings@1341
|
333 for (var index=0; index<audioHolderObject.audioElements.length; index++)
|
nickjillings@1341
|
334 {
|
nickjillings@1341
|
335 var element = audioHolderObject.audioElements[index];
|
nickjillings@2177
|
336 var audioObject = audioEngineContext.newTrack(element);
|
nickjillings@1341
|
337 if (index == audioHolderObject.outsideReference || element.type == 'outside-reference')
|
nickjillings@1341
|
338 {
|
nickjillings@2177
|
339 var orNode = new interfaceContext.outsideReferenceDOM(audioObject,index,document.getElementById('interface-buttons'));
|
nickjillings@2177
|
340 audioObject.bindInterface(orNode);
|
nickjillings@2177
|
341 } else {
|
nickjillings@2177
|
342 var label;
|
nickjillings@2177
|
343 switch(audioObject.specification.parent.label) {
|
nickjillings@2177
|
344 case "none":
|
nickjillings@2177
|
345 label = "";
|
nickjillings@2177
|
346 break;
|
nickjillings@2177
|
347 case "number":
|
nickjillings@2177
|
348 label = ""+index;
|
nickjillings@2177
|
349 break;
|
nickjillings@2177
|
350 case "letter":
|
nickjillings@2177
|
351 label = String.fromCharCode(97 + index);
|
nickjillings@2177
|
352 break;
|
nickjillings@2177
|
353 default:
|
nickjillings@2177
|
354 label = String.fromCharCode(65 + index);
|
nickjillings@2177
|
355 break;
|
nickjillings@2177
|
356 }
|
nickjillings@2177
|
357 var node = new this.comparatorBox(audioObject,index,label);
|
nickjillings@2177
|
358 audioObject.bindInterface(node);
|
nickjillings@2177
|
359 this.comparators.push(node);
|
nickjillings@2177
|
360 this.boxHolders.appendChild(node.box);
|
nickjillings@1295
|
361 }
|
nickjillings@1341
|
362 }
|
nickjillings@1341
|
363 return this;
|
nickjillings@1341
|
364 }
|
nickjillings@1341
|
365
|
nickjillings@1341
|
366 function resizeWindow(event)
|
nickjillings@1341
|
367 {
|
nickjillings@1341
|
368 document.getElementById('submit').style.left = (window.innerWidth-250)/2 + 'px';
|
nickjillings@2110
|
369 var numObj = interfaceContext.comparator.comparators.length;
|
nickjillings@1341
|
370 var boxW = numObj*312;
|
nickjillings@1341
|
371 var diff = window.innerWidth - boxW;
|
nickjillings@1341
|
372 while (diff < 0)
|
nickjillings@1341
|
373 {
|
nickjillings@1341
|
374 numObj = Math.ceil(numObj/2);
|
nickjillings@1341
|
375 boxW = numObj*312;
|
nickjillings@1341
|
376 diff = window.innerWidth - boxW;
|
nickjillings@1341
|
377 }
|
nickjillings@1341
|
378 document.getElementById('box-holders').style.marginLeft = diff/2 + 'px';
|
nickjillings@1341
|
379 document.getElementById('box-holders').style.marginRight = diff/2 + 'px';
|
nickjillings@1341
|
380 document.getElementById('box-holders').style.width = boxW + 'px';
|
nickjillings@2177
|
381
|
nickjillings@2177
|
382 var outsideRef = document.getElementById('outside-reference');
|
nickjillings@2177
|
383 if(outsideRef != null)
|
nickjillings@2177
|
384 {
|
nickjillings@2177
|
385 outsideRef.style.left = (window.innerWidth-120)/2 + 'px';
|
nickjillings@2177
|
386 }
|
nickjillings@1341
|
387 }
|
nickjillings@1341
|
388
|
nickjillings@1341
|
389 function buttonSubmitClick()
|
nickjillings@1341
|
390 {
|
nickjillings@1341
|
391 var checks = [];
|
nickjillings@1341
|
392 checks = checks.concat(testState.currentStateMap.interfaces[0].options);
|
nickjillings@1341
|
393 checks = checks.concat(specification.interfaces.options);
|
nickjillings@1341
|
394 var canContinue = true;
|
nickjillings@1341
|
395
|
nickjillings@1341
|
396 for (var i=0; i<checks.length; i++) {
|
nickjillings@1341
|
397 if (checks[i].type == 'check')
|
nickjillings@1341
|
398 {
|
nickjillings@1341
|
399 switch(checks[i].name) {
|
nickjillings@1341
|
400 case 'fragmentPlayed':
|
nickjillings@1341
|
401 // Check if all fragments have been played
|
nickjillings@1341
|
402 var checkState = interfaceContext.checkAllPlayed();
|
nickjillings@1341
|
403 if (checkState == false) {canContinue = false;}
|
nickjillings@1341
|
404 break;
|
nickjillings@1341
|
405 case 'fragmentFullPlayback':
|
nickjillings@1341
|
406 // Check all fragments have been played to their full length
|
nickjillings@1341
|
407 var checkState = interfaceContext.checkFragmentsFullyPlayed();
|
nickjillings@1341
|
408 if (checkState == false) {canContinue = false;}
|
nickjillings@1341
|
409 break;
|
nickjillings@1341
|
410 case 'fragmentMoved':
|
nickjillings@1341
|
411 // Check all fragment sliders have been moved.
|
nickjillings@1341
|
412 var checkState = interfaceContext.checkAllMoved();
|
nickjillings@1341
|
413 if (checkState == false) {canContinue = false;}
|
nickjillings@1341
|
414 break;
|
nickjillings@1341
|
415 case 'fragmentComments':
|
nickjillings@1341
|
416 // Check all fragment sliders have been moved.
|
nickjillings@1341
|
417 var checkState = interfaceContext.checkAllCommented();
|
nickjillings@1341
|
418 if (checkState == false) {canContinue = false;}
|
nickjillings@1341
|
419 break;
|
nicholas@2310
|
420 case 'scalerange':
|
nicholas@2310
|
421 // Check the scale has been used effectively
|
nicholas@2310
|
422 var checkState = interfaceContext.checkScaleRange(checks[i].min,checks[i].max);
|
nicholas@2310
|
423 if (checkState == false) {canContinue = false;}
|
nicholas@2310
|
424 break;
|
nickjillings@1341
|
425 default:
|
nickjillings@1341
|
426 console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface");
|
nickjillings@1341
|
427 break;
|
nickjillings@1341
|
428 }
|
nickjillings@1341
|
429
|
nickjillings@1341
|
430 }
|
nickjillings@1341
|
431 if (!canContinue) {break;}
|
nickjillings@1341
|
432 }
|
nickjillings@1341
|
433 if (canContinue)
|
nickjillings@1341
|
434 {
|
nickjillings@1341
|
435 if (audioEngineContext.status == 1) {
|
nickjillings@1341
|
436 var playback = document.getElementById('playback-button');
|
nickjillings@1341
|
437 playback.click();
|
nickjillings@1341
|
438 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
|
nickjillings@1341
|
439 } else
|
nickjillings@1341
|
440 {
|
nickjillings@1341
|
441 if (audioEngineContext.timer.testStarted == false)
|
nickjillings@1341
|
442 {
|
nicholas@2362
|
443 interfaceContext.lightbox.post("Warning",'You have not started the test! Please click play on a sample to begin the test!');
|
nickjillings@1341
|
444 return;
|
nickjillings@1341
|
445 }
|
nickjillings@1341
|
446 }
|
nickjillings@1341
|
447 testState.advanceState();
|
nickjillings@1341
|
448 }
|
nickjillings@1341
|
449 }
|
nickjillings@1341
|
450
|
nickjillings@1341
|
451 function pageXMLSave(store, pageSpecification)
|
nickjillings@1341
|
452 {
|
nickjillings@1341
|
453 // MANDATORY
|
nickjillings@1341
|
454 // Saves a specific test page
|
nickjillings@1341
|
455 // You can use this space to add any extra nodes to your XML <audioHolder> saves
|
nickjillings@1341
|
456 // Get the current <page> information in store (remember to appendChild your data to it)
|
nickjillings@1341
|
457 // pageSpecification is the current page node configuration
|
nickjillings@1341
|
458 // To create new XML nodes, use storage.document.createElement();
|
nickjillings@1341
|
459 } |