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