comparison interfaces/discrete.js @ 3095:20de79c56ad7

JSHinted Dev_main
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 12 Jan 2018 16:39:39 +0000
parents f888168418ad
children 335bc77627e0
comparison
equal deleted inserted replaced
3094:95e946ee225b 3095:20de79c56ad7
1 /** 1 /**
2 * WAET Blank Template 2 * WAET Blank Template
3 * Use this to start building your custom interface 3 * Use this to start building your custom interface
4 */ 4 */
5 5 /*globals window, interfaceContext, testState, Interface, audioEngineContext, console, document, specification, $, storage*/
6 // Once this is loaded and parsed, begin execution 6 // Once this is loaded and parsed, begin execution
7 loadInterface(); 7 loadInterface();
8 8
9 function loadInterface() { 9 function loadInterface() {
10 // Use this to do any one-time page / element construction. For instance, placing any stationary text objects, 10 // Use this to do any one-time page / element construction. For instance, placing any stationary text objects,
113 interfaceContext.insertPoint.appendChild(testContent); 113 interfaceContext.insertPoint.appendChild(testContent);
114 114
115 // Load the full interface 115 // Load the full interface
116 testState.initialise(); 116 testState.initialise();
117 testState.advanceState(); 117 testState.advanceState();
118 }; 118 }
119 119
120 function loadTest(page) { 120 function loadTest(page) {
121 // Called each time a new test page is to be build. The page specification node is the only item passed in 121 // Called each time a new test page is to be build. The page specification node is the only item passed in
122 122
123 var feedbackHolder = document.getElementById('feedbackHolder'); 123 var feedbackHolder = document.getElementById('feedbackHolder');
184 h.className = "scale-text"; 184 h.className = "scale-text";
185 h.style.gridColumn = String(i + 2) + "/" + String(i + 3); 185 h.style.gridColumn = String(i + 2) + "/" + String(i + 3);
186 text.textContent = a.text; 186 text.textContent = a.text;
187 h.appendChild(text); 187 h.appendChild(text);
188 scaleTextHolder.appendChild(h); 188 scaleTextHolder.appendChild(h);
189 }) 189 });
190 190
191 // Find all the audioElements from the audioHolder 191 // Find all the audioElements from the audioHolder
192 var index = 0; 192 var index = 0;
193 var labelType = page.label; 193 var labelType = page.label;
194 if (labelType == "default") { 194 if (labelType == "default") {
266 if (!playing) { 266 if (!playing) {
267 audioEngineContext.play(audioObject.id); 267 audioEngineContext.play(audioObject.id);
268 } else { 268 } else {
269 audioEngineContext.stop(); 269 audioEngineContext.stop();
270 } 270 }
271 }; 271 }
272 272
273 function radioSelected(event) { 273 function radioSelected(event) {
274 var time = audioEngineContext.timer.getTestTime(); 274 var time = audioEngineContext.timer.getTestTime();
275 audioObject.metric.moved(time, event.currentTarget.value); 275 audioObject.metric.moved(time, event.currentTarget.value);
276 console.log("slider " + audioObject.id + " moved to " + event.currentTarget.value + "(" + time + ")"); 276 console.log("slider " + audioObject.id + " moved to " + event.currentTarget.value + "(" + time + ")");
277 }; 277 }
278 278
279 var root = document.createElement("div"), 279 var root = document.createElement("div"),
280 labelHolder = document.createElement("div"), 280 labelHolder = document.createElement("div"),
281 button = document.createElement("button"); 281 button = document.createElement("button");
282 root.className = "discrete-row"; 282 root.className = "discrete-row";
307 if (event.currentTarget === button) { 307 if (event.currentTarget === button) {
308 buttonClicked(event); 308 buttonClicked(event);
309 } else if (event.currentTarget.type === "radio") { 309 } else if (event.currentTarget.type === "radio") {
310 radioSelected(event); 310 radioSelected(event);
311 } 311 }
312 } 312 };
313 this.enable = function () { 313 this.enable = function () {
314 // This is used to tell the interface object that playback of this node is ready 314 // This is used to tell the interface object that playback of this node is ready
315 button.disabled = ""; 315 button.disabled = "";
316 var a = root.querySelectorAll("input[type=\"radio\"]"); 316 var a = root.querySelectorAll("input[type=\"radio\"]");
317 for (var n = 0; n < a.length; n++) { 317 for (var n = 0; n < a.length; n++) {
370 Object.defineProperties(this, { 370 Object.defineProperties(this, {
371 "DOMRoot": { 371 "DOMRoot": {
372 "value": root 372 "value": root
373 } 373 }
374 }); 374 });
375 }; 375 }
376 376
377 function resizeWindow(event) { 377 function resizeWindow(event) {
378 // Called on every window resize event, use this to scale your page properly 378 // Called on every window resize event, use this to scale your page properly
379 } 379 }
380 380