annotate interfaces/horizontal-sliders.js @ 2474:32335c0f5a08

Merge branch 'master' of https://github.com/BrechtDeMan/WebAudioEvaluationTool
author www-data <www-data@sucuk.dcs.qmul.ac.uk>
date Tue, 02 Aug 2016 15:20:50 +0100
parents 1647bb807186
children 464c6c6692d6
rev   line source
nickjillings@1343 1 // Once this is loaded and parsed, begin execution
nickjillings@1343 2 loadInterface();
nickjillings@1343 3
nickjillings@1343 4 function loadInterface() {
nickjillings@1343 5 // Use this to do any one-time page / element construction. For instance, placing any stationary text objects,
nickjillings@1343 6 // holding div's, or setting up any nodes which are present for the entire test sequence
nickjillings@1343 7
nickjillings@1343 8 // The injection point into the HTML page
nickjillings@1343 9 interfaceContext.insertPoint = document.getElementById("topLevelBody");
nickjillings@1343 10 var testContent = document.createElement('div');
nickjillings@1343 11 testContent.id = 'testContent';
nickjillings@1343 12
nickjillings@1343 13 // Create the top div for the Title element
nickjillings@1343 14 var titleAttr = specification.title;
nickjillings@1343 15 var title = document.createElement('div');
nickjillings@1343 16 title.className = "title";
nickjillings@1343 17 title.align = "center";
nickjillings@1343 18 var titleSpan = document.createElement('span');
nicholas@2470 19 titleSpan.id="test-title";
nickjillings@1343 20
nickjillings@1343 21 // Set title to that defined in XML, else set to default
nickjillings@1343 22 if (titleAttr != undefined) {
nickjillings@1343 23 titleSpan.textContent = titleAttr;
nickjillings@1343 24 } else {
nickjillings@1343 25 titleSpan.textContent = 'Listening test';
nickjillings@1343 26 }
nickjillings@1343 27 // Insert the titleSpan element into the title div element.
nickjillings@1343 28 title.appendChild(titleSpan);
nickjillings@1343 29
nickjillings@1343 30 var pagetitle = document.createElement('div');
nickjillings@1343 31 pagetitle.className = "pageTitle";
nickjillings@1343 32 pagetitle.align = "center";
nickjillings@1343 33 var titleSpan = document.createElement('span');
nickjillings@1343 34 titleSpan.id = "pageTitle";
nickjillings@1343 35 pagetitle.appendChild(titleSpan);
nickjillings@1343 36
nickjillings@1343 37 // Create Interface buttons!
nickjillings@1343 38 var interfaceButtons = document.createElement('div');
nickjillings@1343 39 interfaceButtons.id = 'interface-buttons';
nickjillings@1343 40 interfaceButtons.style.height = '25px';
nickjillings@1343 41
nickjillings@1343 42 // Create playback start/stop points
nickjillings@1343 43 var playback = document.createElement("button");
nickjillings@1343 44 playback.innerHTML = 'Stop';
nickjillings@1343 45 playback.id = 'playback-button';
nickjillings@1343 46 playback.style.float = 'left';
nickjillings@1343 47 // onclick function. Check if it is playing or not, call the correct function in the
nickjillings@1343 48 // audioEngine, change the button text to reflect the next state.
nickjillings@1343 49 playback.onclick = function() {
nickjillings@1343 50 if (audioEngineContext.status == 1) {
nickjillings@1343 51 audioEngineContext.stop();
nickjillings@1343 52 this.innerHTML = 'Stop';
nickjillings@1343 53 var time = audioEngineContext.timer.getTestTime();
nickjillings@1343 54 console.log('Stopped at ' + time); // DEBUG/SAFETY
nickjillings@1343 55 }
nickjillings@1343 56 };
nickjillings@1343 57 // Create Submit (save) button
nickjillings@1343 58 var submit = document.createElement("button");
nickjillings@1295 59 submit.innerHTML = 'Next';
nickjillings@1343 60 submit.onclick = buttonSubmitClick;
nickjillings@1343 61 submit.id = 'submit-button';
nickjillings@1343 62 submit.style.float = 'left';
nickjillings@1343 63 // Append the interface buttons into the interfaceButtons object.
nickjillings@1343 64 interfaceButtons.appendChild(playback);
nickjillings@1343 65 interfaceButtons.appendChild(submit);
nicholas@2396 66
nicholas@2396 67 // Create outside reference holder
nicholas@2396 68 var outsideRef = document.createElement("div");
nicholas@2396 69 outsideRef.id = "outside-reference-holder";
nickjillings@1343 70
nickjillings@1343 71 // Create a slider box
nickjillings@1343 72 var sliderBox = document.createElement('div');
nickjillings@1343 73 sliderBox.style.width = "100%";
nickjillings@1343 74 sliderBox.style.height = window.innerHeight - 200+12 + 'px';
nickjillings@1343 75 sliderBox.style.marginBottom = '10px';
nickjillings@1343 76 sliderBox.id = 'slider';
nickjillings@1343 77 var scaleHolder = document.createElement('div');
nickjillings@1343 78 scaleHolder.id = "scale-holder";
nickjillings@1343 79 scaleHolder.style.marginLeft = "107px";
nickjillings@1343 80 sliderBox.appendChild(scaleHolder);
nickjillings@1343 81 var scaleText = document.createElement('div');
nickjillings@1343 82 scaleText.id = "scale-text-holder";
nickjillings@1343 83 scaleText.style.height = "25px";
nickjillings@1343 84 scaleText.style.width = "100%";
nickjillings@1343 85 scaleHolder.appendChild(scaleText);
nickjillings@1343 86 var scaleCanvas = document.createElement('canvas');
nickjillings@1343 87 scaleCanvas.id = "scale-canvas";
nickjillings@1343 88 scaleCanvas.style.marginLeft = "100px";
nickjillings@1343 89 scaleHolder.appendChild(scaleCanvas);
nickjillings@1343 90 var sliderObjectHolder = document.createElement('div');
nickjillings@1343 91 sliderObjectHolder.id = 'slider-holder';
nickjillings@1343 92 sliderObjectHolder.align = "center";
nickjillings@1343 93 sliderBox.appendChild(sliderObjectHolder);
nickjillings@1343 94
nickjillings@1343 95 // Global parent for the comment boxes on the page
nickjillings@1343 96 var feedbackHolder = document.createElement('div');
nickjillings@1343 97 feedbackHolder.id = 'feedbackHolder';
nickjillings@1343 98
nickjillings@1343 99 testContent.style.zIndex = 1;
nicholas@2381 100 interfaceContext.insertPoint.innerHTML = ""; // Clear the current schema
nickjillings@1343 101
nickjillings@1343 102 // Inject into HTML
nickjillings@1343 103 testContent.appendChild(title); // Insert the title
nickjillings@1343 104 testContent.appendChild(pagetitle);
nickjillings@1343 105 testContent.appendChild(interfaceButtons);
nicholas@2396 106 testContent.appendChild(outsideRef);
nickjillings@1343 107 testContent.appendChild(sliderBox);
nickjillings@1343 108 testContent.appendChild(feedbackHolder);
nickjillings@1343 109 interfaceContext.insertPoint.appendChild(testContent);
nickjillings@1343 110
nickjillings@1343 111 // Load the full interface
nickjillings@1343 112 testState.initialise();
nickjillings@1343 113 testState.advanceState();
nickjillings@1343 114 };
nickjillings@1343 115
nickjillings@1343 116 function loadTest(page)
nickjillings@1343 117 {
nickjillings@1343 118 // Called each time a new test page is to be build. The page specification node is the only item passed in
nickjillings@1343 119 var id = page.id;
nickjillings@1343 120
nickjillings@1343 121 var feedbackHolder = document.getElementById('feedbackHolder');
nicholas@2381 122 feedbackHolder.innerHTML = "";
nickjillings@1356 123
nickjillings@1343 124 var interfaceObj = page.interfaces;
nickjillings@1343 125 if (interfaceObj.length > 1)
nickjillings@1343 126 {
nickjillings@1343 127 console.log("WARNING - This interface only supports one <interface> node per page. Using first interface node");
nickjillings@1343 128 }
nickjillings@1343 129 interfaceObj = interfaceObj[0];
nicholas@2470 130
nicholas@2470 131 // Set the page title
nicholas@2470 132 if (typeof page.title == "string" && page.title.length > 0) {
nicholas@2470 133 document.getElementById("test-title").textContent = page.title
nicholas@2470 134 }
nicholas@2470 135
nickjillings@1343 136 if(interfaceObj.title != null)
nickjillings@1343 137 {
nickjillings@1343 138 document.getElementById("pageTitle").textContent = interfaceObj.title;
nickjillings@1343 139 }
nickjillings@1356 140
nickjillings@1343 141 // Delete outside reference
nicholas@2396 142 document.getElementById("outside-reference-holder").innerHTML = "";
nickjillings@1343 143
nickjillings@1343 144 var sliderBox = document.getElementById('slider-holder');
nicholas@2381 145 sliderBox.innerHTML = "";
nickjillings@1343 146
nickjillings@1343 147 var commentBoxPrefix = "Comment on track";
nickjillings@1343 148 if (interfaceObj.commentBoxPrefix != undefined) {
nickjillings@1343 149 commentBoxPrefix = interfaceObj.commentBoxPrefix;
nickjillings@1343 150 }
nickjillings@1343 151 var loopPlayback = page.loop;
nickjillings@1343 152
nickjillings@1343 153 $(page.commentQuestions).each(function(index,element) {
nickjillings@1343 154 var node = interfaceContext.createCommentQuestion(element);
nickjillings@1343 155 feedbackHolder.appendChild(node.holder);
nickjillings@1343 156 });
nickjillings@1343 157
nickjillings@1343 158 // Find all the audioElements from the audioHolder
nickjillings@1295 159 var index = 0;
nickjillings@1343 160 $(page.audioElements).each(function(index,element){
nickjillings@1343 161 // Find URL of track
nickjillings@1343 162 // In this jQuery loop, variable 'this' holds the current audioElement.
nickjillings@1343 163
nickjillings@1343 164 var audioObject = audioEngineContext.newTrack(element);
nickjillings@1343 165 if (element.type == 'outside-reference')
nickjillings@1343 166 {
nickjillings@1343 167 // Construct outside reference;
nicholas@2396 168 var orNode = new interfaceContext.outsideReferenceDOM(audioObject,index,document.getElementById("outside-reference-holder"));
nickjillings@1343 169 audioObject.bindInterface(orNode);
nickjillings@1343 170 } else {
nickjillings@1343 171 // Create a slider per track
nickjillings@1295 172 switch(audioObject.specification.parent.label) {
nickjillings@1295 173 case "none":
nickjillings@1295 174 label = "";
nickjillings@1295 175 break;
nickjillings@1295 176 case "letter":
nickjillings@1295 177 label = String.fromCharCode(97 + index);
nickjillings@1295 178 break;
nickjillings@1295 179 case "capital":
nickjillings@1295 180 label = String.fromCharCode(65 + index);
nickjillings@1295 181 break;
nickjillings@1295 182 default:
nickjillings@1295 183 label = ""+index;
nickjillings@1295 184 break;
nickjillings@1295 185 }
nickjillings@1343 186 var sliderObj = new sliderObject(audioObject,label);
nickjillings@1343 187
nickjillings@1343 188 if (typeof page.initialPosition === "number")
nickjillings@1343 189 {
nickjillings@1343 190 // Set the values
nickjillings@1343 191 sliderObj.slider.value = page.initalPosition;
nickjillings@1343 192 } else {
nickjillings@1343 193 // Distribute it randomnly
nickjillings@1343 194 sliderObj.slider.value = Math.random();
nickjillings@1343 195 }
nickjillings@1343 196 sliderBox.appendChild(sliderObj.holder);
nickjillings@1343 197 audioObject.bindInterface(sliderObj);
nickjillings@2117 198 interfaceContext.commentBoxes.createCommentBox(audioObject);
nickjillings@1295 199 index += 1;
nickjillings@1343 200 }
nickjillings@1343 201
nickjillings@1343 202 });
n@2407 203 var interfaceOptions = specification.interfaces.options.concat(interfaceObj.options);
n@2407 204 for (var option of interfaceOptions)
nickjillings@1316 205 {
n@2407 206 if (option.type == "show")
n@2407 207 {
n@2407 208 switch(option.name) {
n@2407 209 case "playhead":
n@2407 210 var playbackHolder = document.getElementById('playback-holder');
n@2407 211 if (playbackHolder == null)
n@2407 212 {
n@2407 213 playbackHolder = document.createElement('div');
n@2407 214 playbackHolder.style.width = "100%";
n@2407 215 playbackHolder.align = 'center';
n@2407 216 playbackHolder.appendChild(interfaceContext.playhead.object);
n@2407 217 feedbackHolder.appendChild(playbackHolder);
n@2407 218 }
n@2407 219 break;
n@2407 220 case "page-count":
n@2407 221 var pagecountHolder = document.getElementById('page-count');
n@2407 222 if (pagecountHolder == null)
n@2407 223 {
n@2407 224 pagecountHolder = document.createElement('div');
n@2407 225 pagecountHolder.id = 'page-count';
n@2407 226 }
n@2407 227 pagecountHolder.innerHTML = '<span>Page '+(testState.stateIndex+1)+' of '+testState.stateMap.length+'</span>';
n@2407 228 var inject = document.getElementById('interface-buttons');
n@2407 229 inject.appendChild(pagecountHolder);
n@2407 230 break;
n@2407 231 case "volume":
n@2407 232 if (document.getElementById('master-volume-holder') == null)
n@2407 233 {
n@2407 234 feedbackHolder.appendChild(interfaceContext.volume.object);
n@2407 235 }
n@2407 236 break;
n@2407 237 case "comments":
n@2407 238 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder,true);
n@2407 239 break;
n@2407 240 }
n@2407 241 }
nickjillings@1316 242 }
nickjillings@1343 243 // Auto-align
nickjillings@1343 244 resizeWindow(null);
nickjillings@1343 245 }
nickjillings@1343 246
nickjillings@1343 247 function sliderObject(audioObject,label)
nickjillings@1343 248 {
nickjillings@1343 249 // An example node, you can make this however you want for each audioElement.
nickjillings@1343 250 // However, every audioObject (audioEngineContext.audioObject) MUST have an interface object with the following
nickjillings@1343 251 // You attach them by calling audioObject.bindInterface( )
nickjillings@1343 252 this.parent = audioObject;
nickjillings@1343 253
nickjillings@1343 254 this.holder = document.createElement('div');
nickjillings@1343 255 this.title = document.createElement('div');
nickjillings@1343 256 this.slider = document.createElement('input');
nickjillings@1343 257 this.play = document.createElement('button');
nickjillings@1343 258
nickjillings@1343 259 this.holder.className = 'track-slider';
nickjillings@1343 260 this.holder.style.width = window.innerWidth-200 + 'px';
nickjillings@1343 261 this.holder.appendChild(this.title);
nickjillings@1343 262 this.holder.appendChild(this.slider);
nickjillings@1343 263 this.holder.appendChild(this.play);
nickjillings@1343 264 this.holder.setAttribute('trackIndex',audioObject.id);
nickjillings@1343 265 this.title.textContent = label;
nickjillings@1343 266 this.title.className = 'track-slider-title';
nickjillings@1343 267
nickjillings@1343 268 this.slider.type = "range";
nickjillings@1343 269 this.slider.className = "track-slider-range track-slider-not-moved";
nickjillings@1343 270 this.slider.min = "0";
nickjillings@1343 271 this.slider.max = "1";
nickjillings@1343 272 this.slider.step = "0.01";
nickjillings@1343 273 this.slider.style.width = window.innerWidth-420 + 'px';
nickjillings@1343 274 this.slider.onchange = function()
nickjillings@1343 275 {
nickjillings@1343 276 var time = audioEngineContext.timer.getTestTime();
nickjillings@1343 277 var id = Number(this.parentNode.getAttribute('trackIndex'));
nickjillings@1343 278 audioEngineContext.audioObjects[id].metric.moved(time,this.value);
nickjillings@1343 279 console.log('slider '+id+' moved to '+this.value+' ('+time+')');
nickjillings@1343 280 $(this).removeClass('track-slider-not-moved');
nickjillings@1343 281 };
nickjillings@1343 282
nickjillings@1343 283 this.play.className = 'track-slider-button';
nickjillings@1343 284 this.play.textContent = "Loading...";
nickjillings@1343 285 this.play.value = audioObject.id;
nickjillings@1343 286 this.play.disabled = true;
nickjillings@1377 287 this.play.setAttribute("playstate","ready");
nickjillings@1343 288 this.play.onclick = function(event)
nickjillings@1343 289 {
nickjillings@1343 290 var id = Number(event.currentTarget.value);
nickjillings@1343 291 //audioEngineContext.metric.sliderPlayed(id);
nickjillings@1377 292 if (event.currentTarget.getAttribute("playstate") == "ready")
nickjillings@1377 293 {audioEngineContext.play(id);}
nickjillings@1377 294 else if (event.currentTarget.getAttribute("playstate") == "playing")
nickjillings@1377 295 {audioEngineContext.stop();}
nickjillings@1343 296 };
nickjillings@1344 297 this.resize = function(event)
nickjillings@1344 298 {
nickjillings@1344 299 this.holder.style.width = window.innerWidth-200 + 'px';
nickjillings@1344 300 this.slider.style.width = window.innerWidth-420 + 'px';
nickjillings@1344 301 };
nickjillings@1343 302 this.enable = function()
nickjillings@1343 303 {
nickjillings@1343 304 // This is used to tell the interface object that playback of this node is ready
nickjillings@1343 305 this.play.disabled = false;
nickjillings@1343 306 this.play.textContent = "Play";
nickjillings@1343 307 $(this.slider).removeClass('track-slider-disabled');
nickjillings@1343 308 };
nickjillings@1343 309 this.updateLoading = function(progress)
nickjillings@1343 310 {
nickjillings@1343 311 // progress is a value from 0 to 100 indicating the current download state of media files
nickjillings@1343 312 };
nickjillings@1360 313 this.startPlayback = function()
nickjillings@1360 314 {
nickjillings@1360 315 // Called when playback has begun
nickjillings@1377 316 this.play.setAttribute("playstate","playing");
nickjillings@1360 317 $(".track-slider").removeClass('track-slider-playing');
nickjillings@1360 318 $(this.holder).addClass('track-slider-playing');
nickjillings@1360 319 var outsideReference = document.getElementById('outside-reference');
nickjillings@1360 320 if (outsideReference != null) {
nickjillings@1360 321 $(outsideReference).removeClass('track-slider-playing');
nickjillings@1360 322 }
nickjillings@1360 323 };
nickjillings@1360 324 this.stopPlayback = function()
nickjillings@1360 325 {
nickjillings@1360 326 // Called when playback has stopped. This gets called even if playback never started!
nickjillings@1377 327 this.play.setAttribute("playstate","ready");
nickjillings@1360 328 $(this.holder).removeClass('track-slider-playing');
nickjillings@1360 329 };
nickjillings@1343 330 this.getValue = function()
nickjillings@1343 331 {
nickjillings@1343 332 // Return the current value of the object. If there is no value, return 0
nickjillings@1343 333 return this.slider.value;
nickjillings@1343 334 };
nickjillings@1343 335 this.getPresentedId = function()
nickjillings@1343 336 {
nickjillings@1343 337 // Return the presented ID of the object. For instance, the APE has sliders starting from 0. Whilst AB has alphabetical scale
nickjillings@1343 338 return this.title.textContent;
nickjillings@1343 339 };
nickjillings@1343 340 this.canMove = function()
nickjillings@1343 341 {
nickjillings@1343 342 // 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@1343 343 // These are checked primarily if the interface check option 'fragmentMoved' is enabled.
nickjillings@1343 344 return true;
nickjillings@1343 345 };
nickjillings@1343 346 this.exportXMLDOM = function(audioObject) {
nickjillings@1343 347 // Called by the audioObject holding this element to export the interface <value> node.
nickjillings@1343 348 // If there is no value node (such as outside reference), return null
nickjillings@1343 349 // 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@1343 350 // Use storage.document.createElement('value'); to generate the XML node.
nickjillings@1347 351 var node = storage.document.createElement('value');
nickjillings@1347 352 node.textContent = this.slider.value;
nickjillings@1347 353 return node;
nickjillings@1343 354 };
nickjillings@2113 355 this.error = function() {
nickjillings@2113 356 // audioObject has an error!!
nickjillings@2113 357 this.playback.textContent = "Error";
nickjillings@2113 358 $(this.playback).addClass("error-colour");
nickjillings@2113 359 }
nickjillings@1343 360 };
nickjillings@1343 361
nickjillings@1343 362 function resizeWindow(event)
nickjillings@1343 363 {
nickjillings@1343 364 // Called on every window resize event, use this to scale your page properly
nickjillings@1343 365
nickjillings@1343 366 var numObj = document.getElementsByClassName('track-slider').length;
nickjillings@1343 367 var totalHeight = (numObj * 125)-25;
nickjillings@1343 368 document.getElementById('scale-holder').style.width = window.innerWidth-220 + 'px';
nicholas@2381 369 // Cheers edge for making me delete a canvas every resize.
nickjillings@1343 370 var canvas = document.getElementById('scale-canvas');
nicholas@2381 371 var new_canvas = document.createElement("canvas");
nicholas@2381 372 new_canvas.id = 'scale-canvas';
nicholas@2381 373 new_canvas.style.marginLeft = "100px";
nicholas@2381 374 canvas.parentElement.appendChild(new_canvas);
nicholas@2381 375 canvas.parentElement.removeChild(canvas);
nicholas@2381 376 new_canvas.width = window.innerWidth-420;
nicholas@2381 377 new_canvas.height = totalHeight;
nickjillings@1344 378 for (var i in audioEngineContext.audioObjects)
nickjillings@1344 379 {
nickjillings@1344 380 if (audioEngineContext.audioObjects[i].specification.type != 'outside-reference'){
nickjillings@1344 381 audioEngineContext.audioObjects[i].interfaceDOM.resize(event);
nickjillings@1344 382 }
nickjillings@1344 383 }
nickjillings@1356 384 document.getElementById("slider").style.height = totalHeight+50+'px';
nickjillings@1343 385 drawScale();
nickjillings@1343 386 }
nickjillings@1343 387
nickjillings@1343 388 function drawScale()
nickjillings@1343 389 {
nickjillings@1343 390 var interfaceObj = testState.currentStateMap.interfaces[0];
nickjillings@1343 391 var scales = testState.currentStateMap.interfaces[0].scales;
nickjillings@1343 392 scales = scales.sort(function(a,b) {
nickjillings@1343 393 return a.position - b.position;
nickjillings@1343 394 });
nickjillings@1343 395 var canvas = document.getElementById('scale-canvas');
nickjillings@1343 396 var ctx = canvas.getContext("2d");
nickjillings@1343 397 var height = canvas.height;
nickjillings@1343 398 var width = canvas.width;
nickjillings@1343 399 var textHolder = document.getElementById('scale-text-holder');
nicholas@2381 400 textHolder.innerHTML = "";
nickjillings@1343 401 ctx.fillStyle = "#000000";
nickjillings@1343 402 ctx.setLineDash([1,4]);
nickjillings@1343 403 for (var scale of scales)
nickjillings@1343 404 {
nickjillings@1343 405 var posPercent = scale.position / 100.0;
nickjillings@1343 406 var posPix = Math.round(width * posPercent);
nickjillings@1343 407 if(posPix<=0){posPix=1;}
nickjillings@1343 408 if(posPix>=width){posPix=width-1;}
nickjillings@1343 409 ctx.moveTo(posPix,0);
nickjillings@1343 410 ctx.lineTo(posPix,height);
nickjillings@1343 411 ctx.stroke();
nickjillings@1343 412
nickjillings@1343 413 var text = document.createElement('div');
nickjillings@1343 414 text.align = "center";
nickjillings@1343 415 var textC = document.createElement('span');
nickjillings@1343 416 textC.textContent = scale.text;
nickjillings@1343 417 text.appendChild(textC);
nickjillings@1343 418 text.className = "scale-text";
nickjillings@1343 419 textHolder.appendChild(text);
nickjillings@1343 420 text.style.width = Math.ceil($(text).width())+'px';
nickjillings@1343 421 text.style.left = (posPix+100-($(text).width()/2)) +'px';
nickjillings@1343 422 }
nickjillings@1343 423 }
nickjillings@1343 424
nickjillings@1343 425 function buttonSubmitClick() // TODO: Only when all songs have been played!
nickjillings@1343 426 {
nickjillings@1343 427 var checks = [];
nickjillings@1343 428 checks = checks.concat(testState.currentStateMap.interfaces[0].options);
nickjillings@1343 429 checks = checks.concat(specification.interfaces.options);
nickjillings@1343 430 var canContinue = true;
nickjillings@1343 431
nickjillings@1343 432 // Check that the anchor and reference objects are correctly placed
nickjillings@1343 433 if (interfaceContext.checkHiddenAnchor() == false) {return;}
nickjillings@1343 434 if (interfaceContext.checkHiddenReference() == false) {return;}
nickjillings@1343 435
nickjillings@1343 436 for (var i=0; i<checks.length; i++) {
nickjillings@1343 437 if (checks[i].type == 'check')
nickjillings@1343 438 {
nickjillings@1343 439 switch(checks[i].name) {
nickjillings@1343 440 case 'fragmentPlayed':
nickjillings@1343 441 // Check if all fragments have been played
nickjillings@1343 442 var checkState = interfaceContext.checkAllPlayed();
nickjillings@1343 443 if (checkState == false) {canContinue = false;}
nickjillings@1343 444 break;
nickjillings@1343 445 case 'fragmentFullPlayback':
nickjillings@1343 446 // Check all fragments have been played to their full length
nickjillings@1343 447 var checkState = interfaceContext.checkAllPlayed();
nickjillings@1343 448 if (checkState == false) {canContinue = false;}
nickjillings@1343 449 console.log('NOTE: fragmentFullPlayback not currently implemented, performing check fragmentPlayed instead');
nickjillings@1343 450 break;
nickjillings@1343 451 case 'fragmentMoved':
nickjillings@1343 452 // Check all fragment sliders have been moved.
nickjillings@1343 453 var checkState = interfaceContext.checkAllMoved();
nickjillings@1343 454 if (checkState == false) {canContinue = false;}
nickjillings@1343 455 break;
nickjillings@1343 456 case 'fragmentComments':
nickjillings@1343 457 // Check all fragment sliders have been moved.
nickjillings@1343 458 var checkState = interfaceContext.checkAllCommented();
nickjillings@1343 459 if (checkState == false) {canContinue = false;}
nickjillings@1343 460 break;
nicholas@2310 461 case 'scalerange':
nicholas@2310 462 // Check the scale has been used effectively
nicholas@2310 463 var checkState = interfaceContext.checkScaleRange(checks[i].min,checks[i].max);
nicholas@2310 464 if (checkState == false) {canContinue = false;}
nicholas@2310 465 break;
nickjillings@1343 466 default:
nickjillings@1343 467 console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface");
nickjillings@1343 468 break;
nickjillings@1343 469 }
nickjillings@1343 470
nickjillings@1343 471 }
nickjillings@1343 472 if (!canContinue) {break;}
nickjillings@1343 473 }
nickjillings@1343 474
nickjillings@1343 475 if (canContinue) {
nickjillings@1343 476 if (audioEngineContext.status == 1) {
nickjillings@1343 477 var playback = document.getElementById('playback-button');
nickjillings@1343 478 playback.click();
nickjillings@1343 479 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
nickjillings@1343 480 } else
nickjillings@1343 481 {
nickjillings@1343 482 if (audioEngineContext.timer.testStarted == false)
nickjillings@1343 483 {
nicholas@2362 484 interfaceContext.lightbox.post("Warning",'You have not started the test! Please press start to begin the test!');
nickjillings@1343 485 return;
nickjillings@1343 486 }
nickjillings@1343 487 }
nickjillings@1343 488 testState.advanceState();
nickjillings@1343 489 }
nickjillings@1343 490 }
nickjillings@1343 491
nickjillings@1343 492 function pageXMLSave(store, pageSpecification)
nickjillings@1343 493 {
nickjillings@1343 494 // MANDATORY
nickjillings@1343 495 // Saves a specific test page
nickjillings@1343 496 // You can use this space to add any extra nodes to your XML <audioHolder> saves
nickjillings@1343 497 // Get the current <page> information in store (remember to appendChild your data to it)
nickjillings@1343 498 // pageSpecification is the current page node configuration
nickjillings@1343 499 // To create new XML nodes, use storage.document.createElement();
nickjillings@1343 500 }