nicholas@3045
|
1 /**
|
nicholas@3045
|
2 * WAET Blank Template
|
nicholas@3045
|
3 * Use this to start building your custom interface
|
nicholas@3045
|
4 */
|
n@3095
|
5 /*globals window, interfaceContext, testState, Interface, audioEngineContext, console, document, specification, $, storage*/
|
nickjillings@1345
|
6 // Once this is loaded and parsed, begin execution
|
nickjillings@1345
|
7 loadInterface();
|
nickjillings@1345
|
8
|
nickjillings@1345
|
9 function loadInterface() {
|
nicholas@2538
|
10 // Use this to do any one-time page / element construction. For instance, placing any stationary text objects,
|
nicholas@2538
|
11 // holding div's, or setting up any nodes which are present for the entire test sequence
|
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@2699
|
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@2699
|
38
|
nicholas@2699
|
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@1345
|
59 var time = audioEngineContext.timer.getTestTime();
|
nickjillings@1345
|
60 console.log('Stopped at ' + time); // DEBUG/SAFETY
|
nicholas@2538
|
61 }
|
nicholas@2538
|
62 };
|
nicholas@2538
|
63 // Create Submit (save) button
|
nicholas@2538
|
64 var submit = document.createElement("button");
|
nicholas@2538
|
65 submit.innerHTML = 'Next';
|
nicholas@2538
|
66 submit.onclick = buttonSubmitClick;
|
nicholas@2538
|
67 submit.id = 'submit-button';
|
nicholas@2538
|
68 submit.style.float = 'left';
|
n@3007
|
69
|
n@3007
|
70 // Create the sort button
|
n@3007
|
71 var sort = document.createElement("button");
|
n@3007
|
72 sort.id = "sort-fragments";
|
n@3007
|
73 sort.textContent = "Sort";
|
n@3007
|
74 sort.style.display = "inline-block";
|
n@3007
|
75 sort.style.visibility = "hidden";
|
n@3007
|
76 sort.onclick = buttonSortFragmentClick;
|
n@3007
|
77
|
nicholas@2538
|
78 // Append the interface buttons into the interfaceButtons object.
|
nicholas@2538
|
79 interfaceButtons.appendChild(playback);
|
nicholas@2538
|
80 interfaceButtons.appendChild(submit);
|
n@3007
|
81 interfaceButtons.appendChild(sort);
|
nicholas@2538
|
82
|
nicholas@3045
|
83
|
nicholas@3045
|
84 // Create outside reference holder
|
nicholas@3045
|
85 var outsideRef = document.createElement("div");
|
nicholas@3045
|
86 outsideRef.id = "outside-reference-holder";
|
nicholas@3045
|
87
|
nicholas@3045
|
88 // Create a holder for the slider rows
|
nicholas@3045
|
89 var sliderBox = document.createElement("div");
|
nicholas@3045
|
90 sliderBox.id = 'slider-box';
|
nicholas@3045
|
91 var sliderGrid = document.createElement("div");
|
nicholas@3045
|
92 sliderGrid.id = "slider-grid";
|
nicholas@3045
|
93 sliderBox.appendChild(sliderGrid);
|
nicholas@2538
|
94 var scaleText = document.createElement('div');
|
nicholas@2538
|
95 scaleText.id = "scale-text-holder";
|
nicholas@3045
|
96 sliderGrid.appendChild(scaleText);
|
nicholas@3045
|
97
|
nicholas@2538
|
98
|
nicholas@2538
|
99 // Global parent for the comment boxes on the page
|
nicholas@2538
|
100 var feedbackHolder = document.createElement('div');
|
nicholas@2538
|
101 feedbackHolder.id = 'feedbackHolder';
|
nicholas@2538
|
102
|
nicholas@2538
|
103 testContent.style.zIndex = 1;
|
nicholas@2538
|
104 interfaceContext.insertPoint.innerHTML = ""; // Clear the current schema
|
nicholas@2538
|
105
|
nicholas@2538
|
106 // Inject into HTML
|
nicholas@2538
|
107 testContent.appendChild(title); // Insert the title
|
nicholas@2538
|
108 testContent.appendChild(pagetitle);
|
nicholas@2538
|
109 testContent.appendChild(interfaceButtons);
|
nicholas@2396
|
110 testContent.appendChild(outsideRef);
|
nicholas@2538
|
111 testContent.appendChild(sliderBox);
|
nicholas@2538
|
112 testContent.appendChild(feedbackHolder);
|
nicholas@2538
|
113 interfaceContext.insertPoint.appendChild(testContent);
|
nickjillings@1345
|
114
|
nicholas@2538
|
115 // Load the full interface
|
nicholas@2538
|
116 testState.initialise();
|
nicholas@2538
|
117 testState.advanceState();
|
n@3095
|
118 }
|
nickjillings@1345
|
119
|
nicholas@2538
|
120 function loadTest(page) {
|
nicholas@2538
|
121 // Called each time a new test page is to be build. The page specification node is the only item passed in
|
nicholas@2538
|
122
|
nicholas@2538
|
123 var feedbackHolder = document.getElementById('feedbackHolder');
|
nicholas@3045
|
124 var sliderBox = document.getElementById('slider-box');
|
nicholas@3045
|
125 var sliderGrid = document.getElementById("slider-grid");
|
nicholas@3045
|
126 var scaleTextHolder = document.getElementById("scale-text-holder");
|
nicholas@3045
|
127 var interfaceObj = interfaceContext.getCombinedInterfaces(page);
|
nicholas@3045
|
128 var commentBoxPrefix = "Comment on track";
|
nicholas@3045
|
129 var loopPlayback = page.loop;
|
nicholas@2381
|
130 feedbackHolder.innerHTML = "";
|
nicholas@3045
|
131
|
nicholas@2538
|
132 if (interfaceObj.length > 1) {
|
nicholas@2538
|
133 console.log("WARNING - This interface only supports one <interface> node per page. Using first interface node");
|
nicholas@2538
|
134 }
|
nicholas@2538
|
135 interfaceObj = interfaceObj[0];
|
nicholas@2538
|
136
|
nicholas@2470
|
137 // Set the page title
|
nicholas@2470
|
138 if (typeof page.title == "string" && page.title.length > 0) {
|
nicholas@2699
|
139 document.getElementById("test-title").textContent = page.title;
|
nicholas@2470
|
140 }
|
nicholas@3045
|
141 // Set the axis title
|
nicholas@2699
|
142 if (interfaceObj.title !== null) {
|
nicholas@2538
|
143 document.getElementById("pageTitle").textContent = interfaceObj.title;
|
nicholas@2538
|
144 }
|
nicholas@2538
|
145
|
nicholas@2801
|
146 if (interfaceObj.image !== undefined || page.audioElements.some(function (elem) {
|
n@2793
|
147 return elem.image !== undefined;
|
n@2793
|
148 })) {
|
nicholas@2781
|
149 document.getElementById("testContent").insertBefore(interfaceContext.imageHolder.root, document.getElementById("slider"));
|
nicholas@2781
|
150 interfaceContext.imageHolder.setImage(interfaceObj.image);
|
nicholas@2781
|
151 }
|
nicholas@2781
|
152
|
nicholas@2538
|
153 // Delete outside reference
|
nicholas@2396
|
154 document.getElementById("outside-reference-holder").innerHTML = "";
|
nicholas@2538
|
155
|
nicholas@3045
|
156 // Get the comment box prefix
|
nicholas@2699
|
157 if (interfaceObj.commentBoxPrefix !== undefined) {
|
nicholas@2538
|
158 commentBoxPrefix = interfaceObj.commentBoxPrefix;
|
nicholas@2538
|
159 }
|
nicholas@2538
|
160
|
nicholas@3045
|
161 // Populate the comment questions
|
nicholas@3045
|
162 $(page.commentQuestions).each(function (index, element) {
|
nicholas@3045
|
163 var node = interfaceContext.createCommentQuestion(element);
|
nicholas@3045
|
164 feedbackHolder.appendChild(node.holder);
|
nicholas@3045
|
165 });
|
nicholas@3045
|
166
|
nicholas@3045
|
167 // Configure the grid
|
nicholas@3045
|
168 var numRows = page.audioElements.filter(function (a) {
|
nicholas@3045
|
169 return (a.type !== "outside-reference");
|
nicholas@3045
|
170 }).length;
|
nicholas@3045
|
171 var numColumns = page.interfaces[0].scales.length;
|
nicholas@3045
|
172 sliderGrid.style.gridTemplateRows = "50px repeat(" + numRows + ", 72px)";
|
nicholas@3045
|
173 scaleTextHolder.style.gridTemplateColumns = "100px repeat(" + numColumns + ", 1fr) 100px";
|
nicholas@3045
|
174 page.interfaces[0].scales.sort(function (a, b) {
|
nicholas@3045
|
175 if (a.position > b.position) {
|
nicholas@3045
|
176 return 1;
|
nicholas@3045
|
177 } else if (a.position < b.position) {
|
nicholas@3045
|
178 return -1;
|
nicholas@3045
|
179 }
|
nicholas@3045
|
180 return 0;
|
nicholas@3045
|
181 }).forEach(function (a, i) {
|
nicholas@3045
|
182 var h = document.createElement("div");
|
nicholas@3045
|
183 var text = document.createElement("span");
|
nicholas@3045
|
184 h.className = "scale-text";
|
nicholas@3045
|
185 h.style.gridColumn = String(i + 2) + "/" + String(i + 3);
|
nicholas@3045
|
186 text.textContent = a.text;
|
nicholas@3045
|
187 h.appendChild(text);
|
nicholas@3045
|
188 scaleTextHolder.appendChild(h);
|
n@3095
|
189 });
|
nicholas@3045
|
190
|
nicholas@3045
|
191 // Find all the audioElements from the audioHolder
|
nicholas@3045
|
192 var index = 0;
|
nicholas@3045
|
193 var labelType = page.label;
|
nicholas@3045
|
194 if (labelType == "default") {
|
nicholas@3045
|
195 labelType = "number";
|
nicholas@3045
|
196 }
|
nicholas@3045
|
197 $(page.audioElements).each(function (pageIndex, element) {
|
nicholas@3045
|
198 // Find URL of track
|
nicholas@3045
|
199 // In this jQuery loop, variable 'this' holds the current audioElement.
|
nicholas@3045
|
200
|
nicholas@3045
|
201 var audioObject = audioEngineContext.newTrack(element);
|
nicholas@3045
|
202 if (element.type == 'outside-reference') {
|
nicholas@3045
|
203 // Construct outside reference;
|
nicholas@3045
|
204 var orNode = new interfaceContext.outsideReferenceDOM(audioObject, index, document.getElementById("outside-reference-holder"));
|
nicholas@3045
|
205 audioObject.bindInterface(orNode);
|
nicholas@3045
|
206 } else {
|
nicholas@3045
|
207 // Create a slider per track
|
nicholas@3045
|
208 var label = interfaceContext.getLabel(labelType, index, page.labelStart);
|
nicholas@3045
|
209 var sliderObj = new discreteObject(audioObject, label);
|
nicholas@3045
|
210 sliderGrid.appendChild(sliderObj.DOMRoot);
|
nicholas@3045
|
211 audioObject.bindInterface(sliderObj);
|
nicholas@3045
|
212 interfaceContext.commentBoxes.createCommentBox(audioObject);
|
nicholas@3045
|
213 index += 1;
|
nicholas@3045
|
214 }
|
nicholas@3045
|
215
|
nicholas@3045
|
216 });
|
nicholas@2699
|
217 interfaceObj.options.forEach(function (option) {
|
nicholas@2538
|
218 if (option.type == "show") {
|
nicholas@2538
|
219 switch (option.name) {
|
n@2407
|
220 case "playhead":
|
n@2407
|
221 var playbackHolder = document.getElementById('playback-holder');
|
nicholas@2699
|
222 if (playbackHolder === null) {
|
n@2407
|
223 playbackHolder = document.createElement('div');
|
n@2407
|
224 playbackHolder.style.width = "100%";
|
n@2407
|
225 playbackHolder.align = 'center';
|
n@2407
|
226 playbackHolder.appendChild(interfaceContext.playhead.object);
|
n@2407
|
227 feedbackHolder.appendChild(playbackHolder);
|
n@2407
|
228 }
|
n@2407
|
229 break;
|
n@2407
|
230 case "page-count":
|
n@2407
|
231 var pagecountHolder = document.getElementById('page-count');
|
nicholas@2699
|
232 if (pagecountHolder === null) {
|
n@2407
|
233 pagecountHolder = document.createElement('div');
|
n@2407
|
234 pagecountHolder.id = 'page-count';
|
n@2407
|
235 }
|
nicholas@2538
|
236 pagecountHolder.innerHTML = '<span>Page ' + (testState.stateIndex + 1) + ' of ' + testState.stateMap.length + '</span>';
|
n@2407
|
237 var inject = document.getElementById('interface-buttons');
|
n@2407
|
238 inject.appendChild(pagecountHolder);
|
n@2407
|
239 break;
|
n@2407
|
240 case "volume":
|
nicholas@2699
|
241 if (document.getElementById('master-volume-holder') === null) {
|
n@2407
|
242 feedbackHolder.appendChild(interfaceContext.volume.object);
|
n@2407
|
243 }
|
n@2407
|
244 break;
|
n@2407
|
245 case "comments":
|
nicholas@2538
|
246 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder, true);
|
n@2407
|
247 break;
|
n@3007
|
248 case "fragmentSort":
|
n@3007
|
249 var button = document.getElementById('sort-fragments');
|
n@3007
|
250 button.style.visibility = "visible";
|
n@3007
|
251 break;
|
n@2407
|
252 }
|
n@2407
|
253 }
|
nicholas@2699
|
254 });
|
nicholas@2538
|
255 // Auto-align
|
nicholas@2538
|
256 resizeWindow(null);
|
nickjillings@1345
|
257 }
|
nickjillings@1345
|
258
|
nicholas@3045
|
259 function discreteObject(audioObject, label) {
|
nicholas@2538
|
260 // An example node, you can make this however you want for each audioElement.
|
nicholas@2538
|
261 // However, every audioObject (audioEngineContext.audioObject) MUST have an interface object with the following
|
nicholas@2538
|
262 // You attach them by calling audioObject.bindInterface( )
|
nicholas@3045
|
263 var playing = false;
|
nicholas@2538
|
264
|
nicholas@3045
|
265 function buttonClicked(event) {
|
nicholas@3045
|
266 if (!playing) {
|
nicholas@3045
|
267 audioEngineContext.play(audioObject.id);
|
nicholas@3045
|
268 } else {
|
nicholas@3045
|
269 audioEngineContext.stop();
|
nicholas@2699
|
270 }
|
n@3095
|
271 }
|
nicholas@3045
|
272
|
nicholas@3045
|
273 function radioSelected(event) {
|
nicholas@3045
|
274 var time = audioEngineContext.timer.getTestTime();
|
nicholas@3045
|
275 audioObject.metric.moved(time, event.currentTarget.value);
|
nicholas@3045
|
276 console.log("slider " + audioObject.id + " moved to " + event.currentTarget.value + "(" + time + ")");
|
n@3095
|
277 }
|
nicholas@3045
|
278
|
nicholas@3045
|
279 var root = document.createElement("div"),
|
nicholas@3045
|
280 labelHolder = document.createElement("div"),
|
nicholas@3045
|
281 button = document.createElement("button");
|
nicholas@3045
|
282 root.className = "discrete-row";
|
nicholas@3045
|
283 labelHolder.className = "discrete-label";
|
nicholas@3045
|
284 button.className = "discrete-button";
|
nicholas@3045
|
285 root.appendChild(labelHolder);
|
nicholas@3045
|
286
|
nicholas@3045
|
287 var labelSpan = document.createElement("span");
|
nicholas@3045
|
288 labelHolder.appendChild(labelSpan);
|
nicholas@3045
|
289 labelSpan.textContent = label;
|
nicholas@3045
|
290 button.textContent = "Listen";
|
nicholas@3045
|
291 button.disabled = "true";
|
nicholas@3045
|
292 button.addEventListener("click", this);
|
nicholas@3045
|
293
|
nicholas@3045
|
294 var numScales = audioObject.specification.parent.interfaces[0].scales.length;
|
nicholas@3045
|
295 root.style.gridTemplateColumns = "100px repeat(" + numScales + ", 1fr) 100px";
|
nicholas@3045
|
296 for (var n = 0; n < numScales; n++) {
|
nicholas@3045
|
297 var input = document.createElement("input");
|
nicholas@3045
|
298 input.type = "radio";
|
nicholas@3045
|
299 input.disabled = "true";
|
nicholas@3045
|
300 input.value = n / (numScales - 1);
|
nicholas@3045
|
301 input.addEventListener("click", this);
|
nicholas@3045
|
302 input.name = audioObject.specification.id;
|
nicholas@3045
|
303 root.appendChild(input);
|
nicholas@2538
|
304 }
|
nicholas@3045
|
305 root.appendChild(button);
|
nicholas@3045
|
306 this.handleEvent = function (event) {
|
nicholas@3045
|
307 if (event.currentTarget === button) {
|
nicholas@3045
|
308 buttonClicked(event);
|
nicholas@3045
|
309 } else if (event.currentTarget.type === "radio") {
|
nicholas@3045
|
310 radioSelected(event);
|
nicholas@2538
|
311 }
|
n@3095
|
312 };
|
nicholas@2538
|
313 this.enable = function () {
|
nicholas@2538
|
314 // This is used to tell the interface object that playback of this node is ready
|
nicholas@3045
|
315 button.disabled = "";
|
nicholas@3045
|
316 var a = root.querySelectorAll("input[type=\"radio\"]");
|
nicholas@3045
|
317 for (var n = 0; n < a.length; n++) {
|
nicholas@3045
|
318 a[n].disabled = false;
|
nicholas@3045
|
319 }
|
nicholas@3045
|
320 button.textContent = "Listen";
|
nicholas@2538
|
321 };
|
nicholas@2538
|
322 this.updateLoading = function (progress) {
|
nicholas@2538
|
323 // progress is a value from 0 to 100 indicating the current download state of media files
|
nicholas@3045
|
324 button.textContent = progress + "%";
|
nicholas@2538
|
325 };
|
nicholas@2538
|
326 this.startPlayback = function () {
|
nicholas@3045
|
327 // Called when playback has begun
|
nicholas@3045
|
328 playing = true;
|
nicholas@3045
|
329 $(root).addClass("discrete-row-playing");
|
nicholas@3045
|
330 button.textContent = "Stop";
|
nicholas@2699
|
331 };
|
nicholas@2538
|
332 this.stopPlayback = function () {
|
nicholas@3045
|
333 // Called when playback has stopped. This gets called even if playback never started!
|
nicholas@3045
|
334 playing = false;
|
nicholas@3045
|
335 $(root).removeClass("discrete-row-playing");
|
nicholas@3045
|
336 button.textContent = "Listen";
|
nicholas@3045
|
337 };
|
nicholas@3045
|
338 this.getValue = function () {
|
nicholas@3045
|
339 // Return the current value of the object. If there is no value, return 0
|
nicholas@3045
|
340 var a = root.querySelectorAll("input[type=\"radio\"]");
|
nicholas@3045
|
341 for (var n = 0; n < a.length; n++) {
|
nicholas@3045
|
342 if (a[n].checked) {
|
nicholas@3045
|
343 return Number(a[n].value);
|
n@2793
|
344 }
|
n@2428
|
345 }
|
nicholas@3045
|
346 return -1;
|
nicholas@2538
|
347 };
|
nicholas@2538
|
348 this.getPresentedId = function () {
|
nicholas@2538
|
349 // Return the presented ID of the object. For instance, the APE has sliders starting from 0. Whilst AB has alphabetical scale
|
nicholas@3045
|
350 return label;
|
nicholas@2538
|
351 };
|
nicholas@2538
|
352 this.canMove = function () {
|
nicholas@2538
|
353 // Return either true or false if the interface object can be moved. AB / Reference cannot, whilst sliders can and therefore have a continuous scale.
|
nicholas@2538
|
354 // These are checked primarily if the interface check option 'fragmentMoved' is enabled.
|
nicholas@2538
|
355 return true;
|
nicholas@2538
|
356 };
|
nicholas@2538
|
357 this.exportXMLDOM = function (audioObject) {
|
nicholas@2538
|
358 // Called by the audioObject holding this element to export the interface <value> node.
|
nicholas@2538
|
359 // If there is no value node (such as outside reference), return null
|
nicholas@2538
|
360 // If there are multiple value nodes (such as multiple scale / 2D scales), return an array of nodes with each value node having an 'interfaceName' attribute
|
nicholas@2538
|
361 // Use storage.document.createElement('value'); to generate the XML node.
|
nicholas@2538
|
362 var node = storage.document.createElement('value');
|
nicholas@2538
|
363 node.textContent = this.getValue();
|
nicholas@2538
|
364 return node;
|
nicholas@3045
|
365
|
nicholas@2538
|
366 };
|
nicholas@2538
|
367 this.error = function () {
|
nicholas@3045
|
368 // If there is an error with the audioObject, this will be called to indicate a failure
|
nicholas@2699
|
369 };
|
nicholas@3045
|
370 Object.defineProperties(this, {
|
nicholas@3045
|
371 "DOMRoot": {
|
nicholas@3045
|
372 "value": root
|
nicholas@3045
|
373 }
|
nicholas@3045
|
374 });
|
n@3095
|
375 }
|
nickjillings@1345
|
376
|
nicholas@2538
|
377 function resizeWindow(event) {
|
nicholas@2538
|
378 // Called on every window resize event, use this to scale your page properly
|
nickjillings@1345
|
379 }
|
nickjillings@1345
|
380
|
nicholas@3045
|
381 function buttonSortFragmentClick() {
|
nicholas@3045
|
382 var sortIndex = interfaceContext.sortFragmentsByScore();
|
nicholas@3045
|
383 var sliderBox = document.getElementById("slider-holder");
|
nicholas@3045
|
384 var nodes = audioEngineContext.audioObjects.filter(function (ao) {
|
nicholas@3045
|
385 return ao.specification.type !== "outside-reference";
|
nicholas@3040
|
386 });
|
nicholas@3045
|
387 var i;
|
nicholas@3045
|
388 nodes.forEach(function (ao) {
|
nicholas@3045
|
389 sliderBox.removeChild(ao.interfaceDOM.holder);
|
nicholas@3045
|
390 });
|
nicholas@3045
|
391 for (i = 0; i < nodes.length; i++) {
|
nicholas@3045
|
392 var j = sortIndex[i];
|
nicholas@3045
|
393 sliderBox.appendChild(nodes[j].interfaceDOM.holder);
|
nicholas@3040
|
394 }
|
nickjillings@1345
|
395 }
|
nickjillings@1345
|
396
|
nickjillings@1345
|
397 function buttonSubmitClick() // TODO: Only when all songs have been played!
|
nickjillings@1345
|
398 {
|
nicholas@2651
|
399 var checks = testState.currentStateMap.interfaces[0].options,
|
nicholas@2651
|
400 canContinue = true;
|
nickjillings@1345
|
401
|
nicholas@2538
|
402 // Check that the anchor and reference objects are correctly placed
|
nicholas@2699
|
403 if (interfaceContext.checkHiddenAnchor() === false) {
|
nicholas@2538
|
404 return;
|
nicholas@2538
|
405 }
|
nicholas@2699
|
406 if (interfaceContext.checkHiddenReference() === false) {
|
nicholas@2538
|
407 return;
|
nicholas@2538
|
408 }
|
nicholas@2825
|
409 if (interfaceContext.checkFragmentMinPlays() === false) {
|
nicholas@2825
|
410 return;
|
nicholas@2825
|
411 }
|
nicholas@3035
|
412 if (interfaceContext.checkCommentQuestions() === false) {
|
nicholas@3035
|
413 return;
|
nicholas@3035
|
414 }
|
nicholas@2538
|
415
|
nicholas@2538
|
416 for (var i = 0; i < checks.length; i++) {
|
nicholas@3045
|
417 var checkState = true;
|
nicholas@2538
|
418 if (checks[i].type == 'check') {
|
nicholas@2538
|
419 switch (checks[i].name) {
|
nicholas@2538
|
420 case 'fragmentPlayed':
|
nicholas@2538
|
421 // Check if all fragments have been played
|
n@2790
|
422 checkState = interfaceContext.checkAllPlayed(checks[i].errorMessage);
|
nicholas@2538
|
423 break;
|
nicholas@2538
|
424 case 'fragmentFullPlayback':
|
nicholas@2538
|
425 // Check all fragments have been played to their full length
|
n@2790
|
426 checkState = interfaceContext.checkAllPlayed(checks[i].errorMessage);
|
nicholas@2538
|
427 console.log('NOTE: fragmentFullPlayback not currently implemented, performing check fragmentPlayed instead');
|
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@2538
|
432 break;
|
nicholas@2538
|
433 case 'fragmentComments':
|
nicholas@2538
|
434 // Check all fragment sliders have been moved.
|
n@2790
|
435 checkState = interfaceContext.checkAllCommented(checks[i].errorMessage);
|
nicholas@2538
|
436 break;
|
nicholas@2538
|
437 case 'scalerange':
|
nicholas@2538
|
438 // Check the scale has been used effectively
|
n@2790
|
439 checkState = interfaceContext.checkScaleRange(checks[i].errorMessage);
|
nicholas@3045
|
440
|
nicholas@2538
|
441 break;
|
nicholas@2538
|
442 default:
|
nicholas@2538
|
443 console.log("WARNING - Check option " + checks[i].check + " is not supported on this interface");
|
nicholas@2538
|
444 break;
|
nicholas@2538
|
445 }
|
nicholas@2538
|
446 }
|
nicholas@3045
|
447 if (checkState === false) {
|
nicholas@3045
|
448 canContinue = false;
|
nicholas@2538
|
449 break;
|
nicholas@2538
|
450 }
|
nicholas@2538
|
451 }
|
nicholas@2538
|
452
|
nickjillings@1345
|
453 if (canContinue) {
|
nicholas@2538
|
454 if (audioEngineContext.status == 1) {
|
nicholas@2538
|
455 var playback = document.getElementById('playback-button');
|
nicholas@2538
|
456 playback.click();
|
nicholas@2538
|
457 // 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
|
458 } else {
|
nicholas@2699
|
459 if (audioEngineContext.timer.testStarted === false) {
|
nicholas@2538
|
460 interfaceContext.lightbox.post("Warning", 'You have not started the test! Please press start to begin the test!');
|
nicholas@2538
|
461 return;
|
nicholas@2538
|
462 }
|
nicholas@2538
|
463 }
|
nicholas@2538
|
464 testState.advanceState();
|
nicholas@2538
|
465 }
|
nickjillings@1345
|
466 }
|
nickjillings@1345
|
467
|
nicholas@2538
|
468 function pageXMLSave(store, pageSpecification) {
|
nicholas@2538
|
469 // MANDATORY
|
nicholas@2538
|
470 // Saves a specific test page
|
nicholas@2538
|
471 // You can use this space to add any extra nodes to your XML <audioHolder> saves
|
nicholas@2538
|
472 // Get the current <page> information in store (remember to appendChild your data to it)
|
nicholas@2538
|
473 // pageSpecification is the current page node configuration
|
nicholas@2538
|
474 // To create new XML nodes, use storage.document.createElement();
|
nicholas@2538
|
475 }
|