annotate interfaces/ABX.js @ 2362:a3099bdb056c

Implemented #55
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Mon, 16 May 2016 16:14:52 +0100
parents 971acb7e3fab
children 5b23f2e05207
rev   line source
nickjillings@2161 1 /**
nickjillings@2161 2 * WAET Blank Template
nickjillings@2161 3 * Use this to start building your custom interface
nickjillings@2161 4 */
nickjillings@2161 5
nickjillings@2161 6 // Once this is loaded and parsed, begin execution
nickjillings@2161 7 loadInterface();
nickjillings@2161 8
nickjillings@2161 9 function loadInterface() {
nickjillings@2161 10 // Use this to do any one-time page / element construction. For instance, placing any stationary text objects,
nickjillings@2161 11 // holding div's, or setting up any nodes which are present for the entire test sequence
nickjillings@2161 12
nickjillings@2163 13 interfaceContext.insertPoint.innerHTML = null; // Clear the current schema
nickjillings@2163 14
nicholas@2359 15 Interface.prototype.checkScaleRange = function(min, max) {
nicholas@2359 16 var page = testState.getCurrentTestPage();
nicholas@2359 17 var audioObjects = audioEngineContext.audioObjects;
nicholas@2359 18 var state = true;
nicholas@2359 19 var str = "Please keep listening. ";
nicholas@2359 20 var minRanking = Infinity;
nicholas@2359 21 var maxRanking = -Infinity;
nicholas@2359 22 for (var ao of audioObjects) {
nicholas@2359 23 var rank = ao.interfaceDOM.getValue();
nicholas@2359 24 if (rank < minRanking) {minRanking = rank;}
nicholas@2359 25 if (rank > maxRanking) {maxRanking = rank;}
nicholas@2359 26 }
nicholas@2359 27 if (maxRanking*100 < max) {
nicholas@2359 28 str += "At least one fragment must be selected."
nicholas@2359 29 state = false;
nicholas@2359 30 }
nicholas@2359 31 if (!state) {
nicholas@2359 32 console.log(str);
nicholas@2359 33 this.storeErrorNode(str);
nicholas@2362 34 interfaceContext.lightbox.post("Message",str);
nicholas@2359 35 }
nicholas@2359 36 return state;
nicholas@2359 37 }
nicholas@2359 38
nickjillings@2161 39 // Custom comparator Object
nickjillings@2161 40 Interface.prototype.comparator = null;
nickjillings@2161 41
nickjillings@2161 42 // The injection point into the HTML page
nickjillings@2161 43 interfaceContext.insertPoint = document.getElementById("topLevelBody");
nickjillings@2161 44 var testContent = document.createElement('div');
nickjillings@2161 45 testContent.id = 'testContent';
nickjillings@2161 46
nickjillings@2161 47 // Create the top div for the Title element
nickjillings@2161 48 var titleAttr = specification.title;
nickjillings@2161 49 var title = document.createElement('div');
nickjillings@2161 50 title.className = "title";
nickjillings@2161 51 title.align = "center";
nickjillings@2161 52 var titleSpan = document.createElement('span');
nickjillings@2161 53
nickjillings@2161 54 // Set title to that defined in XML, else set to default
nickjillings@2161 55 if (titleAttr != undefined) {
nickjillings@2161 56 titleSpan.textContent = titleAttr;
nickjillings@2161 57 } else {
nickjillings@2161 58 titleSpan.textContent = 'Listening test';
nickjillings@2161 59 }
nickjillings@2161 60 // Insert the titleSpan element into the title div element.
nickjillings@2161 61 title.appendChild(titleSpan);
nickjillings@2161 62
nickjillings@2161 63 var pagetitle = document.createElement('div');
nickjillings@2161 64 pagetitle.className = "pageTitle";
nickjillings@2161 65 pagetitle.align = "center";
nickjillings@2161 66 var titleSpan = document.createElement('span');
nickjillings@2161 67 titleSpan.id = "pageTitle";
nickjillings@2161 68 pagetitle.appendChild(titleSpan);
nickjillings@2161 69
nickjillings@2161 70 // Create Interface buttons!
nickjillings@2161 71 var interfaceButtons = document.createElement('div');
nickjillings@2161 72 interfaceButtons.id = 'interface-buttons';
nickjillings@2161 73 interfaceButtons.style.height = '25px';
nickjillings@2161 74
nickjillings@2161 75 // Create playback start/stop points
nickjillings@2161 76 var playback = document.createElement("button");
nickjillings@2161 77 playback.innerHTML = 'Stop';
nickjillings@2161 78 playback.id = 'playback-button';
nickjillings@2161 79 playback.style.float = 'left';
nickjillings@2161 80 // onclick function. Check if it is playing or not, call the correct function in the
nickjillings@2161 81 // audioEngine, change the button text to reflect the next state.
nickjillings@2161 82 playback.onclick = function() {
nickjillings@2161 83 if (audioEngineContext.status == 1) {
nickjillings@2161 84 audioEngineContext.stop();
nickjillings@2161 85 this.innerHTML = 'Stop';
nickjillings@2161 86 var time = audioEngineContext.timer.getTestTime();
nickjillings@2161 87 console.log('Stopped at ' + time); // DEBUG/SAFETY
nickjillings@2161 88 }
nickjillings@2161 89 };
nickjillings@2161 90 // Append the interface buttons into the interfaceButtons object.
nickjillings@2161 91 interfaceButtons.appendChild(playback);
nickjillings@2161 92
nickjillings@2161 93 // Global parent for the comment boxes on the page
nickjillings@2161 94 var feedbackHolder = document.createElement('div');
nickjillings@2161 95 feedbackHolder.id = 'feedbackHolder';
nickjillings@2161 96
nickjillings@2161 97 // Construct the AB Boxes
nickjillings@2161 98 var boxes = document.createElement('div');
nickjillings@2161 99 boxes.align = "center";
nickjillings@2161 100 boxes.id = "box-holders";
nickjillings@2161 101 boxes.style.float = "left";
nickjillings@2161 102
nickjillings@2161 103 var submit = document.createElement('button');
nickjillings@2161 104 submit.id = "submit";
nickjillings@2161 105 submit.onclick = buttonSubmitClick;
nickjillings@2161 106 submit.className = "big-button";
nickjillings@2161 107 submit.textContent = "submit";
nickjillings@2161 108 submit.style.position = "relative";
nickjillings@2161 109 submit.style.left = (window.innerWidth-250)/2 + 'px';
nickjillings@2161 110
nickjillings@2161 111 feedbackHolder.appendChild(boxes);
nickjillings@2161 112
nickjillings@2161 113 // Inject into HTML
nickjillings@2161 114 testContent.appendChild(title); // Insert the title
nickjillings@2161 115 testContent.appendChild(pagetitle);
nickjillings@2161 116 testContent.appendChild(interfaceButtons);
nickjillings@2161 117 testContent.appendChild(feedbackHolder);
nickjillings@2161 118 testContent.appendChild(submit);
nickjillings@2161 119 interfaceContext.insertPoint.appendChild(testContent);
nickjillings@2161 120
nickjillings@2161 121 // Load the full interface
nickjillings@2161 122 testState.initialise();
nickjillings@2161 123 testState.advanceState();
nickjillings@2161 124 };
nickjillings@2161 125
nickjillings@2161 126 function loadTest(page)
nickjillings@2161 127 {
nickjillings@2161 128 // Called each time a new test page is to be build. The page specification node is the only item passed in
nickjillings@2163 129 document.getElementById('box-holders').innerHTML = null;
nickjillings@2163 130
nickjillings@2163 131 var interfaceObj = page.interfaces;
nickjillings@2163 132 if (interfaceObj.length > 1)
nickjillings@2163 133 {
nickjillings@2163 134 console.log("WARNING - This interface only supports one <interface> node per page. Using first interface node");
nickjillings@2163 135 }
nickjillings@2163 136 interfaceObj = interfaceObj[0];
nickjillings@2163 137
nickjillings@2163 138 if(interfaceObj.title != null)
nickjillings@2163 139 {
nickjillings@2163 140 document.getElementById("pageTitle").textContent = interfaceObj.title;
nickjillings@2163 141 }
nickjillings@2163 142
nickjillings@2163 143 var interfaceOptions = specification.interfaces.options.concat(interfaceObj.options);
nickjillings@2163 144 for (var option of interfaceOptions)
nickjillings@2163 145 {
nickjillings@2163 146 if (option.type == "show")
nickjillings@2163 147 {
nickjillings@2163 148 switch(option.name) {
nickjillings@2163 149 case "playhead":
nickjillings@2163 150 var playbackHolder = document.getElementById('playback-holder');
nickjillings@2163 151 if (playbackHolder == null)
nickjillings@2163 152 {
nickjillings@2163 153 playbackHolder = document.createElement('div');
nickjillings@2163 154 playbackHolder.style.width = "100%";
nickjillings@2163 155 playbackHolder.style.float = "left";
nickjillings@2163 156 playbackHolder.align = 'center';
nickjillings@2163 157 playbackHolder.appendChild(interfaceContext.playhead.object);
nickjillings@2163 158 feedbackHolder.appendChild(playbackHolder);
nickjillings@2163 159 }
nickjillings@2163 160 break;
nickjillings@2163 161 case "page-count":
nickjillings@2163 162 var pagecountHolder = document.getElementById('page-count');
nickjillings@2163 163 if (pagecountHolder == null)
nickjillings@2163 164 {
nickjillings@2163 165 pagecountHolder = document.createElement('div');
nickjillings@2163 166 pagecountHolder.id = 'page-count';
nickjillings@2163 167 }
nickjillings@2163 168 pagecountHolder.innerHTML = '<span>Page '+(testState.stateIndex+1)+' of '+testState.stateMap.length+'</span>';
nickjillings@2163 169 var inject = document.getElementById('interface-buttons');
nickjillings@2163 170 inject.appendChild(pagecountHolder);
nickjillings@2163 171 break;
nickjillings@2163 172 case "volume":
nickjillings@2163 173 if (document.getElementById('master-volume-holder') == null)
nickjillings@2163 174 {
nickjillings@2163 175 feedbackHolder.appendChild(interfaceContext.volume.object);
nickjillings@2163 176 }
nickjillings@2163 177 break;
nickjillings@2163 178 }
nickjillings@2163 179 }
nickjillings@2163 180 }
nickjillings@2163 181
nickjillings@2161 182 interfaceContext.comparator = new comparator(page);
nickjillings@2163 183 resizeWindow(null);
nickjillings@2161 184 }
nickjillings@2161 185
nickjillings@2161 186 function comparator(page)
nickjillings@2161 187 {
nickjillings@2161 188 // Build prototype constructor
nickjillings@2161 189 this.interfaceObject = function(element,label)
nickjillings@2161 190 {
nickjillings@2161 191 // An example node, you can make this however you want for each audioElement.
nickjillings@2161 192 // However, every audioObject (audioEngineContext.audioObject) MUST have an interface object with the following
nickjillings@2161 193 // You attach them by calling audioObject.bindInterface( )
nickjillings@2161 194 this.parent = element;
nickjillings@2161 195 this.id = element.id;
nickjillings@2161 196 this.value = 0;
nickjillings@2161 197 this.disabled = true;
nickjillings@2161 198 this.box = document.createElement('div');
nickjillings@2161 199 this.box.className = 'comparator-holder';
nickjillings@2161 200 this.box.setAttribute('track-id',element.id);
nickjillings@2161 201 this.box.id = 'comparator-'+label;
nickjillings@2161 202 this.selector = document.createElement('div');
nickjillings@2161 203 this.selector.className = 'comparator-selector disabled';
nickjillings@2161 204 var selectorText = document.createElement('span');
nickjillings@2161 205 selectorText.textContent = label;
nickjillings@2161 206 this.selector.appendChild(selectorText);
nickjillings@2161 207 this.playback = document.createElement('button');
nickjillings@2161 208 this.playback.className = 'comparator-button';
nickjillings@2161 209 this.playback.disabled = true;
nickjillings@2161 210 this.playback.textContent = "Listen";
nickjillings@2161 211 this.box.appendChild(this.selector);
nickjillings@2161 212 this.box.appendChild(this.playback);
nickjillings@2161 213 this.selector.onclick = function(event)
nickjillings@2161 214 {
nickjillings@2161 215 var label = event.currentTarget.children[0].textContent;
nickjillings@2161 216 if (label == "X" || label == "x") {return;}
nickjillings@2161 217 var time = audioEngineContext.timer.getTestTime();
nickjillings@2161 218 if ($(event.currentTarget).hasClass('disabled'))
nickjillings@2161 219 {
nickjillings@2161 220 console.log("Please wait until sample has loaded");
nickjillings@2161 221 return;
nickjillings@2161 222 }
nickjillings@2161 223 if (audioEngineContext.status == 0)
nickjillings@2161 224 {
nicholas@2362 225 interfaceContext.lightbox.post("Message", "Please listen to the samples before making a selection");
nickjillings@2161 226 console.log("Please listen to the samples before making a selection");
nickjillings@2161 227 return;
nickjillings@2161 228 }
nickjillings@2161 229 var id = event.currentTarget.parentElement.getAttribute('track-id');
nickjillings@2161 230 interfaceContext.comparator.selected = id;
nickjillings@2161 231 if ($(event.currentTarget).hasClass("selected")) {
nickjillings@2161 232 $(".comparator-selector").removeClass('selected');
giuliomoro@2291 233 for (var i=0; i<interfaceContext.comparator.pair.length; i++)
nickjillings@2161 234 {
nicholas@2308 235 var obj = interfaceContext.comparator.pair[i];
nickjillings@2161 236 obj.parent.metric.moved(time,0);
nicholas@2308 237 obj.value = 0;
nickjillings@2161 238 }
nickjillings@2161 239 } else {
nickjillings@2161 240 $(".comparator-selector").removeClass('selected');
nickjillings@2161 241 $(event.currentTarget).addClass('selected');
giuliomoro@2291 242 for (var i=0; i<interfaceContext.comparator.pair.length; i++)
nickjillings@2161 243 {
giuliomoro@2291 244 var obj = interfaceContext.comparator.pair[i];
nickjillings@2161 245 if (i == id) {
nickjillings@2161 246 obj.value = 1;
nickjillings@2161 247 } else {
nickjillings@2161 248 obj.value = 0;
nickjillings@2161 249 }
nickjillings@2161 250 obj.parent.metric.moved(time,obj.value);
nickjillings@2161 251 }
nickjillings@2161 252 console.log("Selected "+id+' ('+time+')');
nickjillings@2161 253 }
nickjillings@2161 254 };
nickjillings@2161 255 this.playback.setAttribute("playstate","ready");
nickjillings@2161 256 this.playback.onclick = function(event)
nickjillings@2161 257 {
nickjillings@2161 258 var id = event.currentTarget.parentElement.getAttribute('track-id');
nickjillings@2161 259 if (event.currentTarget.getAttribute("playstate") == "ready")
nickjillings@2161 260 {
nickjillings@2161 261 audioEngineContext.play(id);
nickjillings@2161 262 } else if (event.currentTarget.getAttribute("playstate") == "playing") {
nickjillings@2161 263 audioEngineContext.stop();
nickjillings@2161 264 }
nickjillings@2161 265
nickjillings@2161 266 };
nickjillings@2161 267 this.enable = function()
nickjillings@2161 268 {
nickjillings@2161 269 // This is used to tell the interface object that playback of this node is ready
nickjillings@2161 270 if (this.parent.state == 1)
nickjillings@2161 271 {
nickjillings@2161 272 $(this.selector).removeClass('disabled');
nickjillings@2161 273 this.playback.disabled = false;
nickjillings@2161 274 }
nickjillings@2161 275 };
nickjillings@2161 276 this.updateLoading = function(progress)
nickjillings@2161 277 {
nickjillings@2161 278 // progress is a value from 0 to 100 indicating the current download state of media files
nickjillings@2161 279 if (progress != 100)
nickjillings@2161 280 {
nickjillings@2161 281 progress = String(progress);
nickjillings@2161 282 progress = progress.split('.')[0];
nickjillings@2161 283 this.playback.textContent = progress+'%';
nickjillings@2161 284 } else {
nickjillings@2161 285 this.playback.textContent = "Play";
nickjillings@2161 286 }
nickjillings@2161 287 };
nickjillings@2161 288 this.error = function() {
nickjillings@2161 289 // audioObject has an error!!
nickjillings@2161 290 this.playback.textContent = "Error";
nickjillings@2161 291 $(this.playback).addClass("error-colour");
nickjillings@2161 292 };
nickjillings@2161 293 this.startPlayback = function()
nickjillings@2161 294 {
nickjillings@2161 295 // Called when playback has begun
nickjillings@2161 296 $('.comparator-button').text('Listen');
nickjillings@2161 297 $(this.playback).text('Stop');
nickjillings@2161 298 this.playback.setAttribute("playstate","playing");
nickjillings@2161 299 };
nickjillings@2161 300 this.stopPlayback = function()
nickjillings@2161 301 {
nickjillings@2161 302 // Called when playback has stopped. This gets called even if playback never started!
nickjillings@2161 303 $(this.playback).text('Listen');
nickjillings@2161 304 this.playback.setAttribute("playstate","ready");
nickjillings@2161 305 };
nickjillings@2161 306 this.getValue = function()
nickjillings@2161 307 {
nickjillings@2161 308 // Return the current value of the object. If there is no value, return 0
nickjillings@2161 309 return this.value;
nickjillings@2161 310 };
nickjillings@2161 311 this.getPresentedId = function()
nickjillings@2161 312 {
nickjillings@2161 313 // Return the presented ID of the object. For instance, the APE has sliders starting from 0. Whilst AB has alphabetical scale
nickjillings@2161 314 return this.selector.children[0].textContent;
nickjillings@2161 315 };
nickjillings@2161 316 this.canMove = function()
nickjillings@2161 317 {
nickjillings@2161 318 // Return either true or false if the interface object can be moved. AB / Reference cannot, whilst sliders can and therefore have a continuous scale.
nickjillings@2161 319 // These are checked primarily if the interface check option 'fragmentMoved' is enabled.
nickjillings@2161 320 return false;
nickjillings@2161 321 };
nickjillings@2161 322 this.exportXMLDOM = function(audioObject) {
nickjillings@2161 323 // Called by the audioObject holding this element to export the interface <value> node.
nickjillings@2161 324 // If there is no value node (such as outside reference), return null
nickjillings@2161 325 // 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
nickjillings@2161 326 // Use storage.document.createElement('value'); to generate the XML node.
nickjillings@2161 327 var node = storage.document.createElement('value');
nickjillings@2161 328 node.textContent = this.value;
nickjillings@2161 329 return node;
nickjillings@2161 330
nickjillings@2161 331 };
nickjillings@2161 332 this.error = function() {
nickjillings@2161 333 // If there is an error with the audioObject, this will be called to indicate a failure
nickjillings@2161 334 }
nickjillings@2161 335 };
nickjillings@2161 336 // Ensure there are only two comparisons per page
nickjillings@2161 337 if (page.audioElements.length != 2) {
nickjillings@2161 338 console.error('FATAL - There must be 2 <audioelement> nodes on each <page>: '+page.id);
nickjillings@2161 339 return;
nickjillings@2161 340 }
nickjillings@2161 341 // Build the three audio elements
nickjillings@2161 342 this.pair = [];
nickjillings@2161 343 this.X = null;
nickjillings@2161 344 this.boxHolders = document.getElementById('box-holders');
nickjillings@2161 345 for (var index=0; index<page.audioElements.length; index++) {
nickjillings@2161 346 var element = page.audioElements[index];
nickjillings@2161 347 if (element.type != 'normal')
nickjillings@2161 348 {
nickjillings@2161 349 console.log("WARNING - ABX can only have normal elements. Page "+page.id+", Element "+element.id);
nickjillings@2161 350 element.type = "normal";
nickjillings@2161 351 }
nickjillings@2161 352 var audioObject = audioEngineContext.newTrack(element);
nickjillings@2161 353 var label;
nickjillings@2161 354 switch(audioObject.specification.parent.label) {
nickjillings@2161 355 case "none":
nickjillings@2161 356 label = "";
nickjillings@2161 357 break;
nickjillings@2161 358 case "number":
nickjillings@2161 359 label = ""+index;
nickjillings@2161 360 break;
nickjillings@2161 361 case "letter":
nickjillings@2161 362 label = String.fromCharCode(97 + index);
nickjillings@2161 363 break;
nickjillings@2161 364 default:
nickjillings@2161 365 label = String.fromCharCode(65 + index);
nickjillings@2161 366 break;
nickjillings@2161 367 }
nickjillings@2161 368 var node = new this.interfaceObject(audioObject,label);
nickjillings@2161 369 audioObject.bindInterface(node);
nickjillings@2161 370 this.pair.push(node);
nickjillings@2161 371 this.boxHolders.appendChild(node.box);
nickjillings@2161 372 }
nickjillings@2161 373 var elementId = Math.floor(Math.random() * 2); //Randomly pick A or B to be X
giuliomoro@2291 374 var element = new page.audioElementNode(specification);
nickjillings@2161 375 for (var atr in page.audioElements[elementId]) {
nickjillings@2161 376 eval("element."+atr+" = page.audioElements[elementId]."+atr);
nickjillings@2161 377 }
nickjillings@2161 378 element.id += "-X";
nickjillings@2161 379 if (typeof element.name == "string") {element.name+="-X";}
nickjillings@2161 380 page.audioElements.push(element);
nickjillings@2161 381 // Create the save place-holder for the 'X' element
nickjillings@2161 382 var root = testState.currentStore.XMLDOM;
nickjillings@2161 383 var aeNode = storage.document.createElement('audioelement');
nickjillings@2161 384 aeNode.setAttribute('ref',element.id);
nickjillings@2161 385 if (typeof element.name == "string"){aeNode.setAttribute('name',element.name);}
nickjillings@2161 386 aeNode.setAttribute('type','normal');
nickjillings@2161 387 aeNode.setAttribute('url',element.url);
nickjillings@2161 388 aeNode.setAttribute('gain',element.gain);
nickjillings@2161 389 aeNode.appendChild(storage.document.createElement('metric'));
nickjillings@2161 390 root.appendChild(aeNode);
nickjillings@2161 391 // Build the 'X' element
nickjillings@2161 392 var audioObject = audioEngineContext.newTrack(element);
nickjillings@2161 393 var label;
nickjillings@2161 394 switch(audioObject.specification.parent.label) {
nickjillings@2161 395 case "letter":
nickjillings@2161 396 label = "x";
nickjillings@2161 397 break;
nickjillings@2161 398 default:
nickjillings@2161 399 label = "X";
nickjillings@2161 400 break;
nickjillings@2161 401 }
nickjillings@2161 402 var node = new this.interfaceObject(audioObject,label);
giuliomoro@2305 403 node.box.children[0].classList.add('inactive');
nickjillings@2161 404 audioObject.bindInterface(node);
nickjillings@2161 405 this.X = node;
nickjillings@2161 406 this.boxHolders.appendChild(node.box);
nickjillings@2161 407 }
nickjillings@2161 408
nickjillings@2161 409 function resizeWindow(event)
nickjillings@2161 410 {
nickjillings@2163 411 document.getElementById('submit').style.left = (window.innerWidth-250)/2 + 'px';
nickjillings@2163 412 var numObj = 3;
nickjillings@2163 413 var boxW = numObj*312;
nickjillings@2163 414 var diff = window.innerWidth - boxW;
nickjillings@2163 415 while (diff < 0)
nickjillings@2163 416 {
nickjillings@2163 417 numObj = Math.ceil(numObj/2);
nickjillings@2163 418 boxW = numObj*312;
nickjillings@2163 419 diff = window.innerWidth - boxW;
nickjillings@2163 420 }
nickjillings@2163 421 document.getElementById('box-holders').style.marginLeft = diff/2 + 'px';
nickjillings@2163 422 document.getElementById('box-holders').style.marginRight = diff/2 + 'px';
nickjillings@2163 423 document.getElementById('box-holders').style.width = boxW + 'px';
nickjillings@2161 424 }
nickjillings@2161 425
nickjillings@2161 426 function buttonSubmitClick()
nickjillings@2161 427 {
nickjillings@2163 428 var checks = [];
nickjillings@2163 429 checks = checks.concat(testState.currentStateMap.interfaces[0].options);
nickjillings@2163 430 checks = checks.concat(specification.interfaces.options);
nickjillings@2163 431 var canContinue = true;
nickjillings@2163 432
nickjillings@2163 433 for (var i=0; i<checks.length; i++) {
nickjillings@2163 434 if (checks[i].type == 'check')
nickjillings@2163 435 {
nickjillings@2163 436 switch(checks[i].name) {
nickjillings@2163 437 case 'fragmentPlayed':
nickjillings@2163 438 // Check if all fragments have been played
nickjillings@2163 439 var checkState = interfaceContext.checkAllPlayed();
nickjillings@2163 440 if (checkState == false) {canContinue = false;}
nickjillings@2163 441 break;
nickjillings@2163 442 case 'fragmentFullPlayback':
nickjillings@2163 443 // Check all fragments have been played to their full length
nickjillings@2163 444 var checkState = interfaceContext.checkFragmentsFullyPlayed();
nickjillings@2163 445 if (checkState == false) {canContinue = false;}
nickjillings@2163 446 break;
nickjillings@2163 447 case 'fragmentMoved':
nickjillings@2163 448 // Check all fragment sliders have been moved.
nickjillings@2163 449 var checkState = interfaceContext.checkAllMoved();
nickjillings@2163 450 if (checkState == false) {canContinue = false;}
nickjillings@2163 451 break;
nickjillings@2163 452 case 'fragmentComments':
nickjillings@2163 453 // Check all fragment sliders have been moved.
nickjillings@2163 454 var checkState = interfaceContext.checkAllCommented();
nickjillings@2163 455 if (checkState == false) {canContinue = false;}
nickjillings@2163 456 break;
nicholas@2310 457 case 'scalerange':
nicholas@2310 458 // Check the scale has been used effectively
nicholas@2310 459 var checkState = interfaceContext.checkScaleRange(checks[i].min,checks[i].max);
nicholas@2310 460 if (checkState == false) {canContinue = false;}
nicholas@2310 461 break;
nickjillings@2163 462 default:
nickjillings@2163 463 console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface");
nickjillings@2163 464 break;
nickjillings@2163 465 }
nickjillings@2163 466
nickjillings@2163 467 }
nickjillings@2163 468 if (!canContinue) {break;}
nickjillings@2163 469 }
nickjillings@2163 470 if (canContinue)
nickjillings@2163 471 {
nickjillings@2163 472 if (audioEngineContext.status == 1) {
nickjillings@2163 473 var playback = document.getElementById('playback-button');
nickjillings@2163 474 playback.click();
nickjillings@2163 475 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
nickjillings@2163 476 } else
nickjillings@2163 477 {
nickjillings@2163 478 if (audioEngineContext.timer.testStarted == false)
nickjillings@2163 479 {
nicholas@2362 480 interfaceContext.lightbox.post("Warning",'You have not started the test! Please listen to a sample to begin the test!');
nickjillings@2163 481 return;
nickjillings@2163 482 }
nickjillings@2163 483 }
nickjillings@2163 484 testState.advanceState();
nickjillings@2163 485 }
nickjillings@2161 486 }
nickjillings@2161 487
nickjillings@2161 488 function pageXMLSave(store, pageSpecification)
nickjillings@2161 489 {
nickjillings@2161 490 // MANDATORY
nickjillings@2161 491 // Saves a specific test page
nickjillings@2161 492 // You can use this space to add any extra nodes to your XML <audioHolder> saves
nickjillings@2161 493 // Get the current <page> information in store (remember to appendChild your data to it)
nickjillings@2161 494 // pageSpecification is the current page node configuration
nickjillings@2161 495 // To create new XML nodes, use storage.document.createElement();
nickjillings@2161 496 }