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