annotate test_create/test_create.html @ 1825:f1c5caf9bb04

Merge. Pull of revision info from dev_main.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 23 Dec 2015 14:36:00 +0000
parents ab037c4210b7 65b97da472dc
children eef2d4ea18fb
rev   line source
nickjillings@1749 1 <!DOCTYPE html>
nickjillings@1749 2 <html lang="en">
nickjillings@1749 3 <head>
nickjillings@1749 4 <meta charset="utf-8">
nickjillings@1749 5
nickjillings@1749 6 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
nickjillings@1749 7 Remove this if you use the .htaccess -->
nickjillings@1749 8 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
nickjillings@1749 9
nickjillings@1453 10 <title>WAET: Test Creator</title>
nickjillings@1749 11
nickjillings@1749 12 <meta name="viewport" content="width=device-width; initial-scale=1.0">
nickjillings@1453 13 <script type="text/javascript">
nickjillings@1591 14
nickjillings@1453 15 var APEInterfaceOptions = [["playhead","page-count"],["Show the playhead/scrubber bar", "Show test page count"]];
nickjillings@1453 16 var APEInterfaceChecks = [["fragmentPlayed","fragmentFullPlayback","fragmentMoved","fragmentComments"],["All Fragments Played","All Fragments Played in entirety","All sliders moved","All fragments have comments"]];
nickjillings@1454 17 var APEInterfaceMetrics = [["testTimer","elementTimer","elementTracker","elementTrackerFull","elementFlagListenedTo","elementFlagMoved","elementFlagComments"],["Test Duration","Total time each fragment was listened to","Return initialised position of marker","Fragment movement tracker with timestamps","Flag if fragment listened to","Flag if fragment moved","Flag if fragment has comments"]];
nickjillings@1453 18 var MUSHRAInterfaceOptions = [[],[]];
nickjillings@1453 19 var MUSHRAInterfaceChecks = [["fragmentPlayed","fragmentMoved","fragmentComments"],["All Fragments Played","All sliders moved","All fragments have comments"]];
nickjillings@1454 20 var MUSHRAInterfaceMetrics = [["testTimer","elementTimer","elementTracker","elementTrackerFull","elementFlagListenedTo","elementFlagMoved","elementFlagComments"],["Test Duration","Total time each fragment was listened to","Return initialised position of marker","Fragment movement tracker with timestamps","Flag if fragment listened to","Flag if fragment moved","Flag if fragment has comments"]];
nickjillings@1453 21 var popupInstance;
nickjillings@1453 22 var specificationNode;
nickjillings@1453 23 var audioContext;
nickjillings@1454 24 var audioObjects = [];
nickjillings@1453 25 window.onload = function()
nickjillings@1453 26 {
nickjillings@1453 27 var AudioContext = window.AudioContext || window.webkitAudioContext;
nickjillings@1453 28 audioContext = new AudioContext;
nickjillings@1453 29 popupInstance = new popup();
nickjillings@1453 30 popupInstance.advanceState();
nickjillings@1453 31 specificationNode = new Specification();
nickjillings@1456 32 specificationNode.projectReturn = "null";
nickjillings@1591 33 };
nickjillings@1591 34
nickjillings@1453 35 function popup()
nickjillings@1453 36 {
nickjillings@1453 37 var x = window.innerWidth;
nickjillings@1453 38 var y = window.innerHeight;
nickjillings@1453 39 this.popupHolder = document.createElement('div');
nickjillings@1453 40 this.popupHolder.style.visibility = 'hidden';
nickjillings@1453 41 this.popupContent = document.createElement('div');
nickjillings@1453 42 this.popupTitle = document.createElement('div');
nickjillings@1453 43 this.popupBody = document.createElement('div');
nickjillings@1453 44 this.popupFooter = document.createElement('div');
nickjillings@1453 45 this.popupTitleText = document.createElement('span');
nickjillings@1453 46 this.popupTitle.appendChild(this.popupTitleText);
nickjillings@1453 47
nickjillings@1453 48 this.popupHolder.className = "popup";
nickjillings@1453 49 this.popupHolder.style.left = (x-500)/2 +'px';
nickjillings@1453 50 this.popupHolder.style.top = (y-400)/2 + 'px';
nickjillings@1453 51 this.popupContent.style.padding = "20px";
nickjillings@1453 52 this.popupHolder.appendChild(this.popupContent);
nickjillings@1453 53
nickjillings@1453 54 this.popupTitle.style.width = "100%";
nickjillings@1453 55 this.popupTitle.style.height = "50px";
nickjillings@1453 56 this.popupTitle.style.fontSize = "xx-large";
nickjillings@1453 57 this.popupContent.appendChild(this.popupTitle);
nickjillings@1453 58
nickjillings@1453 59 this.popupBody.style.width = "100%";
nickjillings@1453 60 this.popupBody.style.height = "280px";
nickjillings@1453 61 this.popupContent.appendChild(this.popupBody);
nickjillings@1453 62
nickjillings@1453 63 this.popupFooter.style.width = "100%";
nickjillings@1453 64 this.popupFooter.style.height = "30px";
nickjillings@1453 65 this.popupContent.appendChild(this.popupFooter);
nickjillings@1453 66 var body = document.getElementsByTagName('body')[0];
nickjillings@1453 67 body.appendChild(this.popupHolder);
nickjillings@1453 68
nickjillings@1453 69 this.pageBlank = document.createElement('div');
nickjillings@1453 70 body.appendChild(this.pageBlank);
nickjillings@1453 71 this.pageBlank.style.width = "100%";
nickjillings@1453 72 this.pageBlank.style.height = "100%";
nickjillings@1453 73 this.pageBlank.style.position = "absolute";
nickjillings@1453 74 this.pageBlank.style.left = "0px";
nickjillings@1453 75 this.pageBlank.style.top = "0px";
nickjillings@1453 76 this.pageBlank.style.backgroundColor = "rgba(0,0,0,0.5)";
nickjillings@1453 77 this.pageBlank.style.visibility = 'hidden';
nickjillings@1453 78
nickjillings@1453 79 this.state = 0;
nickjillings@1454 80 this.dataTransfer = null;
nickjillings@1453 81
nickjillings@1453 82 this.showPopup = function()
nickjillings@1453 83 {
nickjillings@1453 84 this.popupHolder.style.visibility = 'visible';
nickjillings@1453 85 this.popupHolder.style.zIndex = "3";
nickjillings@1453 86 this.pageBlank.style.visibility = 'visible';
nickjillings@1453 87 this.pageBlank.style.zIndex = "2";
nickjillings@1453 88 };
nickjillings@1453 89
nickjillings@1453 90 this.hidePopup = function()
nickjillings@1453 91 {
nickjillings@1453 92 this.popupHolder.style.visibility = 'hidden';
nickjillings@1453 93 this.popupHolder.style.zIndex = "-1";
nickjillings@1453 94 this.pageBlank.style.visibility = 'hidden';
nickjillings@1453 95 this.pageBlank.style.zIndex = "-2";
nickjillings@1453 96 };
nickjillings@1453 97
nickjillings@1453 98 this.init = function()
nickjillings@1453 99 {
nickjillings@1453 100 this.popupTitleText.textContent = "Welcome";
nickjillings@1453 101 var text = document.createElement('span');
nickjillings@1453 102 text.textContent = "Thank you for downloading the Web Audio Evaluation Toolbox. This page will help guide you through creating the documents required to run a test. If you have an existing XML file you wish to edit, please drag and drop it into the box below";
nickjillings@1453 103 var dnd = document.createElement('div');
nickjillings@1453 104 dnd.style.width = "100%";
nickjillings@1453 105 dnd.style.height = "50px";
nickjillings@1453 106 dnd.className = "dragndrop";
nickjillings@1404 107 dnd.ondragover = function(e) {
nickjillings@1404 108 e.stopPropagation();
nickjillings@1404 109 e.preventDefault();
nickjillings@1404 110 };
nickjillings@1404 111 dnd.ondragenter = function(e) {
nickjillings@1404 112 e.stopPropagation();
nickjillings@1404 113 e.preventDefault();
nickjillings@1404 114 this.style.backgroundColor = '#AAFFAA';
nickjillings@1404 115 };
nickjillings@1404 116 dnd.ondragleave = function(e) {
nickjillings@1404 117 e.stopPropagation();
nickjillings@1404 118 e.preventDefault();
nickjillings@1404 119 this.style.backgroundColor = "#FFFFFF";
nickjillings@1404 120 };
nickjillings@1404 121 dnd.ondrop = function(e) {
nickjillings@1404 122 e.stopPropagation();
nickjillings@1404 123 e.preventDefault();
nickjillings@1404 124
nickjillings@1404 125 var file = e.dataTransfer.files[0];
nickjillings@1404 126
nickjillings@1404 127 // Uses HTML5 FileAPI - https://w3c.github.io/FileAPI/#filereader-interface
nickjillings@1404 128 var reader = new FileReader();
nickjillings@1404 129 reader.onload = function() {
nickjillings@1404 130 var parse = new DOMParser();
nickjillings@1404 131 var xml = parse.parseFromString(reader.result,'text/xml');
nickjillings@1404 132 specificationNode.decode(xml);
nickjillings@1404 133 popupInstance.hidePopup();
nickjillings@1404 134 SpecificationToHTML();
nickjillings@1404 135 };
nickjillings@1404 136 reader.readAsText(file);
nickjillings@1404 137
nickjillings@1404 138 };
nickjillings@1453 139 this.popupBody.appendChild(text);
nickjillings@1453 140 this.popupBody.appendChild(dnd);
nickjillings@1453 141 this.showPopup();
nickjillings@1453 142
nickjillings@1453 143 var button = document.createElement('button');
nickjillings@1453 144 button.className = "popupButton";
nickjillings@1453 145 button.textContent = "New File";
nickjillings@1453 146 button.onclick = function(event) {
nickjillings@1453 147 popupInstance.advanceState();
nickjillings@1453 148 };
nickjillings@1453 149 this.popupFooter.appendChild(button);
nickjillings@1453 150 };
nickjillings@1453 151
nickjillings@1453 152 this.advanceState = function()
nickjillings@1453 153 {
nickjillings@1453 154 this.popupBody.innerHTML = null;
nickjillings@1453 155 this.popupFooter.innerHTML = null;
nickjillings@1453 156 this.popupTitleText.textContent = null;
nickjillings@1453 157 switch(this.state)
nickjillings@1453 158 {
nickjillings@1453 159 case 0:
nickjillings@1453 160 this.init();
nickjillings@1453 161 break;
nickjillings@1453 162 case 1:
nickjillings@1453 163 this.popupTitleText.textContent = "Test Type";
nickjillings@1453 164 var text = document.createElement("span");
nickjillings@1453 165 text.textContent = "What type of test would you like to use. Currently APE (Audio Perceptual Evaluation) and MUSHRA style interfaces are available";
nickjillings@1453 166 this.popupBody.appendChild(text);
nickjillings@1453 167 var select = document.createElement("select");
nickjillings@1453 168 select.id="interface-select";
nickjillings@1453 169 var opt1 = document.createElement("option");
nickjillings@1453 170 opt1.value = "APE";
nickjillings@1453 171 opt1.textContent = "APE";
nickjillings@1453 172 select.appendChild(opt1);
nickjillings@1453 173 var opt2 = document.createElement("option");
nickjillings@1453 174 opt2.value = "MUSHRA";
nickjillings@1453 175 opt2.textContent = "MUSHRA";
nickjillings@1453 176 select.appendChild(opt2);
nickjillings@1453 177 this.popupBody.appendChild(select);
nickjillings@1453 178
nickjillings@1453 179 var button = document.createElement('button');
nickjillings@1453 180 button.className = "popupButton";
nickjillings@1453 181 button.textContent = "Submit";
nickjillings@1453 182 button.onclick = function(event) {
nickjillings@1453 183 var select = document.getElementById("interface-select");
nickjillings@1453 184 specificationNode.interfaceType = select.value;
nickjillings@1453 185 specificationNode.collectMetrics = true;
nickjillings@1453 186 popupInstance.advanceState();
nickjillings@1453 187 };
nickjillings@1453 188 this.popupFooter.appendChild(button);
nickjillings@1453 189 break;
nickjillings@1453 190 case 2:
nickjillings@1453 191 this.popupTitleText.textContent = "Test Options";
nickjillings@1453 192 var holder = document.createElement('div');
nickjillings@1453 193 holder.style.margin = "5px";
nickjillings@1453 194 var checkbox = document.createElement('input');
nickjillings@1453 195 checkbox.type = 'checkbox';
nickjillings@1453 196 checkbox.id = "Randomise-Page";
nickjillings@1453 197 var text = document.createElement('span');
nickjillings@1453 198 text.textContent = "Randomise Page Order";
nickjillings@1453 199 holder.appendChild(checkbox);
nickjillings@1453 200 holder.appendChild(text);
nickjillings@1453 201 this.popupBody.appendChild(holder);
nickjillings@1453 202 switch(specificationNode.interfaceType)
nickjillings@1453 203 {
nickjillings@1453 204 case "APE":
nickjillings@1453 205 for (var i=0; i<APEInterfaceOptions[0].length; i++)
nickjillings@1453 206 {
nickjillings@1453 207 holder = document.createElement('div');
nickjillings@1453 208 holder.style.margin = "5px";
nickjillings@1453 209 checkbox = document.createElement('input');
nickjillings@1453 210 checkbox.type = 'checkbox';
nickjillings@1453 211 checkbox.setAttribute("name","option");
nickjillings@1453 212 checkbox.id = APEInterfaceOptions[0][i];
nickjillings@1453 213 text = document.createElement('span');
nickjillings@1453 214 text.textContent = APEInterfaceOptions[1][i];
nickjillings@1453 215 holder.appendChild(checkbox);
nickjillings@1453 216 holder.appendChild(text);
nickjillings@1453 217 this.popupBody.appendChild(holder);
nickjillings@1453 218 }
nickjillings@1453 219 for (var i=0; i<APEInterfaceChecks[0].length; i++)
nickjillings@1453 220 {
nickjillings@1453 221 holder = document.createElement('div');
nickjillings@1453 222 holder.style.margin = "5px";
nickjillings@1453 223 checkbox = document.createElement('input');
nickjillings@1453 224 checkbox.type = 'checkbox';
nickjillings@1453 225 checkbox.setAttribute("name","check");
nickjillings@1453 226 checkbox.id = APEInterfaceChecks[0][i];
nickjillings@1453 227 text = document.createElement('span');
nickjillings@1453 228 text.textContent = APEInterfaceChecks[1][i];
nickjillings@1453 229 holder.appendChild(checkbox);
nickjillings@1453 230 holder.appendChild(text);
nickjillings@1453 231 this.popupBody.appendChild(holder);
nickjillings@1453 232 }
nickjillings@1453 233 break;
nickjillings@1453 234 case "MUSHRA":
nickjillings@1453 235 for (var i=0; i<MUSHRAInterfaceOptions[0].length; i++)
nickjillings@1453 236 {
nickjillings@1453 237 holder = document.createElement('div');
nickjillings@1453 238 holder.style.margin = "5px";
nickjillings@1453 239 checkbox = document.createElement('input');
nickjillings@1453 240 checkbox.type = 'checkbox';
nickjillings@1453 241 checkbox.setAttribute("name","option");
nickjillings@1453 242 checkbox.id = MUSHRAInterfaceOptions[0][i];
nickjillings@1453 243 text = document.createElement('span');
nickjillings@1453 244 text.textContent = MUSHRAInterfaceOptions[1][i];
nickjillings@1453 245 holder.appendChild(checkbox);
nickjillings@1453 246 holder.appendChild(text);
nickjillings@1453 247 this.popupBody.appendChild(holder);
nickjillings@1453 248 }
nickjillings@1453 249 for (var i=0; i<MUSHRAInterfaceChecks[0].length; i++)
nickjillings@1453 250 {
nickjillings@1453 251 holder = document.createElement('div');
nickjillings@1453 252 holder.style.margin = "5px";
nickjillings@1453 253 checkbox = document.createElement('input');
nickjillings@1453 254 checkbox.type = 'checkbox';
nickjillings@1453 255 checkbox.setAttribute("name","check");
nickjillings@1453 256 checkbox.id = MUSHRAInterfaceChecks[0][i];
nickjillings@1453 257 text = document.createElement('span');
nickjillings@1453 258 text.textContent = MUSHRAInterfaceChecks[1][i];
nickjillings@1453 259 holder.appendChild(checkbox);
nickjillings@1453 260 holder.appendChild(text);
nickjillings@1453 261 this.popupBody.appendChild(holder);
nickjillings@1453 262 }
nickjillings@1453 263 }
nickjillings@1453 264 var button = document.createElement('button');
nickjillings@1453 265 button.className = "popupButton";
nickjillings@1453 266 button.textContent = "Submit";
nickjillings@1453 267 button.onclick = function(event) {
nickjillings@1453 268 var optHold = popupInstance.popupBody;
nickjillings@1453 269 var opt = optHold.firstChild;
nickjillings@1453 270 var input = opt.getElementsByTagName('input')[0];
nickjillings@1453 271 specificationNode.randomiseOrder = input.checked;
nickjillings@1453 272 while(opt.nextSibling != null)
nickjillings@1453 273 {
nickjillings@1453 274 opt = opt.nextSibling;
nickjillings@1453 275 input = opt.getElementsByTagName('input')[0];
nickjillings@1453 276 if (input.checked)
nickjillings@1453 277 {
nickjillings@1453 278 specificationNode.commonInterface.options.push(new specificationNode.commonInterface.optionNode(input));
nickjillings@1453 279 }
nickjillings@1453 280
nickjillings@1453 281 }
nickjillings@1453 282 popupInstance.advanceState();
nickjillings@1453 283 };
nickjillings@1453 284 this.popupFooter.appendChild(button);
nickjillings@1453 285 break;
nickjillings@1453 286 case 3:
nickjillings@1454 287 audioObjects = [];
nickjillings@1453 288 this.popupTitleText.textContent = "Test Page";
nickjillings@1453 289 var span = document.createElement('span');
nickjillings@1453 290 span.textContent = "Drag and drop your audio files into the box below to add them to a test page";
nickjillings@1453 291 this.popupBody.appendChild(span);
nickjillings@1453 292 var dnd = document.createElement('div');
nickjillings@1453 293 dnd.id = "audio-holder-drop";
nickjillings@1453 294 dnd.style.width = "100%";
nickjillings@1453 295 dnd.style.minHeight = "50px";
nickjillings@1453 296 dnd.style.maxHeight = "220px";
nickjillings@1453 297 dnd.style.overflow = 'auto';
nickjillings@1453 298 dnd.className = "dragndrop";
nickjillings@1453 299 dnd.ondragover = function(e) {
nickjillings@1453 300 if(e.preventDefault) {e.preventDefault();}
nickjillings@1453 301 return false;
nickjillings@1453 302 };
nickjillings@1453 303 dnd.ondragenter = function(e) {
nickjillings@1453 304 if(e.preventDefault) {e.preventDefault();}
nickjillings@1453 305 return false;
nickjillings@1453 306 };
nickjillings@1453 307 dnd.ondrop = function(e) {
nickjillings@1453 308 if(e.preventDefault) {e.preventDefault();}
nickjillings@1453 309 var dt = e.dataTransfer;
nickjillings@1453 310 var body = document.getElementById("audio-holder-drop");
nickjillings@1453 311 var files = dt.files;
nickjillings@1453 312 for (var i = 0, f; f = files[i]; i++)
nickjillings@1453 313 {
nickjillings@1454 314 var ao = new audioObject();
nickjillings@1454 315 ao.constructTrack(f);
nickjillings@1454 316 audioObjects.push(ao);
nickjillings@1453 317 var dndHeader = document.createElement('div');
nickjillings@1453 318 dndHeader.style.width = "100%";
nickjillings@1453 319 dndHeader.style.height = "20px";
nickjillings@1453 320 dndHeader.style.borderBottom = "#DDD";
nickjillings@1453 321 dndHeader.style.borderBottomWidth = "1px";
nickjillings@1453 322 dndHeader.style.borderBottomStyle = "solid";
nickjillings@1454 323 dndHeader.setAttribute('aoID',audioObjects.length-1);
nickjillings@1453 324 var dndHInclude = document.createElement('div');
nickjillings@1453 325 dndHInclude.style.width = "30px";
nickjillings@1453 326 dndHInclude.className = "dndheaderelement";
nickjillings@1453 327 var includeCheck = document.createElement('input');
nickjillings@1453 328 includeCheck.type = "checkbox";
nickjillings@1453 329 includeCheck.name = "include-check";
nickjillings@1453 330 includeCheck.checked = true;
nickjillings@1454 331 includeCheck.onchange = function()
nickjillings@1454 332 {
nickjillings@1454 333 var i = event.currentTarget.parentElement.parentElement.getAttribute('aoID');
nickjillings@1454 334 audioObjects[i].include = event.currentTarget.checked;
nickjillings@1454 335 };
nickjillings@1453 336 dndHInclude.appendChild(includeCheck);
nickjillings@1453 337 dndHeader.appendChild(dndHInclude);
nickjillings@1453 338 var dndHTitle = document.createElement('div');
nickjillings@1453 339 dndHTitle.style.width = "180px";
nickjillings@1453 340 dndHTitle.className = "dndheaderelement";
nickjillings@1453 341 var text = document.createElement('span');
nickjillings@1453 342 text.textContent = f.name;
nickjillings@1453 343 dndHTitle.appendChild(text);
nickjillings@1453 344 dndHeader.appendChild(dndHTitle);
nickjillings@1453 345 var dndHID = document.createElement('div');
nickjillings@1453 346 dndHID.style.width = "100px";
nickjillings@1453 347 dndHID.className = "dndheaderelement";
nickjillings@1453 348 var IDInput = document.createElement('input');
nickjillings@1454 349 IDInput.name = "audio-fragment-ID";
nickjillings@1453 350 IDInput.value = f.name.split('.')[0];
nickjillings@1454 351 IDInput.onchange = function()
nickjillings@1454 352 {
nickjillings@1454 353 var allIDInput = document.getElementsByName("audio-fragment-ID");
nickjillings@1454 354 var isCopy = new Array(allIDInput.length);
nickjillings@1454 355 isCopy.fill(0,0,this.length);
nickjillings@1454 356 if (allIDInput.length > 1)
nickjillings@1454 357 {
nickjillings@1454 358 for (var j=0; j<allIDInput.length; j++)
nickjillings@1454 359 {
nickjillings@1454 360 var textCompare1 = allIDInput[j].value;
nickjillings@1454 361 for (var k=j+1; k<allIDInput.length; k++)
nickjillings@1454 362 {
nickjillings@1454 363 var textCompare2 = allIDInput[k].value;
nickjillings@1454 364 if (textCompare1 == textCompare2)
nickjillings@1454 365 {
nickjillings@1454 366 isCopy[j] = 1;
nickjillings@1454 367 isCopy[k] = 1;
nickjillings@1454 368 }
nickjillings@1454 369 }
nickjillings@1454 370 }
nickjillings@1454 371 }
nickjillings@1454 372 var button = document.getElementById('submit');
nickjillings@1454 373 button.disabled = false;
nickjillings@1454 374 for (var j=0; j<allIDInput.length; j++)
nickjillings@1454 375 {
nickjillings@1454 376 if (isCopy[j] == 1)
nickjillings@1454 377 {
nickjillings@1454 378 allIDInput[j].style.backgroundColor = '#F22';
nickjillings@1454 379 button.disabled = true;
nickjillings@1454 380 }
nickjillings@1454 381 else
nickjillings@1454 382 {
nickjillings@1454 383 allIDInput[j].style.backgroundColor = '#FFF';
nickjillings@1454 384 audioObjects[j].id = allIDInput[j].value;
nickjillings@1454 385 }
nickjillings@1454 386 }
nickjillings@1454 387 };
nickjillings@1453 388 IDInput.style.width = "96px";
nickjillings@1453 389 dndHID.appendChild(IDInput);
nickjillings@1453 390 dndHeader.appendChild(dndHID);
nickjillings@1453 391 var dndHPlay = document.createElement('div');
nickjillings@1453 392 dndHPlay.style.width = "100px";
nickjillings@1453 393 dndHPlay.className = "dndheaderelement";
nickjillings@1454 394 var audio = document.createElement('button');
nickjillings@1454 395 audio.textContent = 'Play';
nickjillings@1454 396 audio.className = "popupButton";
nickjillings@1454 397 audio.style.height = "inherit";
nickjillings@1454 398 audio.onclick = function()
nickjillings@1454 399 {
nickjillings@1454 400 var i = event.currentTarget.parentElement.parentElement.getAttribute('aoID');
nickjillings@1454 401 audioObjects[i].play();
nickjillings@1454 402 };
nickjillings@1453 403 dndHPlay.appendChild(audio);
nickjillings@1453 404 dndHeader.appendChild(dndHPlay);
nickjillings@1453 405 dnd.appendChild(dndHeader);
nickjillings@1454 406 IDInput.onchange();
nickjillings@1453 407 }
nickjillings@1453 408 };
nickjillings@1453 409 var dndHeader = document.createElement('div');
nickjillings@1453 410 dndHeader.style.width = "100%";
nickjillings@1453 411 dndHeader.style.height = "15px";
nickjillings@1453 412 dndHeader.style.borderBottom = "#DDD";
nickjillings@1453 413 dndHeader.style.borderBottomWidth = "1px";
nickjillings@1453 414 dndHeader.style.borderBottomStyle = "solid";
nickjillings@1453 415 var dndHInclude = document.createElement('div');
nickjillings@1453 416 dndHInclude.style.width = "30px";
nickjillings@1453 417 dndHInclude.className = "dndheaderelement";
nickjillings@1453 418 var text = document.createElement('span');
nickjillings@1453 419 text.textContent = "Inc.";
nickjillings@1453 420 dndHInclude.appendChild(text);
nickjillings@1453 421 dndHeader.appendChild(dndHInclude);
nickjillings@1453 422 var dndHTitle = document.createElement('div');
nickjillings@1453 423 dndHTitle.style.width = "180px";
nickjillings@1453 424 dndHTitle.className = "dndheaderelement";
nickjillings@1453 425 text = document.createElement('span');
nickjillings@1453 426 text.textContent = "File Name";
nickjillings@1453 427 dndHTitle.appendChild(text);
nickjillings@1453 428 dndHeader.appendChild(dndHTitle);
nickjillings@1453 429 var dndHID = document.createElement('div');
nickjillings@1453 430 dndHID.style.width = "100px";
nickjillings@1453 431 dndHID.className = "dndheaderelement";
nickjillings@1453 432 text = document.createElement('span');
nickjillings@1453 433 text.textContent = "ID";
nickjillings@1453 434 dndHID.appendChild(text);
nickjillings@1453 435 dndHeader.appendChild(dndHID);
nickjillings@1453 436 var dndHPlay = document.createElement('div');
nickjillings@1453 437 dndHPlay.style.width = "100px";
nickjillings@1453 438 dndHPlay.className = "dndheaderelement";
nickjillings@1453 439 text = document.createElement('span');
nickjillings@1453 440 text.textContent = "Sample";
nickjillings@1453 441 dndHPlay.appendChild(text);
nickjillings@1453 442 dndHeader.appendChild(dndHPlay);
nickjillings@1453 443 dnd.appendChild(dndHeader);
nickjillings@1453 444 this.popupBody.appendChild(dnd);
nickjillings@1453 445 var button = document.createElement('button');
nickjillings@1454 446 button.id = 'submit';
nickjillings@1453 447 button.className = "popupButton";
nickjillings@1453 448 button.textContent = "Submit";
nickjillings@1453 449 button.onclick = function(event)
nickjillings@1453 450 {
nickjillings@1454 451 // Construct the audio-holder nodes;
nickjillings@1454 452 for (var i=0; i<audioObjects.length; i++)
nickjillings@1454 453 {
nickjillings@1454 454 if (!audioObjects[i].include)
nickjillings@1454 455 {
nickjillings@1454 456 audioObjects.pop(audioObjects[i]);
nickjillings@1454 457 }
nickjillings@1454 458 }
nickjillings@1454 459 if (audioObjects.length != 0)
nickjillings@1454 460 {
nickjillings@1454 461 popupInstance.advanceState();
nickjillings@1454 462 }
nickjillings@1453 463 };
nickjillings@1453 464 this.popupFooter.appendChild(button);
nickjillings@1454 465 break;
nickjillings@1454 466 case 4:
nickjillings@1454 467 this.popupTitleText.textContent = "Test Page - Options";
nickjillings@1454 468 var span = document.createElement('span');
nickjillings@1454 469 span.textContent = "Set your test page options here";
nickjillings@1454 470 this.popupBody.appendChild(span);
nickjillings@1454 471 var pair = document.createElement('div');
nickjillings@1454 472 pair.style.margin = '5px';
nickjillings@1454 473 var text = document.createElement('span');
nickjillings@1454 474 text.textContent = "Page ID:";
nickjillings@1454 475 var input = document.createElement('input');
nickjillings@1454 476 input.value = specificationNode.audioHolders.length;
nickjillings@1454 477 input.id = "id";
nickjillings@1454 478 pair.appendChild(text);
nickjillings@1454 479 pair.appendChild(input);
nickjillings@1454 480 this.popupBody.appendChild(pair);
nickjillings@1454 481 pair = document.createElement('div');
nickjillings@1454 482 pair.style.margin = '5px';
nickjillings@1454 483 text = document.createElement('span');
nickjillings@1454 484 text.textContent = "Randomise Fragment Order";
nickjillings@1454 485 input = document.createElement('input');
nickjillings@1454 486 input.type = "checkbox";
nickjillings@1454 487 input.id = "randomiseOrder";
nickjillings@1454 488 pair.appendChild(input);
nickjillings@1454 489 pair.appendChild(text);
nickjillings@1454 490 this.popupBody.appendChild(pair);
nickjillings@1454 491 pair = document.createElement('div');
nickjillings@1454 492 pair.style.margin = '5px';
nickjillings@1454 493 text = document.createElement('span');
nickjillings@1454 494 text.textContent = "Loop Fragment Playback";
nickjillings@1454 495 input = document.createElement('input');
nickjillings@1454 496 input.type = "checkbox";
nickjillings@1454 497 input.id = "loop";
nickjillings@1454 498 pair.appendChild(input);
nickjillings@1454 499 pair.appendChild(text);
nickjillings@1454 500 this.popupBody.appendChild(pair);
nickjillings@1454 501 pair = document.createElement('div');
nickjillings@1454 502 pair.style.margin = '5px';
nickjillings@1454 503 text = document.createElement('span');
nickjillings@1454 504 text.textContent = "Show fragment comment boxes";
nickjillings@1454 505 input = document.createElement('input');
nickjillings@1454 506 input.type = "checkbox";
nickjillings@1454 507 input.id = "elementComments";
nickjillings@1454 508 pair.appendChild(input);
nickjillings@1454 509 pair.appendChild(text);
nickjillings@1454 510 this.popupBody.appendChild(pair);
nickjillings@1454 511 var button = document.createElement('button');
nickjillings@1454 512 button.id = 'submit';
nickjillings@1454 513 button.className = "popupButton";
nickjillings@1454 514 button.textContent = "Next";
nickjillings@1454 515 button.onclick = function(event)
nickjillings@1454 516 {
nickjillings@1454 517 var ah = new specificationNode.audioHolderNode(specificationNode);
nickjillings@1454 518 ah.id = document.getElementById('id').value;
nickjillings@1454 519 ah.presentedId = specificationNode.audioHolders.length;
nickjillings@1454 520 ah.hostURL = ah.id+'/';
nickjillings@1454 521 ah.randomiseOrder = document.getElementById('randomiseOrder').checked;
nickjillings@1454 522 ah.loop = document.getElementById('loop').checked;
nickjillings@1454 523 ah.elementComments = document.getElementById('elementComments').checked;
nickjillings@1454 524 for (var i=0; i<audioObjects.length; i++)
nickjillings@1454 525 {
nickjillings@1454 526 ah.audioElements.push(new ah.audioElementNode(ah,audioObjects[i]));
nickjillings@1454 527 }
nickjillings@1454 528 specificationNode.audioHolders.push(ah);
nickjillings@1454 529 popupInstance.advanceState();
nickjillings@1454 530 };
nickjillings@1454 531 this.popupFooter.appendChild(button);
nickjillings@1454 532 break;
nickjillings@1454 533 case 5:
nickjillings@1454 534 this.dataTransfer = null;
nickjillings@1454 535 this.popupTitleText.textContent = "Test Page - Pre/Post Survey";
nickjillings@1454 536 var span = document.createElement('span');
nickjillings@1454 537 span.textContent = "Add your pre test page options here";
nickjillings@1454 538 this.popupBody.appendChild(span);
nickjillings@1454 539 var preHolder = document.createElement('div');
nickjillings@1454 540 preHolder.id = "preHolder";
nickjillings@1454 541 preHolder.style.width = "460px";
nickjillings@1454 542 preHolder.style.minHeight = "100px";
nickjillings@1454 543 preHolder.style.maxHeight = "220px";
nickjillings@1454 544 preHolder.style.overflow = 'auto';
nickjillings@1454 545 preHolder.style.border = "black";
nickjillings@1454 546 preHolder.style.borderStyle = "solid";
nickjillings@1454 547 preHolder.style.borderWidth = "1px";
nickjillings@1454 548 this.popupBody.appendChild(preHolder);
nickjillings@1454 549 var audioHolder = specificationNode.audioHolders[specificationNode.audioHolders.length-1];
nickjillings@1454 550 var preHeaderHolder = document.createElement('div');
nickjillings@1454 551 preHeaderHolder.style.width = "456px";
nickjillings@1454 552 preHeaderHolder.style.height= "20px";
nickjillings@1454 553 preHeaderHolder.style.margin= "2px";
nickjillings@1454 554 preHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1454 555 preHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1454 556 preHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1454 557 var mvH = document.createElement('div');
nickjillings@1454 558 mvH.className = "dndheaderelement";
nickjillings@1454 559 mvH.style.width = "50px";
nickjillings@1454 560 var text = document.createElement('span');
nickjillings@1454 561 text.textContent = "Order";
nickjillings@1454 562 mvH.appendChild(text);
nickjillings@1454 563 preHeaderHolder.appendChild(mvH);
nickjillings@1454 564 var idH = document.createElement('div');
nickjillings@1454 565 idH.className = "dndheaderelement";
nickjillings@1454 566 idH.style.width = "150px";
nickjillings@1454 567 text = document.createElement('span');
nickjillings@1454 568 text.textContent = "ID";
nickjillings@1454 569 idH.appendChild(text);
nickjillings@1454 570 preHeaderHolder.appendChild(idH);
nickjillings@1454 571 var tH = document.createElement('div');
nickjillings@1454 572 tH.className = "dndheaderelement";
nickjillings@1454 573 tH.style.width = "150px";
nickjillings@1454 574 text = document.createElement('span');
nickjillings@1454 575 text.textContent = "Type";
nickjillings@1454 576 tH.appendChild(text);
nickjillings@1454 577 preHeaderHolder.appendChild(tH);
nickjillings@1454 578 var editH = document.createElement('div');
nickjillings@1454 579 editH.className = "dndheaderelement";
nickjillings@1454 580 editH.style.width = "50px";
nickjillings@1454 581 text = document.createElement('span');
nickjillings@1454 582 text.textContent = "Edit";
nickjillings@1454 583 editH.appendChild(text);
nickjillings@1454 584 preHeaderHolder.appendChild(editH);
nickjillings@1454 585 var deleteH = document.createElement('div');
nickjillings@1454 586 deleteH.className = "dndheaderelement";
nickjillings@1454 587 deleteH.style.width = "50px";
nickjillings@1454 588 text = document.createElement('span');
nickjillings@1454 589 text.textContent = "Delete";
nickjillings@1454 590 deleteH.appendChild(text);
nickjillings@1454 591 preHeaderHolder.appendChild(deleteH);
nickjillings@1454 592 preHolder.appendChild(preHeaderHolder);
nickjillings@1454 593
nickjillings@1454 594
nickjillings@1454 595 for (var i=0; i<audioHolder.preTest.options.length; i++)
nickjillings@1454 596 {
nickjillings@1454 597 var optionNode = audioHolder.preTest.options[i];
nickjillings@1454 598 var entry = document.createElement('div');
nickjillings@1454 599 entry.style.width = "456px";
nickjillings@1454 600 entry.style.height= "20px";
nickjillings@1454 601 entry.style.margin= "2px";
nickjillings@1454 602 entry.style.borderBottom = "#DDD";
nickjillings@1454 603 entry.style.borderBottomWidth = "1px";
nickjillings@1454 604 entry.style.borderBottomStyle = "solid";
nickjillings@1454 605 entry.setAttribute("node-id",i);
nickjillings@1454 606 var node = audioHolder.preTest.options[i];
nickjillings@1454 607 var mvH = document.createElement('div');
nickjillings@1454 608 mvH.className = "dndheaderelement";
nickjillings@1454 609 mvH.style.width = "50px";
nickjillings@1454 610 var mvup = document.createElement("button");
nickjillings@1454 611 mvup.textContent = "Up";
nickjillings@1454 612 mvup.style.width = "25px";
nickjillings@1454 613 mvup.style.padding = "1px 0px";
nickjillings@1454 614 mvup.onclick = function()
nickjillings@1454 615 {
nickjillings@1454 616 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 617 if (i != 0)
nickjillings@1454 618 {
nickjillings@1454 619 var next = audioHolder.preTest.options[i-1];
nickjillings@1454 620 var cur = audioHolder.preTest.options[i];
nickjillings@1454 621 audioHolder.preTest.options[i-1] = cur;
nickjillings@1454 622 audioHolder.preTest.options[i] = next;
nickjillings@1454 623 popupInstance.state = 5;
nickjillings@1454 624 popupInstance.advanceState();
nickjillings@1454 625 }
nickjillings@1454 626 };
nickjillings@1454 627 mvH.appendChild(mvup);
nickjillings@1454 628 var mvdn = document.createElement("button");
nickjillings@1454 629 mvdn.textContent = "Dn";
nickjillings@1454 630 mvdn.style.width = "25px";
nickjillings@1454 631 mvdn.style.padding = "1px 0px";
nickjillings@1454 632 mvdn.onclick = function()
nickjillings@1454 633 {
nickjillings@1454 634 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 635 if (i != audioHolder.preTest.options.length-1)
nickjillings@1454 636 {
nickjillings@1454 637 var next = audioHolder.preTest.options[i+1];
nickjillings@1454 638 var cur = audioHolder.preTest.options[i];
nickjillings@1454 639 audioHolder.preTest.options[i+1] = cur;
nickjillings@1454 640 audioHolder.preTest.options[i] = next;
nickjillings@1454 641 popupInstance.state = 5;
nickjillings@1454 642 popupInstance.advanceState();
nickjillings@1454 643 }
nickjillings@1454 644 };
nickjillings@1454 645 mvH.appendChild(mvdn);
nickjillings@1454 646 entry.appendChild(mvH);
nickjillings@1454 647 var idH = document.createElement('div');
nickjillings@1454 648 idH.className = "dndheaderelement";
nickjillings@1454 649 idH.style.width = "150px";
nickjillings@1454 650 if (optionNode.type != "statement")
nickjillings@1454 651 {
nickjillings@1454 652 var span = document.createElement('span');
nickjillings@1454 653 span.textContent = optionNode.id;
nickjillings@1454 654 idH.appendChild(span);
nickjillings@1454 655 }
nickjillings@1454 656 entry.appendChild(idH);
nickjillings@1454 657 var typeH = document.createElement('div');
nickjillings@1454 658 typeH.className = "dndheaderelement";
nickjillings@1454 659 typeH.style.width = "150px";
nickjillings@1454 660 var span = document.createElement('span');
nickjillings@1454 661 span.textContent = optionNode.type;
nickjillings@1454 662 typeH.appendChild(span);
nickjillings@1454 663 entry.appendChild(typeH);
nickjillings@1454 664 var editH = document.createElement('div');
nickjillings@1454 665 editH.className = "dndheaderelement";
nickjillings@1454 666 editH.style.width = "50px";
nickjillings@1454 667 var editButton = document.createElement("button");
nickjillings@1454 668 editButton.textContent = "Edit";
nickjillings@1454 669 editButton.style.width = "48px";
nickjillings@1454 670 editButton.style.padding = "1px 0px";
nickjillings@1454 671 editButton.onclick = function()
nickjillings@1454 672 {
nickjillings@1454 673 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 674 popupInstance.dataTransfer = new function() {
nickjillings@1454 675 this.title = "Edit Test Node";
nickjillings@1454 676 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].preTest;
nickjillings@1454 677 this.node = this.parent.options[i];
nickjillings@1454 678 this.previousState = 5;
nickjillings@1454 679 };
nickjillings@1454 680 popupInstance.advanceState();
nickjillings@1454 681 };
nickjillings@1454 682 editH.appendChild(editButton);
nickjillings@1454 683 entry.appendChild(editH);
nickjillings@1454 684 var deleteH = document.createElement('div');
nickjillings@1454 685 deleteH.className = "dndheaderelement";
nickjillings@1454 686 deleteH.style.width = "50px";
nickjillings@1454 687 var deleteButton = document.createElement("button");
nickjillings@1454 688 deleteButton.textContent = "Del";
nickjillings@1454 689 deleteButton.style.width = "48px";
nickjillings@1454 690 deleteButton.style.padding = "1px 0px";
nickjillings@1454 691 deleteButton.onclick = function()
nickjillings@1454 692 {
nickjillings@1454 693 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 694 var j = i+1;
nickjillings@1454 695 while(j < audioHolder.preTest.options.length)
nickjillings@1454 696 {
nickjillings@1454 697 audioHolder.preTest.options[i] = audioHolder.preTest.options[j];
nickjillings@1454 698 j++;
nickjillings@1454 699 i++;
nickjillings@1454 700 }
nickjillings@1454 701 audioHolder.preTest.options.pop();
nickjillings@1454 702 popupInstance.state = 5;
nickjillings@1454 703 popupInstance.advanceState();
nickjillings@1454 704 };
nickjillings@1454 705 deleteH.appendChild(deleteButton);
nickjillings@1454 706 entry.appendChild(deleteH);
nickjillings@1454 707 preHolder.appendChild(entry);
nickjillings@1454 708 }
nickjillings@1454 709 var entry = document.createElement('div');
nickjillings@1454 710 entry.style.width = "456px";
nickjillings@1454 711 entry.style.height= "20px";
nickjillings@1454 712 entry.style.margin= "2px";
nickjillings@1454 713 entry.style.borderBottom = "#DDD";
nickjillings@1454 714 entry.style.borderBottomWidth = "1px";
nickjillings@1454 715 entry.style.borderBottomStyle = "solid";
nickjillings@1454 716 entry.align = "center";
nickjillings@1454 717 var addPre = document.createElement('button');
nickjillings@1454 718 addPre.className = "popupButton";
nickjillings@1454 719 addPre.textContent = "Add New Entry";
nickjillings@1454 720 addPre.style.height = "20px";
nickjillings@1454 721 addPre.onclick = function()
nickjillings@1454 722 {
nickjillings@1454 723 popupInstance.dataTransfer = new function() {
nickjillings@1454 724 this.title = "New Pre Test Node";
nickjillings@1454 725 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].preTest;
nickjillings@1454 726 this.node = null;
nickjillings@1454 727 this.previousState = 5;
nickjillings@1454 728 };
nickjillings@1454 729 popupInstance.advanceState();
nickjillings@1454 730 };
nickjillings@1454 731 entry.appendChild(addPre);
nickjillings@1454 732 preHolder.appendChild(entry);
nickjillings@1454 733
nickjillings@1454 734 var span = document.createElement('span');
nickjillings@1454 735 span.textContent = "Add your post test page options here";
nickjillings@1454 736 this.popupBody.appendChild(span);
nickjillings@1454 737 var postHolder = document.createElement('div');
nickjillings@1454 738 postHolder.id = "preHolder";
nickjillings@1454 739 postHolder.style.width = "100%";
nickjillings@1454 740 postHolder.style.minHeight = "100px";
nickjillings@1454 741 postHolder.style.maxHeight = "220px";
nickjillings@1454 742 postHolder.style.overflow = 'auto';
nickjillings@1454 743 postHolder.style.border = "black";
nickjillings@1454 744 postHolder.style.borderStyle = "solid";
nickjillings@1454 745 postHolder.style.borderWidth = "1px";
nickjillings@1454 746 this.popupBody.appendChild(postHolder);
nickjillings@1454 747 var postHeaderHolder = document.createElement('div');
nickjillings@1454 748 postHeaderHolder.style.width = "456px";
nickjillings@1454 749 postHeaderHolder.style.height= "20px";
nickjillings@1454 750 postHeaderHolder.style.margin= "2px";
nickjillings@1454 751 postHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1454 752 postHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1454 753 postHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1454 754 var mvH = document.createElement('div');
nickjillings@1454 755 mvH.className = "dndheaderelement";
nickjillings@1454 756 mvH.style.width = "50px";
nickjillings@1454 757 var text = document.createElement('span');
nickjillings@1454 758 text.textContent = "Order";
nickjillings@1454 759 mvH.appendChild(text);
nickjillings@1454 760 postHeaderHolder.appendChild(mvH);
nickjillings@1454 761 var idH = document.createElement('div');
nickjillings@1454 762 idH.className = "dndheaderelement";
nickjillings@1454 763 idH.style.width = "150px";
nickjillings@1454 764 text = document.createElement('span');
nickjillings@1454 765 text.textContent = "ID";
nickjillings@1454 766 idH.appendChild(text);
nickjillings@1454 767 postHeaderHolder.appendChild(idH);
nickjillings@1454 768 var tH = document.createElement('div');
nickjillings@1454 769 tH.className = "dndheaderelement";
nickjillings@1454 770 tH.style.width = "150px";
nickjillings@1454 771 text = document.createElement('span');
nickjillings@1454 772 text.textContent = "Type";
nickjillings@1454 773 tH.appendChild(text);
nickjillings@1454 774 postHeaderHolder.appendChild(tH);
nickjillings@1454 775 var editH = document.createElement('div');
nickjillings@1454 776 editH.className = "dndheaderelement";
nickjillings@1454 777 editH.style.width = "50px";
nickjillings@1454 778 text = document.createElement('span');
nickjillings@1454 779 text.textContent = "Edit";
nickjillings@1454 780 editH.appendChild(text);
nickjillings@1454 781 postHeaderHolder.appendChild(editH);
nickjillings@1454 782 var deleteH = document.createElement('div');
nickjillings@1454 783 deleteH.className = "dndheaderelement";
nickjillings@1454 784 deleteH.style.width = "50px";
nickjillings@1454 785 text = document.createElement('span');
nickjillings@1454 786 text.textContent = "Delete";
nickjillings@1454 787 deleteH.appendChild(text);
nickjillings@1454 788 postHeaderHolder.appendChild(deleteH);
nickjillings@1454 789 postHolder.appendChild(postHeaderHolder);
nickjillings@1454 790
nickjillings@1454 791 for (var i=0; i<audioHolder.postTest.options.length; i++)
nickjillings@1454 792 {
nickjillings@1454 793 var optionNode = audioHolder.postTest.options[i];
nickjillings@1454 794 var entry = document.createElement('div');
nickjillings@1454 795 entry.style.width = "456px";
nickjillings@1454 796 entry.style.height= "20px";
nickjillings@1454 797 entry.style.margin= "2px";
nickjillings@1454 798 entry.style.borderBottom = "#DDD";
nickjillings@1454 799 entry.style.borderBottomWidth = "1px";
nickjillings@1454 800 entry.style.borderBottomStyle = "solid";
nickjillings@1454 801 entry.setAttribute("node-id",i);
nickjillings@1454 802 var node = audioHolder.postTest.options[i];
nickjillings@1454 803 var mvH = document.createElement('div');
nickjillings@1454 804 mvH.className = "dndheaderelement";
nickjillings@1454 805 mvH.style.width = "50px";
nickjillings@1454 806 var mvup = document.createElement("button");
nickjillings@1454 807 mvup.textContent = "Up";
nickjillings@1454 808 mvup.style.width = "25px";
nickjillings@1454 809 mvup.style.padding = "1px 0px";
nickjillings@1454 810 mvup.onclick = function()
nickjillings@1454 811 {
nickjillings@1454 812 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 813 if (i != 0)
nickjillings@1454 814 {
nickjillings@1454 815 var next = audioHolder.postTest.options[i-1];
nickjillings@1454 816 var cur = audioHolder.postTest.options[i];
nickjillings@1454 817 audioHolder.postTest.options[i-1] = cur;
nickjillings@1454 818 audioHolder.postTest.options[i] = next;
nickjillings@1454 819 popupInstance.state = 5;
nickjillings@1454 820 popupInstance.advanceState();
nickjillings@1454 821 }
nickjillings@1454 822 };
nickjillings@1454 823 mvH.appendChild(mvup);
nickjillings@1454 824 var mvdn = document.createElement("button");
nickjillings@1454 825 mvdn.textContent = "Dn";
nickjillings@1454 826 mvdn.style.width = "25px";
nickjillings@1454 827 mvdn.style.padding = "1px 0px";
nickjillings@1454 828 mvdn.onclick = function()
nickjillings@1454 829 {
nickjillings@1454 830 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 831 if (i != audioHolder.postTest.options.length-1)
nickjillings@1454 832 {
nickjillings@1454 833 var next = audioHolder.postTest.options[i+1];
nickjillings@1454 834 var cur = audioHolder.postTest.options[i];
nickjillings@1454 835 audioHolder.postTest.options[i+1] = cur;
nickjillings@1454 836 audioHolder.postTest.options[i] = next;
nickjillings@1454 837 popupInstance.state = 5;
nickjillings@1454 838 popupInstance.advanceState();
nickjillings@1454 839 }
nickjillings@1454 840 };
nickjillings@1454 841 mvH.appendChild(mvdn);
nickjillings@1454 842 entry.appendChild(mvH);
nickjillings@1454 843 var idH = document.createElement('div');
nickjillings@1454 844 idH.className = "dndheaderelement";
nickjillings@1454 845 idH.style.width = "150px";
nickjillings@1454 846 if (optionNode.type != "statement")
nickjillings@1454 847 {
nickjillings@1454 848 var span = document.createElement('span');
nickjillings@1454 849 span.textContent = optionNode.id;
nickjillings@1454 850 idH.appendChild(span);
nickjillings@1454 851 }
nickjillings@1454 852 entry.appendChild(idH);
nickjillings@1454 853 var typeH = document.createElement('div');
nickjillings@1454 854 typeH.className = "dndheaderelement";
nickjillings@1454 855 typeH.style.width = "150px";
nickjillings@1454 856 var span = document.createElement('span');
nickjillings@1454 857 span.textContent = optionNode.type;
nickjillings@1454 858 typeH.appendChild(span);
nickjillings@1454 859 entry.appendChild(typeH);
nickjillings@1454 860 var editH = document.createElement('div');
nickjillings@1454 861 editH.className = "dndheaderelement";
nickjillings@1454 862 editH.style.width = "50px";
nickjillings@1454 863 var editButton = document.createElement("button");
nickjillings@1454 864 editButton.textContent = "Edit";
nickjillings@1454 865 editButton.style.width = "48px";
nickjillings@1454 866 editButton.style.padding = "1px 0px";
nickjillings@1454 867 editButton.onclick = function()
nickjillings@1454 868 {
nickjillings@1454 869 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 870 popupInstance.dataTransfer = new function() {
nickjillings@1454 871 this.title = "Edit Test Node";
nickjillings@1454 872 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].postTest;
nickjillings@1454 873 this.node = this.parent.options[i];
nickjillings@1454 874 this.previousState = 5;
nickjillings@1454 875 };
nickjillings@1454 876 popupInstance.advanceState();
nickjillings@1454 877 };
nickjillings@1454 878 editH.appendChild(editButton);
nickjillings@1454 879 entry.appendChild(editH);
nickjillings@1454 880 var deleteH = document.createElement('div');
nickjillings@1454 881 deleteH.className = "dndheaderelement";
nickjillings@1454 882 deleteH.style.width = "50px";
nickjillings@1454 883 var deleteButton = document.createElement("button");
nickjillings@1454 884 deleteButton.textContent = "Del";
nickjillings@1454 885 deleteButton.style.width = "48px";
nickjillings@1454 886 deleteButton.style.padding = "1px 0px";
nickjillings@1454 887 deleteButton.onclick = function()
nickjillings@1454 888 {
nickjillings@1454 889 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 890 var j = i+1;
nickjillings@1454 891 while(j < audioHolder.postTest.options.length)
nickjillings@1454 892 {
nickjillings@1454 893 audioHolder.postTest.options[i] = audioHolder.postTest.options[j];
nickjillings@1454 894 j++;
nickjillings@1454 895 i++;
nickjillings@1454 896 }
nickjillings@1454 897 audioHolder.postTest.options.pop();
nickjillings@1454 898 popupInstance.state = 5;
nickjillings@1454 899 popupInstance.advanceState();
nickjillings@1454 900 };
nickjillings@1454 901 deleteH.appendChild(deleteButton);
nickjillings@1454 902 entry.appendChild(deleteH);
nickjillings@1454 903 postHolder.appendChild(entry);
nickjillings@1454 904 }
nickjillings@1454 905
nickjillings@1454 906 var entry = document.createElement('div');
nickjillings@1454 907 entry.style.width = "456px";
nickjillings@1454 908 entry.style.height= "20px";
nickjillings@1454 909 entry.style.margin= "2px";
nickjillings@1454 910 entry.style.borderBottom = "#DDD";
nickjillings@1454 911 entry.style.borderBottomWidth = "1px";
nickjillings@1454 912 entry.style.borderBottomStyle = "solid";
nickjillings@1454 913 entry.align = "center";
nickjillings@1454 914 var addPost = document.createElement('button');
nickjillings@1454 915 addPost.className = "popupButton";
nickjillings@1454 916 addPost.textContent = "Add New Entry";
nickjillings@1454 917 addPost.style.height = "20px";
nickjillings@1454 918 addPost.onclick = function()
nickjillings@1454 919 {
nickjillings@1454 920 popupInstance.dataTransfer = new function() {
nickjillings@1454 921 this.title = "New Pre Test Node";
nickjillings@1454 922 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].postTest;
nickjillings@1454 923 this.node = null;
nickjillings@1454 924 this.previousState = 5;
nickjillings@1454 925 };
nickjillings@1454 926 popupInstance.advanceState();
nickjillings@1454 927 };
nickjillings@1454 928 entry.appendChild(addPost);
nickjillings@1454 929 postHolder.appendChild(entry);
nickjillings@1454 930
nickjillings@1454 931 var button = document.createElement('button');
nickjillings@1454 932 button.id = 'submit';
nickjillings@1454 933 button.className = "popupButton";
nickjillings@1454 934 button.textContent = "Finish";
nickjillings@1454 935 button.onclick = function(event)
nickjillings@1454 936 {
nickjillings@1454 937 popupInstance.state = 7;
nickjillings@1454 938 popupInstance.advanceState();
nickjillings@1454 939 };
nickjillings@1454 940 this.popupFooter.appendChild(button);
nickjillings@1454 941 button = document.createElement('button');
nickjillings@1454 942 button.id = 'submit';
nickjillings@1454 943 button.className = "popupButton";
nickjillings@1454 944 button.textContent = "Add Another Page";
nickjillings@1454 945 button.onclick = function(event)
nickjillings@1454 946 {
nickjillings@1454 947 popupInstance.state = 3;
nickjillings@1454 948 popupInstance.advanceState();
nickjillings@1454 949 };
nickjillings@1454 950 this.popupFooter.appendChild(button);
nickjillings@1454 951 break;
nickjillings@1454 952 case 6:
nickjillings@1454 953 this.popupTitleText.textContent = this.dataTransfer.title;
nickjillings@1454 954 var span = document.createElement('span');
nickjillings@1454 955 span.textContent = "Select survey settings here";
nickjillings@1454 956 this.popupBody.appendChild(span);
nickjillings@1454 957 var div = document.createElement('div');
nickjillings@1454 958 span = document.createElement("span");
nickjillings@1454 959 span.textContent = "Survey Type";
nickjillings@1454 960 var select = document.createElement("select");
nickjillings@1454 961 select.id="survey-select";
nickjillings@1454 962 var option = document.createElement('option');
nickjillings@1454 963 option.textContent = "Statement";
nickjillings@1454 964 option.value = "statement";
nickjillings@1454 965 select.appendChild(option);
nickjillings@1454 966 option = document.createElement('option');
nickjillings@1454 967 option.textContent = "Question";
nickjillings@1454 968 option.value = "question";
nickjillings@1454 969 select.appendChild(option);
nickjillings@1454 970 option = document.createElement('option');
nickjillings@1454 971 option.textContent = "Number";
nickjillings@1454 972 option.value = "number";
nickjillings@1454 973 select.appendChild(option);
nickjillings@1454 974 option = document.createElement('option');
nickjillings@1454 975 option.textContent = "Radio";
nickjillings@1454 976 option.value = "radio";
nickjillings@1454 977 select.appendChild(option);
nickjillings@1454 978 option = document.createElement('option');
nickjillings@1454 979 option.textContent = "Checkbox";
nickjillings@1454 980 option.value = "checkbox";
nickjillings@1454 981 select.appendChild(option);
nickjillings@1454 982 this.popupBody.appendChild(select);
nickjillings@1454 983 var options = document.createElement('div');
nickjillings@1454 984 options.id = "survey-options";
nickjillings@1454 985 this.popupBody.appendChild(options);
nickjillings@1454 986 var button = document.createElement('button');
nickjillings@1454 987 button.id = 'submit';
nickjillings@1454 988 button.className = "popupButton";
nickjillings@1454 989 button.textContent = "Add";
nickjillings@1454 990 button.onclick = function(event)
nickjillings@1454 991 {
nickjillings@1454 992 var parent = popupInstance.dataTransfer.parent;
nickjillings@1454 993 if (popupInstance.dataTransfer.node == null)
nickjillings@1454 994 {
nickjillings@1454 995 var node = new parent.OptionNode();
nickjillings@1454 996 } else
nickjillings@1454 997 {
nickjillings@1454 998 var node = popupInstance.dataTransfer.node;
nickjillings@1454 999 }
nickjillings@1454 1000 node.type = document.getElementById("survey-select").value;
nickjillings@1454 1001 switch(node.type)
nickjillings@1454 1002 {
nickjillings@1454 1003 case "statement":
nickjillings@1454 1004 node.statement = document.getElementById("statement").value;
nickjillings@1454 1005 break;
nickjillings@1454 1006 case "question":
nickjillings@1454 1007 node.question = document.getElementById("question").value;
nickjillings@1454 1008 node.id = document.getElementById("ID").value;
nickjillings@1454 1009 node.mandatory = document.getElementById("mandatory").checked;
nickjillings@1454 1010 node.boxsize = document.getElementById("boxsize").value;
nickjillings@1454 1011 break;
nickjillings@1454 1012 }
nickjillings@1454 1013 if (popupInstance.dataTransfer.node == null)
nickjillings@1454 1014 {parent.options.push(node);}
nickjillings@1454 1015 popupInstance.state = popupInstance.dataTransfer.previousState;
nickjillings@1454 1016 popupInstance.advanceState();
nickjillings@1454 1017 };
nickjillings@1454 1018 this.popupFooter.appendChild(button);
nickjillings@1454 1019 select.onchange = function()
nickjillings@1454 1020 {
nickjillings@1454 1021 var options = document.getElementById("survey-options");
nickjillings@1454 1022 options.innerHTML = null;
nickjillings@1454 1023 switch(this.value)
nickjillings@1454 1024 {
nickjillings@1454 1025 case "statement":
nickjillings@1454 1026 var span = document.createElement('span');
nickjillings@1454 1027 span.textContent = "Enter Statement";
nickjillings@1454 1028 var tA = document.createElement('textarea');
nickjillings@1454 1029 tA.id = "statement";
nickjillings@1454 1030 tA.style.width = "460px";
nickjillings@1454 1031 tA.style.height = "96px";
nickjillings@1454 1032 if (popupInstance.dataTransfer.node != null)
nickjillings@1454 1033 {tA.value = this.dataTransfer.node.statement;}
nickjillings@1454 1034 options.appendChild(span);
nickjillings@1454 1035 options.appendChild(tA);
nickjillings@1454 1036 break;
nickjillings@1454 1037 case "question":
nickjillings@1454 1038 var span = document.createElement('span');
nickjillings@1454 1039 span.textContent = "Enter Question";
nickjillings@1454 1040 var tA = document.createElement('textarea');
nickjillings@1454 1041 tA.style.width = "460px";
nickjillings@1454 1042 tA.style.height = "54px";
nickjillings@1454 1043 tA.id = "question";
nickjillings@1454 1044 options.appendChild(span);
nickjillings@1454 1045 options.appendChild(tA);
nickjillings@1454 1046 var div = document.createElement('div');
nickjillings@1454 1047 var input = document.createElement('input');
nickjillings@1454 1048 input.id = "ID";
nickjillings@1454 1049 span = document.createElement('span');
nickjillings@1454 1050 span.textContent = "ID:";
nickjillings@1454 1051 div.appendChild(span);
nickjillings@1454 1052 div.appendChild(input);
nickjillings@1454 1053 options.appendChild(div);
nickjillings@1454 1054 div = document.createElement('div');
nickjillings@1454 1055 input = document.createElement('input');
nickjillings@1454 1056 input.type = "checkbox";
nickjillings@1454 1057 input.id = "mandatory";
nickjillings@1454 1058 span = document.createElement('span');
nickjillings@1454 1059 span.textContent = "Mandatory";
nickjillings@1454 1060 div.appendChild(span);
nickjillings@1454 1061 div.appendChild(input);
nickjillings@1454 1062 options.appendChild(div);
nickjillings@1454 1063 div = document.createElement('div');
nickjillings@1454 1064 var boxsize = document.createElement("select");
nickjillings@1454 1065 boxsize.id = "boxsize";
nickjillings@1454 1066 var selOpt = document.createElement("option");
nickjillings@1454 1067 selOpt.value = "normal";
nickjillings@1454 1068 selOpt.textContent = "Normal";
nickjillings@1454 1069 boxsize.appendChild(selOpt);
nickjillings@1454 1070 selOpt = document.createElement("option");
nickjillings@1454 1071 selOpt.value = "small";
nickjillings@1454 1072 selOpt.textContent = "Small";
nickjillings@1454 1073 boxsize.appendChild(selOpt);
nickjillings@1454 1074 selOpt = document.createElement("option");
nickjillings@1454 1075 selOpt.value = "large";
nickjillings@1454 1076 selOpt.textContent = "Large";
nickjillings@1454 1077 boxsize.appendChild(selOpt);
nickjillings@1454 1078 selOpt = document.createElement("option");
nickjillings@1454 1079 selOpt.value = "huge";
nickjillings@1454 1080 selOpt.textContent = "Huge";
nickjillings@1454 1081 boxsize.appendChild(selOpt);
nickjillings@1454 1082 span = document.createElement('span');
nickjillings@1454 1083 span.textContent = "Response Text Area";
nickjillings@1454 1084 div.appendChild(span);
nickjillings@1454 1085 div.appendChild(boxsize);
nickjillings@1454 1086 options.appendChild(div);
nickjillings@1454 1087 if (popupInstance.dataTransfer.node != null)
nickjillings@1454 1088 {
nickjillings@1454 1089 tA.value = popupInstance.dataTransfer.node.question;
nickjillings@1454 1090 document.getElementById("ID").value = popupInstance.dataTransfer.node.id;
nickjillings@1454 1091 document.getElementById("mandatory").value = popupInstance.dataTransfer.node.mandatory;
nickjillings@1454 1092 document.getElementById("boxsize").value = popupInstance.dataTransfer.node.boxsize;
nickjillings@1454 1093 }
nickjillings@1454 1094 break;
nickjillings@1454 1095 case "number":
nickjillings@1454 1096 var span = document.createElement('span');
nickjillings@1454 1097 span.textContent = "Enter Question";
nickjillings@1454 1098 var tA = document.createElement('textarea');
nickjillings@1454 1099 tA.style.width = "460px";
nickjillings@1454 1100 tA.style.height = "54px";
nickjillings@1454 1101 tA.id = "question";
nickjillings@1454 1102 options.appendChild(span);
nickjillings@1454 1103 options.appendChild(tA);
nickjillings@1454 1104 var div = document.createElement('div');
nickjillings@1454 1105 var input = document.createElement('input');
nickjillings@1454 1106 input.id = "ID";
nickjillings@1454 1107 span = document.createElement('span');
nickjillings@1454 1108 span.textContent = "ID:";
nickjillings@1454 1109 div.appendChild(span);
nickjillings@1454 1110 div.appendChild(input);
nickjillings@1454 1111 options.appendChild(div);
nickjillings@1454 1112 div = document.createElement('div');
nickjillings@1454 1113 input = document.createElement('input');
nickjillings@1454 1114 input.type = "checkbox";
nickjillings@1454 1115 input.id = "mandatory";
nickjillings@1454 1116 span = document.createElement('span');
nickjillings@1454 1117 span.textContent = "Mandatory";
nickjillings@1454 1118 div.appendChild(span);
nickjillings@1454 1119 div.appendChild(input);
nickjillings@1454 1120 options.appendChild(div);
nickjillings@1454 1121 div = document.createElement('div');
nickjillings@1454 1122 break;
nickjillings@1454 1123 }
nickjillings@1454 1124 };
nickjillings@1454 1125 if (this.dataTransfer.node != null)
nickjillings@1454 1126 {
nickjillings@1454 1127 select.value = this.dataTransfer.node.type;
nickjillings@1454 1128 }
nickjillings@1454 1129 select.onchange();
nickjillings@1454 1130 break;
nickjillings@1454 1131 case 7:
nickjillings@1454 1132 this.dataTransfer = null;
nickjillings@1454 1133 this.popupTitleText.textContent = "Test Session - Pre/Post Survey";
nickjillings@1454 1134 var span = document.createElement('span');
nickjillings@1454 1135 span.textContent = "Add your pre test session and post test session survey options here";
nickjillings@1454 1136 this.popupBody.appendChild(span);
nickjillings@1454 1137 var preHolder = document.createElement('div');
nickjillings@1454 1138 preHolder.id = "preHolder";
nickjillings@1454 1139 preHolder.style.width = "460px";
nickjillings@1454 1140 preHolder.style.minHeight = "100px";
nickjillings@1454 1141 preHolder.style.maxHeight = "220px";
nickjillings@1454 1142 preHolder.style.overflow = 'auto';
nickjillings@1454 1143 preHolder.style.border = "black";
nickjillings@1454 1144 preHolder.style.borderStyle = "solid";
nickjillings@1454 1145 preHolder.style.borderWidth = "1px";
nickjillings@1454 1146 this.popupBody.appendChild(preHolder);
nickjillings@1454 1147 var preHeaderHolder = document.createElement('div');
nickjillings@1454 1148 preHeaderHolder.style.width = "456px";
nickjillings@1454 1149 preHeaderHolder.style.height= "20px";
nickjillings@1454 1150 preHeaderHolder.style.margin= "2px";
nickjillings@1454 1151 preHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1454 1152 preHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1454 1153 preHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1454 1154 var mvH = document.createElement('div');
nickjillings@1454 1155 mvH.className = "dndheaderelement";
nickjillings@1454 1156 mvH.style.width = "50px";
nickjillings@1454 1157 var text = document.createElement('span');
nickjillings@1454 1158 text.textContent = "Order";
nickjillings@1454 1159 mvH.appendChild(text);
nickjillings@1454 1160 preHeaderHolder.appendChild(mvH);
nickjillings@1454 1161 var idH = document.createElement('div');
nickjillings@1454 1162 idH.className = "dndheaderelement";
nickjillings@1454 1163 idH.style.width = "150px";
nickjillings@1454 1164 text = document.createElement('span');
nickjillings@1454 1165 text.textContent = "ID";
nickjillings@1454 1166 idH.appendChild(text);
nickjillings@1454 1167 preHeaderHolder.appendChild(idH);
nickjillings@1454 1168 var tH = document.createElement('div');
nickjillings@1454 1169 tH.className = "dndheaderelement";
nickjillings@1454 1170 tH.style.width = "150px";
nickjillings@1454 1171 text = document.createElement('span');
nickjillings@1454 1172 text.textContent = "Type";
nickjillings@1454 1173 tH.appendChild(text);
nickjillings@1454 1174 preHeaderHolder.appendChild(tH);
nickjillings@1454 1175 var editH = document.createElement('div');
nickjillings@1454 1176 editH.className = "dndheaderelement";
nickjillings@1454 1177 editH.style.width = "50px";
nickjillings@1454 1178 text = document.createElement('span');
nickjillings@1454 1179 text.textContent = "Edit";
nickjillings@1454 1180 editH.appendChild(text);
nickjillings@1454 1181 preHeaderHolder.appendChild(editH);
nickjillings@1454 1182 var deleteH = document.createElement('div');
nickjillings@1454 1183 deleteH.className = "dndheaderelement";
nickjillings@1454 1184 deleteH.style.width = "50px";
nickjillings@1454 1185 text = document.createElement('span');
nickjillings@1454 1186 text.textContent = "Delete";
nickjillings@1454 1187 deleteH.appendChild(text);
nickjillings@1454 1188 preHeaderHolder.appendChild(deleteH);
nickjillings@1454 1189 preHolder.appendChild(preHeaderHolder);
nickjillings@1454 1190
nickjillings@1454 1191
nickjillings@1454 1192 for (var i=0; i<specificationNode.preTest.options.length; i++)
nickjillings@1454 1193 {
nickjillings@1454 1194 var optionNode = specificationNode.preTest.options[i];
nickjillings@1454 1195 var entry = document.createElement('div');
nickjillings@1454 1196 entry.style.width = "456px";
nickjillings@1454 1197 entry.style.height= "20px";
nickjillings@1454 1198 entry.style.margin= "2px";
nickjillings@1454 1199 entry.style.borderBottom = "#DDD";
nickjillings@1454 1200 entry.style.borderBottomWidth = "1px";
nickjillings@1454 1201 entry.style.borderBottomStyle = "solid";
nickjillings@1454 1202 entry.setAttribute("node-id",i);
nickjillings@1454 1203 var node = specificationNode.preTest.options[i];
nickjillings@1454 1204 var mvH = document.createElement('div');
nickjillings@1454 1205 mvH.className = "dndheaderelement";
nickjillings@1454 1206 mvH.style.width = "50px";
nickjillings@1454 1207 var mvup = document.createElement("button");
nickjillings@1454 1208 mvup.textContent = "Up";
nickjillings@1454 1209 mvup.style.width = "25px";
nickjillings@1454 1210 mvup.style.padding = "1px 0px";
nickjillings@1454 1211 mvup.onclick = function()
nickjillings@1454 1212 {
nickjillings@1454 1213 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 1214 if (i != 0)
nickjillings@1454 1215 {
nickjillings@1454 1216 var next = specificationNode.preTest.options[i-1];
nickjillings@1454 1217 var cur = specificationNode.preTest.options[i];
nickjillings@1454 1218 specificationNode.preTest.options[i-1] = cur;
nickjillings@1454 1219 specificationNode.preTest.options[i] = next;
nickjillings@1454 1220 popupInstance.state = 7;
nickjillings@1454 1221 popupInstance.advanceState();
nickjillings@1454 1222 }
nickjillings@1454 1223 };
nickjillings@1454 1224 mvH.appendChild(mvup);
nickjillings@1454 1225 var mvdn = document.createElement("button");
nickjillings@1454 1226 mvdn.textContent = "Dn";
nickjillings@1454 1227 mvdn.style.width = "25px";
nickjillings@1454 1228 mvdn.style.padding = "1px 0px";
nickjillings@1454 1229 mvdn.onclick = function()
nickjillings@1454 1230 {
nickjillings@1454 1231 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 1232 if (i != specificationNode.preTest.options.length-1)
nickjillings@1454 1233 {
nickjillings@1454 1234 var next = specificationNode.preTest.options[i+1];
nickjillings@1454 1235 var cur = specificationNode.preTest.options[i];
nickjillings@1454 1236 specificationNode.preTest.options[i+1] = cur;
nickjillings@1454 1237 specificationNode.preTest.options[i] = next;
nickjillings@1454 1238 popupInstance.state = 7;
nickjillings@1454 1239 popupInstance.advanceState();
nickjillings@1454 1240 }
nickjillings@1454 1241 };
nickjillings@1454 1242 mvH.appendChild(mvdn);
nickjillings@1454 1243 entry.appendChild(mvH);
nickjillings@1454 1244 var idH = document.createElement('div');
nickjillings@1454 1245 idH.className = "dndheaderelement";
nickjillings@1454 1246 idH.style.width = "150px";
nickjillings@1454 1247 if (optionNode.type != "statement")
nickjillings@1454 1248 {
nickjillings@1454 1249 var span = document.createElement('span');
nickjillings@1454 1250 span.textContent = optionNode.id;
nickjillings@1454 1251 idH.appendChild(span);
nickjillings@1454 1252 }
nickjillings@1454 1253 entry.appendChild(idH);
nickjillings@1454 1254 var typeH = document.createElement('div');
nickjillings@1454 1255 typeH.className = "dndheaderelement";
nickjillings@1454 1256 typeH.style.width = "150px";
nickjillings@1454 1257 var span = document.createElement('span');
nickjillings@1454 1258 span.textContent = optionNode.type;
nickjillings@1454 1259 typeH.appendChild(span);
nickjillings@1454 1260 entry.appendChild(typeH);
nickjillings@1454 1261 var editH = document.createElement('div');
nickjillings@1454 1262 editH.className = "dndheaderelement";
nickjillings@1454 1263 editH.style.width = "50px";
nickjillings@1454 1264 var editButton = document.createElement("button");
nickjillings@1454 1265 editButton.textContent = "Edit";
nickjillings@1454 1266 editButton.style.width = "48px";
nickjillings@1454 1267 editButton.style.padding = "1px 0px";
nickjillings@1454 1268 editButton.onclick = function()
nickjillings@1454 1269 {
nickjillings@1454 1270 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 1271 popupInstance.dataTransfer = new function() {
nickjillings@1454 1272 this.title = "Edit Test Node";
nickjillings@1454 1273 this.parent = specificationNode.preTest;
nickjillings@1454 1274 this.node = this.parent.options[i];
nickjillings@1454 1275 this.previousState = 7;
nickjillings@1454 1276 };
nickjillings@1454 1277 popupInstace.state = 6;
nickjillings@1454 1278 popupInstance.advanceState();
nickjillings@1454 1279 };
nickjillings@1454 1280 editH.appendChild(editButton);
nickjillings@1454 1281 entry.appendChild(editH);
nickjillings@1454 1282 var deleteH = document.createElement('div');
nickjillings@1454 1283 deleteH.className = "dndheaderelement";
nickjillings@1454 1284 deleteH.style.width = "50px";
nickjillings@1454 1285 var deleteButton = document.createElement("button");
nickjillings@1454 1286 deleteButton.textContent = "Del";
nickjillings@1454 1287 deleteButton.style.width = "48px";
nickjillings@1454 1288 deleteButton.style.padding = "1px 0px";
nickjillings@1454 1289 deleteButton.onclick = function()
nickjillings@1454 1290 {
nickjillings@1454 1291 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 1292 var j = i+1;
nickjillings@1454 1293 while(j < specificationNode.preTest.options.length)
nickjillings@1454 1294 {
nickjillings@1454 1295 specificationNode.preTest.options[i] = specificationNode.preTest.options[j];
nickjillings@1454 1296 j++;
nickjillings@1454 1297 i++;
nickjillings@1454 1298 }
nickjillings@1454 1299 specificationNode.preTest.options.pop();
nickjillings@1454 1300 popupInstance.state = 7;
nickjillings@1454 1301 popupInstance.advanceState();
nickjillings@1454 1302 };
nickjillings@1454 1303 deleteH.appendChild(deleteButton);
nickjillings@1454 1304 entry.appendChild(deleteH);
nickjillings@1454 1305 preHolder.appendChild(entry);
nickjillings@1454 1306 }
nickjillings@1454 1307 var entry = document.createElement('div');
nickjillings@1454 1308 entry.style.width = "456px";
nickjillings@1454 1309 entry.style.height= "20px";
nickjillings@1454 1310 entry.style.margin= "2px";
nickjillings@1454 1311 entry.style.borderBottom = "#DDD";
nickjillings@1454 1312 entry.style.borderBottomWidth = "1px";
nickjillings@1454 1313 entry.style.borderBottomStyle = "solid";
nickjillings@1454 1314 entry.align = "center";
nickjillings@1454 1315 var addPre = document.createElement('button');
nickjillings@1454 1316 addPre.className = "popupButton";
nickjillings@1454 1317 addPre.textContent = "Add New Entry";
nickjillings@1454 1318 addPre.style.height = "20px";
nickjillings@1454 1319 addPre.onclick = function()
nickjillings@1454 1320 {
nickjillings@1454 1321 popupInstance.dataTransfer = new function() {
nickjillings@1454 1322 this.title = "New Pre Test Node";
nickjillings@1454 1323 this.parent = specificationNode.preTest;
nickjillings@1454 1324 this.node = null;
nickjillings@1454 1325 this.previousState = 7;
nickjillings@1454 1326 };
nickjillings@1454 1327 popupInstance.state = 6;
nickjillings@1454 1328 popupInstance.advanceState();
nickjillings@1454 1329 };
nickjillings@1454 1330 entry.appendChild(addPre);
nickjillings@1454 1331 preHolder.appendChild(entry);
nickjillings@1454 1332
nickjillings@1454 1333 var span = document.createElement('span');
nickjillings@1454 1334 span.textContent = "Add your post test page options here";
nickjillings@1454 1335 this.popupBody.appendChild(span);
nickjillings@1454 1336 var postHolder = document.createElement('div');
nickjillings@1454 1337 postHolder.id = "preHolder";
nickjillings@1454 1338 postHolder.style.width = "100%";
nickjillings@1454 1339 postHolder.style.minHeight = "100px";
nickjillings@1454 1340 postHolder.style.maxHeight = "220px";
nickjillings@1454 1341 postHolder.style.overflow = 'auto';
nickjillings@1454 1342 postHolder.style.border = "black";
nickjillings@1454 1343 postHolder.style.borderStyle = "solid";
nickjillings@1454 1344 postHolder.style.borderWidth = "1px";
nickjillings@1454 1345 this.popupBody.appendChild(postHolder);
nickjillings@1454 1346 var postHeaderHolder = document.createElement('div');
nickjillings@1454 1347 postHeaderHolder.style.width = "456px";
nickjillings@1454 1348 postHeaderHolder.style.height= "20px";
nickjillings@1454 1349 postHeaderHolder.style.margin= "2px";
nickjillings@1454 1350 postHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1454 1351 postHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1454 1352 postHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1454 1353 var mvH = document.createElement('div');
nickjillings@1454 1354 mvH.className = "dndheaderelement";
nickjillings@1454 1355 mvH.style.width = "50px";
nickjillings@1454 1356 var text = document.createElement('span');
nickjillings@1454 1357 text.textContent = "Order";
nickjillings@1454 1358 mvH.appendChild(text);
nickjillings@1454 1359 postHeaderHolder.appendChild(mvH);
nickjillings@1454 1360 var idH = document.createElement('div');
nickjillings@1454 1361 idH.className = "dndheaderelement";
nickjillings@1454 1362 idH.style.width = "150px";
nickjillings@1454 1363 text = document.createElement('span');
nickjillings@1454 1364 text.textContent = "ID";
nickjillings@1454 1365 idH.appendChild(text);
nickjillings@1454 1366 postHeaderHolder.appendChild(idH);
nickjillings@1454 1367 var tH = document.createElement('div');
nickjillings@1454 1368 tH.className = "dndheaderelement";
nickjillings@1454 1369 tH.style.width = "150px";
nickjillings@1454 1370 text = document.createElement('span');
nickjillings@1454 1371 text.textContent = "Type";
nickjillings@1454 1372 tH.appendChild(text);
nickjillings@1454 1373 postHeaderHolder.appendChild(tH);
nickjillings@1454 1374 var editH = document.createElement('div');
nickjillings@1454 1375 editH.className = "dndheaderelement";
nickjillings@1454 1376 editH.style.width = "50px";
nickjillings@1454 1377 text = document.createElement('span');
nickjillings@1454 1378 text.textContent = "Edit";
nickjillings@1454 1379 editH.appendChild(text);
nickjillings@1454 1380 postHeaderHolder.appendChild(editH);
nickjillings@1454 1381 var deleteH = document.createElement('div');
nickjillings@1454 1382 deleteH.className = "dndheaderelement";
nickjillings@1454 1383 deleteH.style.width = "50px";
nickjillings@1454 1384 text = document.createElement('span');
nickjillings@1454 1385 text.textContent = "Delete";
nickjillings@1454 1386 deleteH.appendChild(text);
nickjillings@1454 1387 postHeaderHolder.appendChild(deleteH);
nickjillings@1454 1388 postHolder.appendChild(postHeaderHolder);
nickjillings@1454 1389
nickjillings@1454 1390 for (var i=0; i<specificationNode.postTest.options.length; i++)
nickjillings@1454 1391 {
nickjillings@1454 1392 var optionNode = specificationNode.postTest.options[i];
nickjillings@1454 1393 var entry = document.createElement('div');
nickjillings@1454 1394 entry.style.width = "456px";
nickjillings@1454 1395 entry.style.height= "20px";
nickjillings@1454 1396 entry.style.margin= "2px";
nickjillings@1454 1397 entry.style.borderBottom = "#DDD";
nickjillings@1454 1398 entry.style.borderBottomWidth = "1px";
nickjillings@1454 1399 entry.style.borderBottomStyle = "solid";
nickjillings@1454 1400 entry.setAttribute("node-id",i);
nickjillings@1454 1401 var node = specificationNode.postTest.options[i];
nickjillings@1454 1402 var mvH = document.createElement('div');
nickjillings@1454 1403 mvH.className = "dndheaderelement";
nickjillings@1454 1404 mvH.style.width = "50px";
nickjillings@1454 1405 var mvup = document.createElement("button");
nickjillings@1454 1406 mvup.textContent = "Up";
nickjillings@1454 1407 mvup.style.width = "25px";
nickjillings@1454 1408 mvup.style.padding = "1px 0px";
nickjillings@1454 1409 mvup.onclick = function()
nickjillings@1454 1410 {
nickjillings@1454 1411 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 1412 if (i != 0)
nickjillings@1454 1413 {
nickjillings@1454 1414 var next = specificationNode.postTest.options[i-1];
nickjillings@1454 1415 var cur = specificationNode.postTest.options[i];
nickjillings@1454 1416 specificationNode.postTest.options[i-1] = cur;
nickjillings@1454 1417 specificationNode.postTest.options[i] = next;
nickjillings@1454 1418 popupInstance.state = 7;
nickjillings@1454 1419 popupInstance.advanceState();
nickjillings@1454 1420 }
nickjillings@1454 1421 };
nickjillings@1454 1422 mvH.appendChild(mvup);
nickjillings@1454 1423 var mvdn = document.createElement("button");
nickjillings@1454 1424 mvdn.textContent = "Dn";
nickjillings@1454 1425 mvdn.style.width = "25px";
nickjillings@1454 1426 mvdn.style.padding = "1px 0px";
nickjillings@1454 1427 mvdn.onclick = function()
nickjillings@1454 1428 {
nickjillings@1454 1429 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 1430 if (i != specificationNode.postTest.options.length-1)
nickjillings@1454 1431 {
nickjillings@1454 1432 var next = specificationNode.postTest.options[i+1];
nickjillings@1454 1433 var cur = specificationNode.postTest.options[i];
nickjillings@1454 1434 specificationNode.postTest.options[i+1] = cur;
nickjillings@1454 1435 specificationNode.postTest.options[i] = next;
nickjillings@1454 1436 popupInstance.state = 7;
nickjillings@1454 1437 popupInstance.advanceState();
nickjillings@1454 1438 }
nickjillings@1454 1439 };
nickjillings@1454 1440 mvH.appendChild(mvdn);
nickjillings@1454 1441 entry.appendChild(mvH);
nickjillings@1454 1442 var idH = document.createElement('div');
nickjillings@1454 1443 idH.className = "dndheaderelement";
nickjillings@1454 1444 idH.style.width = "150px";
nickjillings@1454 1445 if (optionNode.type != "statement")
nickjillings@1454 1446 {
nickjillings@1454 1447 var span = document.createElement('span');
nickjillings@1454 1448 span.textContent = optionNode.id;
nickjillings@1454 1449 idH.appendChild(span);
nickjillings@1454 1450 }
nickjillings@1454 1451 entry.appendChild(idH);
nickjillings@1454 1452 var typeH = document.createElement('div');
nickjillings@1454 1453 typeH.className = "dndheaderelement";
nickjillings@1454 1454 typeH.style.width = "150px";
nickjillings@1454 1455 var span = document.createElement('span');
nickjillings@1454 1456 span.textContent = optionNode.type;
nickjillings@1454 1457 typeH.appendChild(span);
nickjillings@1454 1458 entry.appendChild(typeH);
nickjillings@1454 1459 var editH = document.createElement('div');
nickjillings@1454 1460 editH.className = "dndheaderelement";
nickjillings@1454 1461 editH.style.width = "50px";
nickjillings@1454 1462 var editButton = document.createElement("button");
nickjillings@1454 1463 editButton.textContent = "Edit";
nickjillings@1454 1464 editButton.style.width = "48px";
nickjillings@1454 1465 editButton.style.padding = "1px 0px";
nickjillings@1454 1466 editButton.onclick = function()
nickjillings@1454 1467 {
nickjillings@1454 1468 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 1469 popupInstance.dataTransfer = new function() {
nickjillings@1454 1470 this.title = "Edit Test Node";
nickjillings@1454 1471 this.parent = specificationNode.postTest;
nickjillings@1454 1472 this.node = this.parent.options[i];
nickjillings@1454 1473 this.previousState = 7;
nickjillings@1454 1474 };
nickjillings@1454 1475 popupInstance.state = 6;
nickjillings@1454 1476 popupInstance.advanceState();
nickjillings@1454 1477 };
nickjillings@1454 1478 editH.appendChild(editButton);
nickjillings@1454 1479 entry.appendChild(editH);
nickjillings@1454 1480 var deleteH = document.createElement('div');
nickjillings@1454 1481 deleteH.className = "dndheaderelement";
nickjillings@1454 1482 deleteH.style.width = "50px";
nickjillings@1454 1483 var deleteButton = document.createElement("button");
nickjillings@1454 1484 deleteButton.textContent = "Del";
nickjillings@1454 1485 deleteButton.style.width = "48px";
nickjillings@1454 1486 deleteButton.style.padding = "1px 0px";
nickjillings@1454 1487 deleteButton.onclick = function()
nickjillings@1454 1488 {
nickjillings@1454 1489 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1454 1490 var j = i+1;
nickjillings@1454 1491 while(j < specificationNode.postTest.options.length)
nickjillings@1454 1492 {
nickjillings@1454 1493 specificationNode.postTest.options[i] = specificationNode.postTest.options[j];
nickjillings@1454 1494 j++;
nickjillings@1454 1495 i++;
nickjillings@1454 1496 }
nickjillings@1454 1497 audioHolder.postTest.options.pop();
nickjillings@1454 1498 popupInstance.state = 7;
nickjillings@1454 1499 popupInstance.advanceState();
nickjillings@1454 1500 };
nickjillings@1454 1501 deleteH.appendChild(deleteButton);
nickjillings@1454 1502 entry.appendChild(deleteH);
nickjillings@1454 1503 postHolder.appendChild(entry);
nickjillings@1454 1504 }
nickjillings@1454 1505
nickjillings@1454 1506 var entry = document.createElement('div');
nickjillings@1454 1507 entry.style.width = "456px";
nickjillings@1454 1508 entry.style.height= "20px";
nickjillings@1454 1509 entry.style.margin= "2px";
nickjillings@1454 1510 entry.style.borderBottom = "#DDD";
nickjillings@1454 1511 entry.style.borderBottomWidth = "1px";
nickjillings@1454 1512 entry.style.borderBottomStyle = "solid";
nickjillings@1454 1513 entry.align = "center";
nickjillings@1454 1514 var addPost = document.createElement('button');
nickjillings@1454 1515 addPost.className = "popupButton";
nickjillings@1454 1516 addPost.textContent = "Add New Entry";
nickjillings@1454 1517 addPost.style.height = "20px";
nickjillings@1454 1518 addPost.onclick = function()
nickjillings@1454 1519 {
nickjillings@1454 1520 popupInstance.dataTransfer = new function() {
nickjillings@1454 1521 this.title = "New Pre Test Node";
nickjillings@1454 1522 this.parent = specificationNode.postTest;
nickjillings@1454 1523 this.node = null;
nickjillings@1454 1524 this.previousState = 7;
nickjillings@1454 1525 };
nickjillings@1456 1526 popupInstance.state = 6;
nickjillings@1454 1527 popupInstance.advanceState();
nickjillings@1454 1528 };
nickjillings@1454 1529 entry.appendChild(addPost);
nickjillings@1454 1530 postHolder.appendChild(entry);
nickjillings@1454 1531
nickjillings@1454 1532 var button = document.createElement('button');
nickjillings@1454 1533 button.id = 'submit';
nickjillings@1454 1534 button.className = "popupButton";
nickjillings@1454 1535 button.textContent = "Finish";
nickjillings@1454 1536 button.onclick = function(event)
nickjillings@1454 1537 {
nickjillings@1454 1538 popupInstance.state = 8;
nickjillings@1454 1539 popupInstance.advanceState();
nickjillings@1454 1540 };
nickjillings@1454 1541 this.popupFooter.appendChild(button);
nickjillings@1454 1542 break;
nickjillings@1454 1543 case 8:
nickjillings@1454 1544 this.hidePopup();
nickjillings@1454 1545 this.state = 0;
nickjillings@1404 1546 SpecificationToHTML ();
nickjillings@1594 1547 }
nickjillings@1453 1548 this.state++;
nickjillings@1453 1549 };
nickjillings@1453 1550 };
nickjillings@1453 1551
nickjillings@1454 1552 function audioObject()
nickjillings@1454 1553 {
nickjillings@1454 1554 // Used to hold audio information in buffers for quick playback
nickjillings@1454 1555 this.bufferObject;
nickjillings@1454 1556 this.bufferNode = undefined;
nickjillings@1454 1557 this.state = 0;
nickjillings@1454 1558 this.gain = audioContext.createGain();
nickjillings@1454 1559 this.gain.connect(audioContext.destination);
nickjillings@1454 1560 this.include = true;
nickjillings@1454 1561 this.id = undefined;
nickjillings@1454 1562 this.file = undefined;
nickjillings@1454 1563
nickjillings@1454 1564 this.play = function()
nickjillings@1454 1565 {
nickjillings@1454 1566 if (this.bufferNode != undefined)
nickjillings@1454 1567 {
nickjillings@1454 1568 this.bufferNode.stop(0);
nickjillings@1454 1569 this.bufferNode = undefined;
nickjillings@1594 1570 }
nickjillings@1454 1571 if(this.state == 1)
nickjillings@1454 1572 {
nickjillings@1454 1573 this.bufferNode = audioContext.createBufferSource();
nickjillings@1454 1574 this.bufferNode.connect(this.gain);
nickjillings@1454 1575 this.bufferNode.buffer = this.bufferObject;
nickjillings@1454 1576 this.bufferNode.onended = function(event) {
nickjillings@1454 1577 // Safari does not like using 'this' to reference the calling object!
nickjillings@1454 1578 event.currentTarget = undefined;
nickjillings@1454 1579 };
nickjillings@1454 1580 this.bufferNode.start(audioContext.currentTime);
nickjillings@1454 1581 this.bufferNode.stop(audioContext.currentTime+3);
nickjillings@1454 1582 }
nickjillings@1454 1583 };
nickjillings@1454 1584
nickjillings@1454 1585 this.constructTrack = function(file) {
nickjillings@1454 1586 var reader = new FileReader();
nickjillings@1454 1587 this.file = file;
nickjillings@1454 1588 var audioObj = this;
nickjillings@1454 1589 // Create callback to decode the data asynchronously
nickjillings@1454 1590 reader.onloadend = function() {
nickjillings@1454 1591 audioContext.decodeAudioData(reader.result, function(decodedData) {
nickjillings@1454 1592 audioObj.bufferObject = decodedData;
nickjillings@1454 1593 audioObj.state = 1;
nickjillings@1454 1594 }, function(){});
nickjillings@1454 1595 };
nickjillings@1454 1596 reader.readAsArrayBuffer(file);
nickjillings@1454 1597 };
nickjillings@1454 1598 };
nickjillings@1454 1599
nickjillings@1453 1600 function Specification() {
nickjillings@1453 1601 // Handles the decoding of the project specification XML into a simple JavaScript Object.
nickjillings@1453 1602
nickjillings@1453 1603 this.interfaceType = null;
nickjillings@1453 1604 this.commonInterface = new function()
nickjillings@1453 1605 {
nickjillings@1453 1606 this.options = [];
nickjillings@1453 1607 this.optionNode = function(input)
nickjillings@1453 1608 {
nickjillings@1453 1609 var name = input.getAttribute('name');
nickjillings@1453 1610 this.type = name;
nickjillings@1453 1611 if(this.type == "option")
nickjillings@1453 1612 {
nickjillings@1453 1613 this.name = input.id;
nickjillings@1453 1614 } else if (this.type == "check")
nickjillings@1453 1615 {
nickjillings@1453 1616 this.check = input.id;
nickjillings@1453 1617 }
nickjillings@1453 1618 };
nickjillings@1453 1619 };
nickjillings@1411 1620
nickjillings@1411 1621 this.randomiseOrder = function(input)
nickjillings@1411 1622 {
nickjillings@1411 1623 // This takes an array of information and randomises the order
nickjillings@1411 1624 var N = input.length;
nickjillings@1411 1625
nickjillings@1411 1626 var inputSequence = []; // For safety purposes: keep track of randomisation
nickjillings@1411 1627 for (var counter = 0; counter < N; ++counter)
nickjillings@1411 1628 inputSequence.push(counter) // Fill array
nickjillings@1411 1629 var inputSequenceClone = inputSequence.slice(0);
nickjillings@1411 1630
nickjillings@1411 1631 var holdArr = [];
nickjillings@1411 1632 var outputSequence = [];
nickjillings@1411 1633 for (var n=0; n<N; n++)
nickjillings@1411 1634 {
nickjillings@1411 1635 // First pick a random number
nickjillings@1411 1636 var r = Math.random();
nickjillings@1411 1637 // Multiply and floor by the number of elements left
nickjillings@1411 1638 r = Math.floor(r*input.length);
nickjillings@1411 1639 // Pick out that element and delete from the array
nickjillings@1411 1640 holdArr.push(input.splice(r,1)[0]);
nickjillings@1411 1641 // Do the same with sequence
nickjillings@1411 1642 outputSequence.push(inputSequence.splice(r,1)[0]);
nickjillings@1411 1643 }
nickjillings@1411 1644 console.log(inputSequenceClone.toString()); // print original array to console
nickjillings@1411 1645 console.log(outputSequence.toString()); // print randomised array to console
nickjillings@1411 1646 return holdArr;
nickjillings@1411 1647 };
nickjillings@1453 1648 this.projectReturn = null;
nickjillings@1453 1649 this.randomiseOrder = null;
nickjillings@1453 1650 this.collectMetrics = null;
nickjillings@1453 1651 this.testPages = null;
nickjillings@1453 1652 this.audioHolders = [];
nickjillings@1454 1653 this.metrics = [];
nickjillings@1453 1654
nickjillings@1404 1655 this.decode = function(projectXML) {
nickjillings@1453 1656 // projectXML - DOM Parsed document
nickjillings@1453 1657 this.projectXML = projectXML.childNodes[0];
nickjillings@1453 1658 var setupNode = projectXML.getElementsByTagName('setup')[0];
nickjillings@1453 1659 this.interfaceType = setupNode.getAttribute('interface');
nickjillings@1453 1660 this.projectReturn = setupNode.getAttribute('projectReturn');
nickjillings@1453 1661 this.testPages = setupNode.getAttribute('testPages');
nickjillings@1453 1662 if (setupNode.getAttribute('randomiseOrder') == "true") {
nickjillings@1453 1663 this.randomiseOrder = true;
nickjillings@1453 1664 } else {this.randomiseOrder = false;}
nickjillings@1453 1665 if (setupNode.getAttribute('collectMetrics') == "true") {
nickjillings@1453 1666 this.collectMetrics = true;
nickjillings@1453 1667 } else {this.collectMetrics = false;}
nickjillings@1453 1668 if (isNaN(Number(this.testPages)) || this.testPages == undefined)
nickjillings@1453 1669 {
nickjillings@1453 1670 this.testPages = null;
nickjillings@1453 1671 } else {
nickjillings@1453 1672 this.testPages = Number(this.testPages);
nickjillings@1453 1673 if (this.testPages == 0) {this.testPages = null;}
nickjillings@1453 1674 }
nickjillings@1453 1675 var metricCollection = setupNode.getElementsByTagName('Metric');
nickjillings@1453 1676
nickjillings@1404 1677 var setupPreTestNode = setupNode.getElementsByTagName('PreTest');
nickjillings@1404 1678 if (setupPreTestNode.length != 0)
nickjillings@1404 1679 {
nickjillings@1404 1680 setupPreTestNode = setupPreTestNode[0];
nickjillings@1404 1681 this.preTest.construct(setupPreTestNode);
nickjillings@1404 1682 }
nickjillings@1404 1683
nickjillings@1404 1684 var setupPostTestNode = setupNode.getElementsByTagName('PostTest');
nickjillings@1404 1685 if (setupPostTestNode.length != 0)
nickjillings@1404 1686 {
nickjillings@1404 1687 setupPostTestNode = setupPostTestNode[0];
nickjillings@1404 1688 this.postTest.construct(setupPostTestNode);
nickjillings@1404 1689 }
nickjillings@1453 1690
nickjillings@1453 1691 if (metricCollection.length > 0) {
nickjillings@1453 1692 metricCollection = metricCollection[0].getElementsByTagName('metricEnable');
nickjillings@1453 1693 for (var i=0; i<metricCollection.length; i++) {
nickjillings@1453 1694 this.metrics.push(new this.metricNode(metricCollection[i].textContent));
nickjillings@1453 1695 }
nickjillings@1453 1696 }
nickjillings@1453 1697
nickjillings@1453 1698 var commonInterfaceNode = setupNode.getElementsByTagName('interface');
nickjillings@1453 1699 if (commonInterfaceNode.length > 0) {
nickjillings@1453 1700 commonInterfaceNode = commonInterfaceNode[0];
nickjillings@1453 1701 } else {
nickjillings@1453 1702 commonInterfaceNode = undefined;
nickjillings@1453 1703 }
nickjillings@1453 1704
nickjillings@1453 1705 this.commonInterface = new function() {
nickjillings@1453 1706 this.OptionNode = function(child) {
nickjillings@1453 1707 this.type = child.nodeName;
nickjillings@1453 1708 if (this.type == 'option')
nickjillings@1453 1709 {
nickjillings@1453 1710 this.name = child.getAttribute('name');
nickjillings@1453 1711 }
nickjillings@1453 1712 else if (this.type == 'check') {
nickjillings@1453 1713 this.check = child.getAttribute('name');
nickjillings@1453 1714 if (this.check == 'scalerange') {
nickjillings@1453 1715 this.min = child.getAttribute('min');
nickjillings@1453 1716 this.max = child.getAttribute('max');
nickjillings@1453 1717 if (this.min == null) {this.min = 1;}
nickjillings@1453 1718 else if (Number(this.min) > 1 && this.min != null) {
nickjillings@1453 1719 this.min = Number(this.min)/100;
nickjillings@1453 1720 } else {
nickjillings@1453 1721 this.min = Number(this.min);
nickjillings@1453 1722 }
nickjillings@1453 1723 if (this.max == null) {this.max = 0;}
nickjillings@1453 1724 else if (Number(this.max) > 1 && this.max != null) {
nickjillings@1453 1725 this.max = Number(this.max)/100;
nickjillings@1453 1726 } else {
nickjillings@1453 1727 this.max = Number(this.max);
nickjillings@1453 1728 }
nickjillings@1453 1729 }
nickjillings@1453 1730 } else if (this.type == 'anchor' || this.type == 'reference') {
nickjillings@1453 1731 this.value = Number(child.textContent);
nickjillings@1453 1732 this.enforce = child.getAttribute('enforce');
nickjillings@1453 1733 if (this.enforce == 'true') {this.enforce = true;}
nickjillings@1453 1734 else {this.enforce = false;}
nickjillings@1453 1735 }
nickjillings@1453 1736 };
nickjillings@1453 1737 this.options = [];
nickjillings@1453 1738 if (commonInterfaceNode != undefined) {
nickjillings@1453 1739 var child = commonInterfaceNode.firstElementChild;
nickjillings@1453 1740 while (child != undefined) {
nickjillings@1453 1741 this.options.push(new this.OptionNode(child));
nickjillings@1453 1742 child = child.nextElementSibling;
nickjillings@1453 1743 }
nickjillings@1453 1744 }
nickjillings@1453 1745 };
nickjillings@1453 1746
nickjillings@1453 1747 var audioHolders = projectXML.getElementsByTagName('audioHolder');
nickjillings@1453 1748 for (var i=0; i<audioHolders.length; i++) {
nickjillings@1404 1749 var node = new this.audioHolderNode(this);
nickjillings@1404 1750 node.decode(this,audioHolders[i]);
nickjillings@1404 1751 this.audioHolders.push(node);
nickjillings@1453 1752 }
nickjillings@1453 1753
nickjillings@1453 1754 // New check if we need to randomise the test order
nickjillings@1427 1755 if (this.randomiseOrder && typeof randomiseOrder === "function")
nickjillings@1453 1756 {
nickjillings@1453 1757 this.audioHolders = randomiseOrder(this.audioHolders);
nickjillings@1453 1758 for (var i=0; i<this.audioHolders.length; i++)
nickjillings@1453 1759 {
nickjillings@1453 1760 this.audioHolders[i].presentedId = i;
nickjillings@1453 1761 }
nickjillings@1453 1762 }
nickjillings@1453 1763
nickjillings@1453 1764 if (this.testPages != null || this.testPages != undefined)
nickjillings@1453 1765 {
nickjillings@1453 1766 if (this.testPages > audioHolders.length)
nickjillings@1453 1767 {
nickjillings@1453 1768 console.log('Warning: You have specified '+audioHolders.length+' tests but requested '+this.testPages+' be completed!');
nickjillings@1453 1769 this.testPages = audioHolders.length;
nickjillings@1453 1770 }
nickjillings@1453 1771 var aH = this.audioHolders;
nickjillings@1453 1772 this.audioHolders = [];
nickjillings@1453 1773 for (var i=0; i<this.testPages; i++)
nickjillings@1453 1774 {
nickjillings@1453 1775 this.audioHolders.push(aH[i]);
nickjillings@1453 1776 }
nickjillings@1453 1777 }
nickjillings@1453 1778 };
nickjillings@1453 1779
nickjillings@1476 1780 this.encode = function()
nickjillings@1476 1781 {
nickjillings@1477 1782 var root = document.implementation.createDocument(null,"BrowserEvalProjectDocument");
nickjillings@1476 1783 // First get all the <setup> tag compiled
nickjillings@1477 1784 var setupNode = root.createElement("setup");
nickjillings@1476 1785 setupNode.setAttribute('interface',this.interfaceType);
nickjillings@1476 1786 setupNode.setAttribute('projectReturn',this.projectReturn);
nickjillings@1476 1787 setupNode.setAttribute('randomiseOrder',this.randomiseOrder);
nickjillings@1476 1788 setupNode.setAttribute('collectMetrics',this.collectMetrics);
nickjillings@1476 1789 setupNode.setAttribute('testPages',this.testPages);
nickjillings@1476 1790
nickjillings@1477 1791 var setupPreTest = root.createElement("PreTest");
nickjillings@1476 1792 for (var i=0; i<this.preTest.options.length; i++)
nickjillings@1476 1793 {
nickjillings@1404 1794 setupPreTest.appendChild(this.preTest.options[i].exportXML(root));
nickjillings@1476 1795 }
nickjillings@1476 1796
nickjillings@1477 1797 var setupPostTest = root.createElement("PostTest");
nickjillings@1404 1798 for (var i=0; i<this.postTest.options.length; i++)
nickjillings@1476 1799 {
nickjillings@1404 1800 setupPostTest.appendChild(this.postTest.options[i].exportXML(root));
nickjillings@1476 1801 }
nickjillings@1476 1802
nickjillings@1476 1803 setupNode.appendChild(setupPreTest);
nickjillings@1476 1804 setupNode.appendChild(setupPostTest);
nickjillings@1476 1805
nickjillings@1476 1806 // <Metric> tag
nickjillings@1477 1807 var Metric = root.createElement("Metric");
nickjillings@1476 1808 for (var i=0; i<this.metrics.length; i++)
nickjillings@1476 1809 {
nickjillings@1404 1810 var metricEnable = root.createElement("metricEnable");
nickjillings@1476 1811 metricEnable.textContent = this.metrics[i].enabled;
nickjillings@1476 1812 Metric.appendChild(metricEnable);
nickjillings@1476 1813 }
nickjillings@1476 1814 setupNode.appendChild(Metric);
nickjillings@1476 1815
nickjillings@1476 1816 // <interface> tag
nickjillings@1477 1817 var CommonInterface = root.createElement("interface");
nickjillings@1476 1818 for (var i=0; i<this.commonInterface.options.length; i++)
nickjillings@1476 1819 {
nickjillings@1476 1820 var CIObj = this.commonInterface.options[i];
nickjillings@1404 1821 var CINode = root.createElement(CIObj.type);
nickjillings@1476 1822 if (CIObj.type == "check") {CINode.setAttribute("name",CIObj.check);}
nickjillings@1476 1823 else {CINode.setAttribute("name",CIObj.name);}
nickjillings@1476 1824 CommonInterface.appendChild(CINode);
nickjillings@1476 1825 }
nickjillings@1476 1826 setupNode.appendChild(CommonInterface);
nickjillings@1476 1827
nickjillings@1477 1828 root.getElementsByTagName("BrowserEvalProjectDocument")[0].appendChild(setupNode);
nickjillings@1476 1829 // Time for the <audioHolder> tags
nickjillings@1476 1830 for (var ahIndex = 0; ahIndex < this.audioHolders.length; ahIndex++)
nickjillings@1476 1831 {
nickjillings@1404 1832 var node = this.audioHolders[ahIndex].encode(root);
nickjillings@1404 1833 root.getElementsByTagName("BrowserEvalProjectDocument")[0].appendChild(node);
nickjillings@1476 1834 }
nickjillings@1476 1835 return root;
nickjillings@1476 1836 };
nickjillings@1476 1837
nickjillings@1454 1838 this.prepostNode = function(type) {
nickjillings@1453 1839 this.type = type;
nickjillings@1453 1840 this.options = [];
nickjillings@1453 1841
nickjillings@1454 1842 this.OptionNode = function() {
nickjillings@1453 1843
nickjillings@1454 1844 this.childOption = function() {
nickjillings@1453 1845 this.type = 'option';
nickjillings@1404 1846 this.id = null;
nickjillings@1404 1847 this.name = undefined;
nickjillings@1404 1848 this.text = null;
nickjillings@1453 1849 };
nickjillings@1453 1850
nickjillings@1454 1851 this.type = undefined;
nickjillings@1454 1852 this.id = undefined;
nickjillings@1454 1853 this.mandatory = undefined;
nickjillings@1454 1854 this.question = undefined;
nickjillings@1454 1855 this.statement = undefined;
nickjillings@1454 1856 this.boxsize = undefined;
nickjillings@1454 1857 this.options = [];
nickjillings@1454 1858 this.min = undefined;
nickjillings@1454 1859 this.max = undefined;
nickjillings@1454 1860 this.step = undefined;
nickjillings@1454 1861
nickjillings@1404 1862 this.decode = function(child)
nickjillings@1404 1863 {
nickjillings@1404 1864 this.type = child.nodeName;
nickjillings@1404 1865 if (child.nodeName == "question") {
nickjillings@1404 1866 this.id = child.id;
nickjillings@1404 1867 this.mandatory;
nickjillings@1404 1868 if (child.getAttribute('mandatory') == "true") {this.mandatory = true;}
nickjillings@1404 1869 else {this.mandatory = false;}
nickjillings@1404 1870 this.question = child.textContent;
nickjillings@1404 1871 if (child.getAttribute('boxsize') == null) {
nickjillings@1404 1872 this.boxsize = 'normal';
nickjillings@1404 1873 } else {
nickjillings@1404 1874 this.boxsize = child.getAttribute('boxsize');
nickjillings@1404 1875 }
nickjillings@1404 1876 } else if (child.nodeName == "statement") {
nickjillings@1404 1877 this.statement = child.textContent;
nickjillings@1404 1878 } else if (child.nodeName == "checkbox" || child.nodeName == "radio") {
nickjillings@1404 1879 var element = child.firstElementChild;
nickjillings@1404 1880 this.id = child.id;
nickjillings@1404 1881 if (element == null) {
nickjillings@1404 1882 console.log('Malformed' +child.nodeName+ 'entry');
nickjillings@1404 1883 this.statement = 'Malformed' +child.nodeName+ 'entry';
nickjillings@1404 1884 this.type = 'statement';
nickjillings@1404 1885 } else {
nickjillings@1404 1886 this.options = [];
nickjillings@1404 1887 while (element != null) {
nickjillings@1404 1888 if (element.nodeName == 'statement' && this.statement == undefined){
nickjillings@1404 1889 this.statement = element.textContent;
nickjillings@1404 1890 } else if (element.nodeName == 'option') {
nickjillings@1404 1891 var node = new this.childOption();
nickjillings@1404 1892 node.id = element.id;
nickjillings@1404 1893 node.name = element.getAttribute('name');
nickjillings@1404 1894 node.text = element.textContent;
nickjillings@1404 1895 this.options.push(node);
nickjillings@1404 1896 }
nickjillings@1404 1897 element = element.nextElementSibling;
nickjillings@1404 1898 }
nickjillings@1404 1899 }
nickjillings@1404 1900 } else if (child.nodeName == "number") {
nickjillings@1404 1901 this.statement = child.textContent;
nickjillings@1404 1902 this.id = child.id;
nickjillings@1404 1903 this.min = child.getAttribute('min');
nickjillings@1404 1904 this.max = child.getAttribute('max');
nickjillings@1404 1905 this.step = child.getAttribute('step');
nickjillings@1404 1906 }
nickjillings@1404 1907 };
nickjillings@1404 1908
nickjillings@1477 1909 this.exportXML = function(root)
nickjillings@1476 1910 {
nickjillings@1477 1911 var node = root.createElement(this.type);
nickjillings@1476 1912 switch(this.type)
nickjillings@1476 1913 {
nickjillings@1476 1914 case "statement":
nickjillings@1476 1915 node.textContent = this.statement;
nickjillings@1476 1916 break;
nickjillings@1476 1917 case "question":
nickjillings@1476 1918 node.id = this.id;
nickjillings@1476 1919 node.setAttribute("mandatory",this.mandatory);
nickjillings@1476 1920 node.setAttribute("boxsize",this.boxsize);
nickjillings@1476 1921 node.textContent = this.question;
nickjillings@1476 1922 break;
nickjillings@1476 1923 case "number":
nickjillings@1476 1924 node.id = this.id;
nickjillings@1476 1925 node.setAttribute("mandatory",this.mandatory);
nickjillings@1404 1926 node.setAttribute("min", this.min);
nickjillings@1404 1927 node.setAttribute("max", this.max);
nickjillings@1404 1928 node.setAttribute("step", this.step);
nickjillings@1405 1929 node.textContent = this.statement;
nickjillings@1476 1930 break;
nickjillings@1476 1931 case "checkbox":
nickjillings@1476 1932 node.id = this.id;
nickjillings@1404 1933 var statement = root.createElement("statement");
nickjillings@1476 1934 statement.textContent = this.statement;
nickjillings@1476 1935 node.appendChild(statement);
nickjillings@1476 1936 for (var i=0; i<this.options.length; i++)
nickjillings@1476 1937 {
nickjillings@1404 1938 var option = this.options[i];
nickjillings@1404 1939 var optionNode = root.createElement("option");
nickjillings@1476 1940 optionNode.id = option.id;
nickjillings@1476 1941 optionNode.textContent = option.text;
nickjillings@1404 1942 node.appendChild(optionNode);
nickjillings@1476 1943 }
nickjillings@1476 1944 break;
nickjillings@1476 1945 case "radio":
nickjillings@1476 1946 node.id = this.id;
nickjillings@1404 1947 var statement = root.createElement("statement");
nickjillings@1476 1948 statement.textContent = this.statement;
nickjillings@1476 1949 node.appendChild(statement);
nickjillings@1476 1950 for (var i=0; i<this.options.length; i++)
nickjillings@1476 1951 {
nickjillings@1404 1952 var option = this.options[i];
nickjillings@1404 1953 var optionNode = root.createElement("option");
nickjillings@1404 1954 optionNode.setAttribute("name",option.name);
nickjillings@1476 1955 optionNode.textContent = option.text;
nickjillings@1404 1956 node.appendChild(optionNode);
nickjillings@1476 1957 }
nickjillings@1476 1958 break;
nickjillings@1476 1959 }
nickjillings@1476 1960 return node;
nickjillings@1476 1961 };
nickjillings@1453 1962 };
nickjillings@1404 1963 this.construct = function(Collection)
nickjillings@1404 1964 {
nickjillings@1404 1965 if (Collection.childElementCount != 0) {
nickjillings@1404 1966 var child = Collection.firstElementChild;
nickjillings@1404 1967 var node = new this.OptionNode();
nickjillings@1404 1968 node.decode(child);
nickjillings@1404 1969 this.options.push(node);
nickjillings@1404 1970 while (child.nextElementSibling != null) {
nickjillings@1404 1971 child = child.nextElementSibling;
nickjillings@1404 1972 node = new this.OptionNode();
nickjillings@1404 1973 node.decode(child);
nickjillings@1404 1974 this.options.push(node);
nickjillings@1404 1975 }
nickjillings@1404 1976 }
nickjillings@1404 1977 };
nickjillings@1453 1978 };
nickjillings@1404 1979 this.preTest = new this.prepostNode("pretest");
nickjillings@1404 1980 this.postTest = new this.prepostNode("posttest");
nickjillings@1453 1981
nickjillings@1453 1982 this.metricNode = function(name) {
nickjillings@1453 1983 this.enabled = name;
nickjillings@1453 1984 };
nickjillings@1453 1985
nickjillings@1454 1986 this.audioHolderNode = function(parent) {
nickjillings@1453 1987 this.type = 'audioHolder';
nickjillings@1454 1988 this.presentedId = undefined;
nickjillings@1454 1989 this.id = undefined;
nickjillings@1454 1990 this.hostURL = undefined;
nickjillings@1454 1991 this.sampleRate = undefined;
nickjillings@1454 1992 this.randomiseOrder = undefined;
nickjillings@1454 1993 this.loop = undefined;
nickjillings@1454 1994 this.elementComments = undefined;
nickjillings@1404 1995 this.outsideReference = null;
nickjillings@1404 1996 this.preTest = new parent.prepostNode("pretest");
nickjillings@1404 1997 this.postTest = new parent.prepostNode("pretest");
nickjillings@1454 1998 this.interfaces = [];
nickjillings@1454 1999 this.commentBoxPrefix = "Comment on track";
nickjillings@1454 2000 this.audioElements = [];
nickjillings@1454 2001 this.commentQuestions = [];
nickjillings@1454 2002
nickjillings@1404 2003 this.decode = function(parent,xml)
nickjillings@1404 2004 {
nickjillings@1404 2005 this.presentedId = parent.audioHolders.length;
nickjillings@1404 2006 this.id = xml.id;
nickjillings@1404 2007 this.hostURL = xml.getAttribute('hostURL');
nickjillings@1404 2008 this.sampleRate = xml.getAttribute('sampleRate');
nickjillings@1404 2009 if (xml.getAttribute('randomiseOrder') == "true") {this.randomiseOrder = true;}
nickjillings@1404 2010 else {this.randomiseOrder = false;}
nickjillings@1404 2011 this.repeatCount = xml.getAttribute('repeatCount');
nickjillings@1404 2012 if (xml.getAttribute('loop') == 'true') {this.loop = true;}
nickjillings@1404 2013 else {this.loop == false;}
nickjillings@1404 2014 if (xml.getAttribute('elementComments') == "true") {this.elementComments = true;}
nickjillings@1404 2015 else {this.elementComments = false;}
nickjillings@1404 2016
nickjillings@1404 2017 var setupPreTestNode = xml.getElementsByTagName('PreTest');
nickjillings@1404 2018 if (setupPreTestNode.length != 0)
nickjillings@1404 2019 {
nickjillings@1404 2020 setupPreTestNode = setupPreTestNode[0];
nickjillings@1404 2021 this.preTest.construct(setupPreTestNode);
nickjillings@1404 2022 }
nickjillings@1404 2023
nickjillings@1404 2024 var setupPostTestNode = xml.getElementsByTagName('PostTest');
nickjillings@1404 2025 if (setupPostTestNode.length != 0)
nickjillings@1404 2026 {
nickjillings@1404 2027 setupPostTestNode = setupPostTestNode[0];
nickjillings@1404 2028 this.postTest.construct(setupPostTestNode);
nickjillings@1404 2029 }
nickjillings@1404 2030
nickjillings@1404 2031 var interfaceDOM = xml.getElementsByTagName('interface');
nickjillings@1404 2032 for (var i=0; i<interfaceDOM.length; i++) {
nickjillings@1404 2033 var node = new this.interfaceNode();
nickjillings@1404 2034 node.decode(interfaceDOM[i]);
nickjillings@1404 2035 this.interfaces.push(node);
nickjillings@1404 2036 }
nickjillings@1404 2037 this.commentBoxPrefix = xml.getElementsByTagName('commentBoxPrefix');
nickjillings@1404 2038 if (this.commentBoxPrefix.length != 0) {
nickjillings@1404 2039 this.commentBoxPrefix = this.commentBoxPrefix[0].textContent;
nickjillings@1404 2040 } else {
nickjillings@1404 2041 this.commentBoxPrefix = "Comment on track";
nickjillings@1404 2042 }
nickjillings@1404 2043 var audioElementsDOM = xml.getElementsByTagName('audioElements');
nickjillings@1404 2044 for (var i=0; i<audioElementsDOM.length; i++) {
nickjillings@1404 2045 var node = new this.audioElementNode();
nickjillings@1406 2046 node.decode(this,audioElementsDOM[i]);
nickjillings@1404 2047 if (audioElementsDOM[i].getAttribute('type') == 'outsidereference') {
nickjillings@1404 2048 if (this.outsideReference == null) {
nickjillings@1406 2049 this.outsideReference = node;
nickjillings@1404 2050 } else {
nickjillings@1404 2051 console.log('Error only one audioelement can be of type outsidereference per audioholder');
nickjillings@1404 2052 this.audioElements.push(node);
nickjillings@1404 2053 console.log('Element id '+audioElementsDOM[i].id+' made into normal node');
nickjillings@1404 2054 }
nickjillings@1404 2055 } else {
nickjillings@1404 2056 this.audioElements.push(node);
nickjillings@1404 2057 }
nickjillings@1404 2058 }
nickjillings@1404 2059
nickjillings@1427 2060 if (this.randomiseOrder == true && typeof randomiseOrder === "function")
nickjillings@1411 2061 {
nickjillings@1411 2062 this.audioElements = randomiseOrder(this.audioElements);
nickjillings@1411 2063 }
nickjillings@1411 2064
nickjillings@1404 2065 var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion');
nickjillings@1404 2066 for (var i=0; i<commentQuestionsDOM.length; i++) {
nickjillings@1404 2067 var node = new this.commentQuestionNode();
nickjillings@1404 2068 node.decode(commentQuestionsDOM[i]);
nickjillings@1404 2069 this.commentQuestions.push(node);
nickjillings@1453 2070 }
nickjillings@1453 2071 };
nickjillings@1453 2072
nickjillings@1404 2073 this.encode = function(root)
nickjillings@1404 2074 {
nickjillings@1404 2075 var AHNode = root.createElement("audioHolder");
nickjillings@1404 2076 AHNode.id = this.id;
nickjillings@1404 2077 AHNode.setAttribute("hostURL",this.hostURL);
nickjillings@1404 2078 AHNode.setAttribute("sampleRate",this.sampleRate);
nickjillings@1404 2079 AHNode.setAttribute("randomiseOrder",this.randomiseOrder);
nickjillings@1404 2080 AHNode.setAttribute("repeatCount",this.repeatCount);
nickjillings@1404 2081 AHNode.setAttribute("loop",this.loop);
nickjillings@1404 2082 AHNode.setAttribute("elementComments",this.elementComments);
nickjillings@1404 2083
nickjillings@1404 2084 for (var i=0; i<this.interfaces.length; i++)
nickjillings@1404 2085 {
nickjillings@1404 2086 AHNode.appendChild(this.interfaces[i].encode(root));
nickjillings@1404 2087 }
nickjillings@1404 2088
nickjillings@1404 2089 for (var i=0; i<this.audioElements.length; i++) {
nickjillings@1404 2090 AHNode.appendChild(this.audioElements[i].encode(root));
nickjillings@1404 2091 }
nickjillings@1404 2092 // Create <CommentQuestion>
nickjillings@1404 2093 for (var i=0; i<this.commentQuestions.length; i++)
nickjillings@1404 2094 {
nickjillings@1404 2095 AHNode.appendChild(this.commentQuestions[i].exportXML(root));
nickjillings@1404 2096 }
nickjillings@1404 2097
nickjillings@1404 2098 // Create <PreTest>
nickjillings@1404 2099 var AHPreTest = root.createElement("PreTest");
nickjillings@1404 2100 for (var i=0; i<this.preTest.options.length; i++)
nickjillings@1404 2101 {
nickjillings@1404 2102 AHPreTest.appendChild(this.preTest.options[i].exportXML(root));
nickjillings@1404 2103 }
nickjillings@1404 2104
nickjillings@1404 2105 var AHPostTest = root.createElement("PostTest");
nickjillings@1404 2106 for (var i=0; i<this.postTest.options.length; i++)
nickjillings@1404 2107 {
nickjillings@1404 2108 AHPostTest.appendChild(this.postTest.options[i].exportXML(root));
nickjillings@1404 2109 }
nickjillings@1404 2110 AHNode.appendChild(AHPreTest);
nickjillings@1404 2111 AHNode.appendChild(AHPostTest);
nickjillings@1404 2112 return AHNode;
nickjillings@1404 2113 };
nickjillings@1404 2114
nickjillings@1404 2115 this.interfaceNode = function() {
nickjillings@1404 2116 this.title = undefined;
nickjillings@1404 2117 this.options = [];
nickjillings@1404 2118 this.scale = [];
nickjillings@1427 2119 this.name = undefined;
nickjillings@1404 2120 this.decode = function(DOM)
nickjillings@1404 2121 {
nickjillings@1404 2122 var title = DOM.getElementsByTagName('title');
nickjillings@1404 2123 if (title.length == 0) {this.title = null;}
nickjillings@1404 2124 else {this.title = title[0].textContent;}
nickjillings@1427 2125 var name = DOM.getAttribute("name");
nickjillings@1427 2126 if (name != undefined) {this.name = name;}
nickjillings@1404 2127 this.options = parent.commonInterface.options;
nickjillings@1404 2128 var scale = DOM.getElementsByTagName('scale');
nickjillings@1404 2129 this.scale = [];
nickjillings@1404 2130 for (var i=0; i<scale.length; i++) {
nickjillings@1404 2131 var arr = [null, null];
nickjillings@1404 2132 arr[0] = scale[i].getAttribute('position');
nickjillings@1404 2133 arr[1] = scale[i].textContent;
nickjillings@1404 2134 this.scale.push(arr);
nickjillings@1404 2135 }
nickjillings@1404 2136 };
nickjillings@1404 2137 this.encode = function(root)
nickjillings@1404 2138 {
nickjillings@1404 2139 var node = root.createElement("interface");
nickjillings@1404 2140 if (this.title != undefined)
nickjillings@1404 2141 {
nickjillings@1404 2142 var title = root.createElement("title");
nickjillings@1404 2143 title.textContent = this.title;
nickjillings@1404 2144 node.appendChild(title);
nickjillings@1404 2145 }
nickjillings@1404 2146 for (var i=0; i<this.options.length; i++)
nickjillings@1404 2147 {
nickjillings@1404 2148 var optionNode = root.createElement(this.options[i].type);
nickjillings@1404 2149 if (this.options[i].type == "option")
nickjillings@1404 2150 {
nickjillings@1404 2151 optionNode.setAttribute("name",this.options[i].name);
nickjillings@1404 2152 } else if (this.options[i].type == "check") {
nickjillings@1404 2153 optionNode.setAttribute("check",this.options[i].check);
nickjillings@1404 2154 } else if (this.options[i].type == "scalerange") {
nickjillings@1404 2155 optionNode.setAttribute("min",this.options[i].min*100);
nickjillings@1404 2156 optionNode.setAttribute("max",this.options[i].max*100);
nickjillings@1404 2157 }
nickjillings@1404 2158 node.appendChild(optionNode);
nickjillings@1404 2159 }
nickjillings@1404 2160 for (var i=0; i<this.scale.length; i++) {
nickjillings@1404 2161 var scale = root.createElement("scale");
nickjillings@1404 2162 scale.setAttribute("position",this.scale[i][0]);
nickjillings@1404 2163 scale.textContent = this.scale[i][1];
nickjillings@1404 2164 node.appendChild(scale);
nickjillings@1404 2165 }
nickjillings@1404 2166 return node;
nickjillings@1404 2167 };
nickjillings@1404 2168 };
nickjillings@1404 2169
nickjillings@1404 2170 this.audioElementNode = function() {
nickjillings@1404 2171 this.url = null;
nickjillings@1404 2172 this.id = null;
nickjillings@1404 2173 this.parent = null;
nickjillings@1454 2174 this.type = "normal";
nickjillings@1404 2175 this.marker = false;
nickjillings@1404 2176 this.enforce = false;
nickjillings@1427 2177 this.gain = 1.0;
nickjillings@1404 2178 this.decode = function(parent,xml)
nickjillings@1404 2179 {
nickjillings@1404 2180 this.url = xml.getAttribute('url');
nickjillings@1404 2181 this.id = xml.id;
nickjillings@1404 2182 this.parent = parent;
nickjillings@1404 2183 this.type = xml.getAttribute('type');
nickjillings@1427 2184 var gain = xml.getAttribute('gain');
nickjillings@1427 2185 if (isNaN(gain) == false && gain != null)
nickjillings@1427 2186 {
nickjillings@1427 2187 this.gain = decibelToLinear(Number(gain));
nickjillings@1427 2188 }
nickjillings@1404 2189 if (this.type == null) {this.type = "normal";}
nickjillings@1404 2190 if (this.type == 'anchor') {this.anchor = true;}
nickjillings@1404 2191 else {this.anchor = false;}
nickjillings@1404 2192 if (this.type == 'reference') {this.reference = true;}
nickjillings@1404 2193 else {this.reference = false;}
nickjillings@1404 2194 if (this.anchor == true || this.reference == true)
nickjillings@1404 2195 {
nickjillings@1404 2196 this.marker = xml.getAttribute('marker');
nickjillings@1404 2197 if (this.marker != undefined)
nickjillings@1404 2198 {
nickjillings@1404 2199 this.marker = Number(this.marker);
nickjillings@1404 2200 if (isNaN(this.marker) == false)
nickjillings@1404 2201 {
nickjillings@1404 2202 if (this.marker > 1)
nickjillings@1404 2203 { this.marker /= 100.0;}
nickjillings@1404 2204 if (this.marker >= 0 && this.marker <= 1)
nickjillings@1404 2205 {
nickjillings@1404 2206 this.enforce = true;
nickjillings@1404 2207 return;
nickjillings@1404 2208 } else {
nickjillings@1404 2209 console.log("ERROR - Marker of audioElement "+this.id+" is not between 0 and 1 (float) or 0 and 100 (integer)!");
nickjillings@1404 2210 console.log("ERROR - Marker not enforced!");
nickjillings@1404 2211 }
nickjillings@1404 2212 } else {
nickjillings@1404 2213 console.log("ERROR - Marker of audioElement "+this.id+" is not a number!");
nickjillings@1404 2214 console.log("ERROR - Marker not enforced!");
nickjillings@1404 2215 }
nickjillings@1404 2216 }
nickjillings@1404 2217 }
nickjillings@1404 2218 };
nickjillings@1404 2219 this.encode = function(root)
nickjillings@1404 2220 {
nickjillings@1404 2221 var AENode = root.createElement("audioElements");
nickjillings@1404 2222 AENode.id = this.id;
nickjillings@1404 2223 AENode.setAttribute("url",this.url);
nickjillings@1404 2224 AENode.setAttribute("type",this.type);
nickjillings@1427 2225 AENode.setAttribute("gain",linearToDecibel(this.gain));
nickjillings@1404 2226 if (this.marker != false)
nickjillings@1404 2227 {
nickjillings@1404 2228 AENode.setAttribute("marker",this.marker*100);
nickjillings@1404 2229 }
nickjillings@1404 2230 return AENode;
nickjillings@1404 2231 };
nickjillings@1453 2232 };
nickjillings@1453 2233
nickjillings@1453 2234 this.commentQuestionNode = function(xml) {
nickjillings@1404 2235 this.id = null;
nickjillings@1404 2236 this.type = undefined;
nickjillings@1404 2237 this.question = undefined;
nickjillings@1404 2238 this.options = [];
nickjillings@1404 2239 this.statement = undefined;
nickjillings@1404 2240
nickjillings@1404 2241 this.childOption = function() {
nickjillings@1404 2242 this.type = 'option';
nickjillings@1404 2243 this.name = null;
nickjillings@1404 2244 this.text = null;
nickjillings@1404 2245 };
nickjillings@1477 2246 this.exportXML = function(root)
nickjillings@1476 2247 {
nickjillings@1477 2248 var CQNode = root.createElement("CommentQuestion");
nickjillings@1476 2249 CQNode.id = this.id;
nickjillings@1476 2250 CQNode.setAttribute("type",this.type);
nickjillings@1476 2251 switch(this.type)
nickjillings@1476 2252 {
nickjillings@1476 2253 case "text":
nickjillings@1476 2254 CQNode.textContent = this.question;
nickjillings@1476 2255 break;
nickjillings@1405 2256 case "radio":
nickjillings@1405 2257 var statement = root.createElement("statement");
nickjillings@1476 2258 statement.textContent = this.statement;
nickjillings@1476 2259 CQNode.appendChild(statement);
nickjillings@1476 2260 for (var i=0; i<this.options.length; i++)
nickjillings@1476 2261 {
nickjillings@1405 2262 var optionNode = root.createElement("option");
nickjillings@1405 2263 optionNode.setAttribute("name",this.options[i].name);
nickjillings@1405 2264 optionNode.textContent = this.options[i].text;
nickjillings@1405 2265 CQNode.appendChild(optionNode);
nickjillings@1405 2266 }
nickjillings@1405 2267 break;
nickjillings@1405 2268 case "checkbox":
nickjillings@1404 2269 var statement = root.createElement("statement");
nickjillings@1404 2270 statement.textContent = this.statement;
nickjillings@1404 2271 CQNode.appendChild(statement);
nickjillings@1404 2272 for (var i=0; i<this.options.length; i++)
nickjillings@1404 2273 {
nickjillings@1404 2274 var optionNode = root.createElement("option");
nickjillings@1476 2275 optionNode.setAttribute("name",this.options[i].name);
nickjillings@1476 2276 optionNode.textContent = this.options[i].text;
nickjillings@1476 2277 CQNode.appendChild(optionNode);
nickjillings@1476 2278 }
nickjillings@1476 2279 break;
nickjillings@1476 2280 }
nickjillings@1476 2281 return CQNode;
nickjillings@1476 2282 };
nickjillings@1404 2283 this.decode = function(xml) {
nickjillings@1404 2284 this.id = xml.id;
nickjillings@1404 2285 if (xml.getAttribute('mandatory') == 'true') {this.mandatory = true;}
nickjillings@1404 2286 else {this.mandatory = false;}
nickjillings@1404 2287 this.type = xml.getAttribute('type');
nickjillings@1404 2288 if (this.type == undefined) {this.type = 'text';}
nickjillings@1404 2289 switch (this.type) {
nickjillings@1404 2290 case 'text':
nickjillings@1404 2291 this.question = xml.textContent;
nickjillings@1404 2292 break;
nickjillings@1404 2293 case 'radio':
nickjillings@1404 2294 var child = xml.firstElementChild;
nickjillings@1404 2295 this.options = [];
nickjillings@1404 2296 while (child != undefined) {
nickjillings@1404 2297 if (child.nodeName == 'statement' && this.statement == undefined) {
nickjillings@1404 2298 this.statement = child.textContent;
nickjillings@1404 2299 } else if (child.nodeName == 'option') {
nickjillings@1404 2300 var node = new this.childOption();
nickjillings@1404 2301 node.name = child.getAttribute('name');
nickjillings@1404 2302 node.text = child.textContent;
nickjillings@1404 2303 this.options.push(node);
nickjillings@1404 2304 }
nickjillings@1404 2305 child = child.nextElementSibling;
nickjillings@1404 2306 }
nickjillings@1404 2307 break;
nickjillings@1404 2308 case 'checkbox':
nickjillings@1404 2309 var child = xml.firstElementChild;
nickjillings@1404 2310 this.options = [];
nickjillings@1404 2311 while (child != undefined) {
nickjillings@1404 2312 if (child.nodeName == 'statement' && this.statement == undefined) {
nickjillings@1404 2313 this.statement = child.textContent;
nickjillings@1404 2314 } else if (child.nodeName == 'option') {
nickjillings@1404 2315 var node = new this.childOption();
nickjillings@1404 2316 node.name = child.getAttribute('name');
nickjillings@1404 2317 node.text = child.textContent;
nickjillings@1404 2318 this.options.push(node);
nickjillings@1404 2319 }
nickjillings@1404 2320 child = child.nextElementSibling;
nickjillings@1404 2321 }
nickjillings@1404 2322 break;
nickjillings@1404 2323 }
nickjillings@1453 2324 };
nickjillings@1453 2325 };
nickjillings@1454 2326 };
nickjillings@1591 2327 }
nickjillings@1591 2328
nickjillings@1427 2329 function linearToDecibel(gain)
nickjillings@1427 2330 {
nickjillings@1427 2331 return 20.0*Math.log10(gain);
nickjillings@1427 2332 }
nickjillings@1427 2333
nickjillings@1427 2334 function decibelToLinear(gain)
nickjillings@1427 2335 {
nickjillings@1427 2336 return Math.pow(10,gain/20.0);
nickjillings@1427 2337 }
nickjillings@1411 2338
nickjillings@1452 2339 function createDeleteNodeButton(node)
nickjillings@1452 2340 {
nickjillings@1452 2341 var button = document.createElement("button");
nickjillings@1452 2342 button.textContent = "Delete";
nickjillings@1452 2343 button.onclick = function(event)
nickjillings@1452 2344 {
nickjillings@1452 2345 var node = event.target.parentElement;
nickjillings@1452 2346 node.parentElement.removeChild(node);
nickjillings@1475 2347 };
nickjillings@1452 2348 return button;
nickjillings@1592 2349 }
nickjillings@1592 2350
nickjillings@1404 2351 function SpecificationToHTML()
nickjillings@1454 2352 {
nickjillings@1454 2353 // Take information from Specification Node and format it into an HTML layout
nickjillings@1454 2354 var destination = document.getElementById("content");
nickjillings@1454 2355 // Setup Header Node
nickjillings@1454 2356 var setupNode = document.createElement("div");
nickjillings@1454 2357 setupNode.className = "topLevel";
nickjillings@1454 2358 setupNode.name = "setup";
nickjillings@1454 2359 var title = document.createElement("h2");
nickjillings@1454 2360 title.textContent = "Setup";
nickjillings@1454 2361 setupNode.appendChild(title);
nickjillings@1454 2362 // Interface Type
nickjillings@1454 2363 var div = document.createElement("div");
nickjillings@1454 2364 div.name = "attributes";
nickjillings@1454 2365 div.style.margin = "5px";
nickjillings@1454 2366 var select = document.createElement("select");
nickjillings@1454 2367 select.id = "interfaceSelect";
nickjillings@1454 2368 select.style.margin = "5px";
nickjillings@1454 2369 var option = document.createElement("option");
nickjillings@1454 2370 option.value = "APE";
nickjillings@1454 2371 option.textContent = "APE";
nickjillings@1454 2372 select.appendChild(option);
nickjillings@1454 2373 option = document.createElement("option");
nickjillings@1454 2374 option.value = "MUSHRA";
nickjillings@1454 2375 option.textContent = "MUSHRA";
nickjillings@1454 2376 select.appendChild(option);
nickjillings@1454 2377 select.value = specificationNode.interfaceType;
nickjillings@1475 2378 select.onchange = function(event)
nickjillings@1475 2379 {
nickjillings@1475 2380 specificationNode.interfaceType = event.currentTarget.value;
nickjillings@1475 2381 };
nickjillings@1454 2382 var span = document.createElement("span");
nickjillings@1454 2383 span.textContent = "Interface Type";
nickjillings@1454 2384 div.appendChild(span);
nickjillings@1454 2385 div.appendChild(select);
nickjillings@1454 2386 // Project Return Attribute
nickjillings@1454 2387 span = document.createElement("span");
nickjillings@1454 2388 span.style.margin = "5px";
nickjillings@1454 2389 span.textContent = "Project Return";
nickjillings@1454 2390 var input = document.createElement("input");
nickjillings@1454 2391 input.value = specificationNode.projectReturn;
nickjillings@1454 2392 input.id = "projectReturn";
nickjillings@1454 2393 input.style.margin = "5px";
nickjillings@1475 2394 input.onchange = function(event) {
nickjillings@1475 2395 specificationNode.projectReturn = event.currentTarget.value;
nickjillings@1475 2396 };
nickjillings@1454 2397 div.appendChild(span);
nickjillings@1454 2398 div.appendChild(input);
nickjillings@1454 2399 // Randomise Order
nickjillings@1454 2400 span = document.createElement("span");
nickjillings@1454 2401 span.textContent = "Randomise Order";
nickjillings@1454 2402 input = document.createElement("input");
nickjillings@1454 2403 input.id = "randomiseOrder";
nickjillings@1454 2404 input.style.margin = "5px";
nickjillings@1454 2405 input.type = "checkbox";
nickjillings@1475 2406 input.checked = specificationNode.randomiseOrder;
nickjillings@1475 2407 input.onchange = function(event) {
nickjillings@1475 2408 specificationNode.randomiseOrder = event.currentTarget.checked;
nickjillings@1475 2409 };
nickjillings@1454 2410 div.appendChild(span);
nickjillings@1454 2411 div.appendChild(input);
nickjillings@1454 2412 setupNode.appendChild(div);
nickjillings@1454 2413
nickjillings@1454 2414 // Now create the common Interface Node
nickjillings@1454 2415 var commonInterface = document.createElement("div");
nickjillings@1454 2416 commonInterface.id = "interface";
nickjillings@1454 2417 commonInterface.className = "SecondLevel";
nickjillings@1454 2418 var title = document.createElement("h3");
nickjillings@1454 2419 title.textContent = "Common Interface";
nickjillings@1454 2420 commonInterface.appendChild(title);
nickjillings@1454 2421 var div = document.createElement("div");
nickjillings@1454 2422 div.name = "attributes";
nickjillings@1454 2423 var interfaceOptions;
nickjillings@1454 2424 var interfaceChecks;
nickjillings@1454 2425 switch(select.value)
nickjillings@1454 2426 {
nickjillings@1454 2427 case "APE":
nickjillings@1454 2428 interfaceOptions = APEInterfaceOptions;
nickjillings@1454 2429 interfaceChecks = APEInterfaceChecks;
nickjillings@1454 2430 break;
nickjillings@1454 2431 case "MUSHRA":
nickjillings@1454 2432 interfaceOptions = MUSHRAInterfaceOptions;
nickjillings@1454 2433 interfaceChecks = MUSHRAInterfaceChecks;
nickjillings@1454 2434 break;
nickjillings@1454 2435 }
nickjillings@1454 2436 for (var i=0; i<interfaceOptions[0].length; i++)
nickjillings@1454 2437 {
nickjillings@1454 2438 var span = document.createElement("span");
nickjillings@1454 2439 span.textContent = interfaceOptions[1][i];
nickjillings@1454 2440 var input = document.createElement("input");
nickjillings@1454 2441 input.type = "checkbox";
nickjillings@1454 2442 input.id = interfaceOptions[0][i];
nickjillings@1475 2443 input.setAttribute("name", "option");
nickjillings@1454 2444 div.appendChild(input);
nickjillings@1454 2445 div.appendChild(span);
nickjillings@1454 2446 commonInterface.appendChild(div);
nickjillings@1454 2447 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
nickjillings@1454 2448 {
nickjillings@1454 2449 if (specificationNode.commonInterface.options[j].name == interfaceOptions[0][i])
nickjillings@1454 2450 {
nickjillings@1454 2451 input.checked = true;
nickjillings@1454 2452 break;
nickjillings@1454 2453 }
nickjillings@1454 2454 }
nickjillings@1475 2455 input.onchange = function(event) {
nickjillings@1475 2456 var id = event.currentTarget.id;
nickjillings@1475 2457 if (event.currentTarget.checked) {
nickjillings@1475 2458 specificationNode.commonInterface.options.push(new specificationNode.commonInterface.optionNode(event.currentTarget));
nickjillings@1475 2459 } else {
nickjillings@1475 2460 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
nickjillings@1475 2461 {
nickjillings@1475 2462 if (specificationNode.commonInterface.options[j].name == event.currentTarget.id)
nickjillings@1475 2463 {
nickjillings@1475 2464 specificationNode.commonInterface.options.splice(j,1);
nickjillings@1475 2465 break;
nickjillings@1475 2466 }
nickjillings@1475 2467 }
nickjillings@1475 2468 }
nickjillings@1475 2469 };
nickjillings@1454 2470 }
nickjillings@1454 2471 for (var i=0; i<interfaceChecks[0].length; i++)
nickjillings@1454 2472 {
nickjillings@1454 2473 var span = document.createElement("span");
nickjillings@1454 2474 span.textContent = interfaceChecks[1][i];
nickjillings@1454 2475 var input = document.createElement("input");
nickjillings@1454 2476 input.type = "checkbox";
nickjillings@1454 2477 input.id = interfaceChecks[0][i];
nickjillings@1475 2478 input.setAttribute("name", "check");
nickjillings@1454 2479 div.appendChild(input);
nickjillings@1454 2480 div.appendChild(span);
nickjillings@1454 2481 commonInterface.appendChild(div);
nickjillings@1454 2482 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
nickjillings@1454 2483 {
nickjillings@1454 2484 if (specificationNode.commonInterface.options[j].check == interfaceChecks[0][i])
nickjillings@1454 2485 {
nickjillings@1454 2486 input.checked = true;
nickjillings@1454 2487 break;
nickjillings@1454 2488 }
nickjillings@1454 2489 }
nickjillings@1475 2490 input.onchange = function(event) {
nickjillings@1475 2491 var id = event.currentTarget.id;
nickjillings@1475 2492 if (event.currentTarget.checked) {
nickjillings@1475 2493 specificationNode.commonInterface.options.push(new specificationNode.commonInterface.optionNode(event.currentTarget));
nickjillings@1475 2494 } else {
nickjillings@1475 2495 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
nickjillings@1475 2496 {
nickjillings@1475 2497 if (specificationNode.commonInterface.options[j].name == event.currentTarget.id)
nickjillings@1475 2498 {
nickjillings@1475 2499 specificationNode.commonInterface.options.splice(j,1);
nickjillings@1475 2500 break;
nickjillings@1475 2501 }
nickjillings@1475 2502 }
nickjillings@1475 2503 }
nickjillings@1475 2504 };
nickjillings@1454 2505 }
nickjillings@1454 2506 setupNode.appendChild(commonInterface);
nickjillings@1454 2507 // Now the Metric Node
nickjillings@1454 2508 var metrics = document.createElement("div");
nickjillings@1454 2509 metrics.id = "metrics";
nickjillings@1454 2510 metrics.className = "SecondLevel";
nickjillings@1454 2511 var title = document.createElement("h3");
nickjillings@1454 2512 title.textContent = "Metric Collections";
nickjillings@1454 2513 metrics.appendChild(title);
nickjillings@1454 2514 var div = document.createElement("div");
nickjillings@1454 2515 div.name = "attributes";
nickjillings@1454 2516 metrics.appendChild(div);
nickjillings@1454 2517 var supportedMetrics;
nickjillings@1454 2518 switch(select.value)
nickjillings@1454 2519 {
nickjillings@1454 2520 case "APE":
nickjillings@1454 2521 supportedMetrics = APEInterfaceMetrics;
nickjillings@1454 2522 break;
nickjillings@1454 2523 case "MUSHRA":
nickjillings@1454 2524 supportedMetrics = MUSHRAInterfaceMetrics;
nickjillings@1454 2525 break;
nickjillings@1454 2526 }
nickjillings@1454 2527
nickjillings@1454 2528 for (var i=0; i<supportedMetrics[0].length; i++)
nickjillings@1454 2529 {
nickjillings@1454 2530 var span = document.createElement("span");
nickjillings@1454 2531 span.textContent = supportedMetrics[1][i];
nickjillings@1454 2532 var input = document.createElement("input");
nickjillings@1454 2533 input.type = "checkbox";
nickjillings@1454 2534 input.id = supportedMetrics[0][i];
nickjillings@1454 2535 div.appendChild(input);
nickjillings@1454 2536 div.appendChild(span);
nickjillings@1454 2537 for (var j=0; j<specificationNode.metrics.length; j++)
nickjillings@1454 2538 {
nickjillings@1454 2539 if (specificationNode.metrics[j].enabled == supportedMetrics[0][i])
nickjillings@1454 2540 {
nickjillings@1454 2541 input.checked = true;
nickjillings@1454 2542 }
nickjillings@1454 2543 }
nickjillings@1475 2544 input.onchange = function(event)
nickjillings@1475 2545 {
nickjillings@1475 2546 if (event.currentTarget.checked) {
nickjillings@1475 2547 specificationNode.metrics.push(new specificationNode.metricNode(event.currentTarget.id));
nickjillings@1475 2548 } else {
nickjillings@1475 2549 for (var j=0; j<specificationNode.metrics.length; j++)
nickjillings@1475 2550 {
nickjillings@1475 2551 if (specificationNode.metrics[j].enabled == event.currentTarget.id)
nickjillings@1475 2552 {
nickjillings@1475 2553 specificationNode.metrics.splice(j,1);
nickjillings@1475 2554 break;
nickjillings@1475 2555 }
nickjillings@1475 2556 }
nickjillings@1475 2557 }
nickjillings@1475 2558 };
nickjillings@1454 2559 }
nickjillings@1454 2560
nickjillings@1454 2561 setupNode.appendChild(metrics);
nickjillings@1454 2562
nickjillings@1454 2563 // Test Session Pre Test
nickjillings@1454 2564 var preTest = document.createElement("div");
nickjillings@1454 2565 preTest.id = "preTest";
nickjillings@1454 2566 preTest.className = "SecondLevel";
nickjillings@1454 2567 var title = document.createElement("h3");
nickjillings@1454 2568 title.textContent = "Pre test Survey";
nickjillings@1454 2569 preTest.appendChild(title);
nickjillings@1454 2570 var div = document.createElement("div");
nickjillings@1454 2571 div.name = "attributes";
nickjillings@1454 2572 for (var j=0; j<specificationNode.preTest.options.length; j++)
nickjillings@1454 2573 {
nickjillings@1454 2574 var node = PPSurveyToHTML(specificationNode.preTest.options[j]);
nickjillings@1454 2575 node.className = "SecondLevel";
nickjillings@1454 2576 node.id = preTest.id+"-"+j;
nickjillings@1475 2577 var del_button = document.createElement("button");
nickjillings@1475 2578 del_button.textContent = "Delete";
nickjillings@1475 2579 del_button.onclick = function(event) {
nickjillings@1475 2580 var node = event.currentTarget.parentElement;
nickjillings@1475 2581 var id = node.id.split("-")[1];
nickjillings@1475 2582 specificationNode.preTest.options.splice(id,1);
nickjillings@1475 2583 node.parentElement.removeChild(node);
nickjillings@1475 2584 };
nickjillings@1475 2585 node.appendChild(del_button);
nickjillings@1454 2586 preTest.appendChild(node);
nickjillings@1454 2587 }
nickjillings@1454 2588 setupNode.appendChild(preTest);
nickjillings@1454 2589
nickjillings@1454 2590 // Test Session Post Test
nickjillings@1454 2591 var postTest = document.createElement("div");
nickjillings@1454 2592 postTest.id = "postTest";
nickjillings@1454 2593 postTest.className = "SecondLevel";
nickjillings@1454 2594 var title = document.createElement("h3");
nickjillings@1454 2595 title.textContent = "Post test Survey";
nickjillings@1454 2596 postTest.appendChild(title);
nickjillings@1454 2597 var div = document.createElement("div");
nickjillings@1454 2598 div.name = "attributes";
nickjillings@1454 2599
nickjillings@1454 2600 for (var j=0; j<specificationNode.postTest.options.length; j++)
nickjillings@1454 2601 {
nickjillings@1454 2602 var node = PPSurveyToHTML(specificationNode.postTest.options[j]);
nickjillings@1454 2603 node.className = "SecondLevel";
nickjillings@1454 2604 node.id = postTest.id+"-"+j;
nickjillings@1475 2605 var del_button = document.createElement("button");
nickjillings@1475 2606 del_button.textContent = "Delete";
nickjillings@1475 2607 del_button.onclick = function(event) {
nickjillings@1475 2608 var node = event.currentTarget.parentElement;
nickjillings@1475 2609 var id = node.id.split("-")[1];
nickjillings@1475 2610 specificationNode.postTest.options.splice(id,1);
nickjillings@1475 2611 node.parentElement.removeChild(node);
nickjillings@1475 2612 };
nickjillings@1475 2613 node.appendChild(del_button);
nickjillings@1454 2614 postTest.appendChild(node);
nickjillings@1454 2615 }
nickjillings@1454 2616
nickjillings@1454 2617 setupNode.appendChild(postTest);
nickjillings@1454 2618
nickjillings@1454 2619 destination.appendChild(setupNode);
nickjillings@1454 2620
nickjillings@1454 2621 // Now we step through the AudioHolders
nickjillings@1454 2622 for (var i=0; i<specificationNode.audioHolders.length; i++)
nickjillings@1454 2623 {
nickjillings@1454 2624 var aH = specificationNode.audioHolders[i];
nickjillings@1454 2625 var aHTML = document.createElement("div");
nickjillings@1454 2626 aHTML.name = "audioHolder";
nickjillings@1475 2627 aHTML.id = "audioHolder-"+i;
nickjillings@1454 2628 aHTML.className = "topLevel";
nickjillings@1452 2629 aHTML.appendChild(createDeleteNodeButton());
nickjillings@1454 2630 destination.appendChild(aHTML);
nickjillings@1454 2631 var title = document.createElement("h2");
nickjillings@1454 2632 title.textContent = "Audio Holder "+aH.id;
nickjillings@1454 2633 aHTML.appendChild(title);
nickjillings@1454 2634 var attributes = document.createElement("div");
nickjillings@1454 2635 attributes.name = "attributes";
nickjillings@1454 2636 aHTML.appendChild(attributes);
nickjillings@1454 2637 var text = document.createElement("span");
nickjillings@1454 2638 text.textContent = "ID: ";
nickjillings@1454 2639 var input = document.createElement("input");
nickjillings@1454 2640 input.id = aHTML.id+"-id";
nickjillings@1454 2641 input.value = aH.id;
nickjillings@1454 2642 input.onchange = function()
nickjillings@1454 2643 {
nickjillings@1475 2644 var IDSplit = event.currentTarget.id.split('-');
nickjillings@1475 2645 var aholderID = IDSplit[0]+"-"+IDSplit[1];
nickjillings@1475 2646 var aholder = document.getElementById(aholderID);
nickjillings@1475 2647 title = aholder.getElementsByTagName("h2")[0];
nickjillings@1475 2648 title.textContent = "Audio Holder "+event.currentTarget.value;
nickjillings@1475 2649 specificationNode.audioHolders[IDSplit[1]].id = event.currentTarget.value;
nickjillings@1454 2650 };
nickjillings@1454 2651 text.style.margin = "5px";
nickjillings@1454 2652 input.style.margin = "5px";
nickjillings@1454 2653 attributes.appendChild(text);
nickjillings@1454 2654 attributes.appendChild(input);
nickjillings@1454 2655 text = document.createElement("span");
nickjillings@1454 2656 text.textContent = "Host URL: ";
nickjillings@1454 2657 input = document.createElement("input");
nickjillings@1454 2658 input.id = aHTML.id+"-hostURL";
nickjillings@1454 2659 input.value = aH.hostURL;
nickjillings@1475 2660 input.onchange = function()
nickjillings@1475 2661 {
nickjillings@1475 2662 var IDSplit = event.currentTarget.id.split('-');
nickjillings@1475 2663 specificationNode.audioHolders[IDSplit[1]].hostURL = event.currentTarget.value;
nickjillings@1475 2664 };
nickjillings@1454 2665 text.style.margin = "5px";
nickjillings@1454 2666 input.style.margin = "5px";
nickjillings@1454 2667 attributes.appendChild(text);
nickjillings@1454 2668 attributes.appendChild(input);
nickjillings@1454 2669 text = document.createElement("span");
nickjillings@1454 2670 text.textContent = "Loop Fragments: ";
nickjillings@1454 2671 input = document.createElement("input");
nickjillings@1454 2672 input.id = aHTML.id+"-loop";
nickjillings@1454 2673 input.type = "checkbox";
nickjillings@1454 2674 input.checked = aH.loop;
nickjillings@1475 2675 input.onchange = function()
nickjillings@1475 2676 {
nickjillings@1475 2677 var IDSplit = event.currentTarget.id.split('-');
nickjillings@1475 2678 specificationNode.audioHolders[IDSplit[1]].loop = event.currentTarget.checked;
nickjillings@1475 2679 };
nickjillings@1454 2680 text.style.margin = "5px";
nickjillings@1454 2681 input.style.margin = "5px";
nickjillings@1454 2682 attributes.appendChild(text);
nickjillings@1454 2683 attributes.appendChild(input);
nickjillings@1454 2684 text = document.createElement("span");
nickjillings@1454 2685 text.textContent = "Randomise Order: ";
nickjillings@1454 2686 input = document.createElement("input");
nickjillings@1454 2687 input.id = aHTML.id+"-randomiseOrder";
nickjillings@1454 2688 input.type = "checkbox";
nickjillings@1454 2689 input.checked = aH.randomiseOrder;
nickjillings@1475 2690 input.onchange = function()
nickjillings@1475 2691 {
nickjillings@1475 2692 var IDSplit = event.currentTarget.id.split('-');
nickjillings@1475 2693 specificationNode.audioHolders[IDSplit[1]].randomiseOrder = event.currentTarget.checked;
nickjillings@1475 2694 };
nickjillings@1454 2695 text.style.margin = "5px";
nickjillings@1454 2696 input.style.margin = "5px";
nickjillings@1454 2697 attributes.appendChild(text);
nickjillings@1454 2698 attributes.appendChild(input);
nickjillings@1454 2699 text = document.createElement("span");
nickjillings@1454 2700 text.textContent = "Show Fragment Comments";
nickjillings@1454 2701 input = document.createElement("input");
nickjillings@1454 2702 input.id = aHTML.id+"-elementComments";
nickjillings@1454 2703 input.type = "checkbox";
nickjillings@1454 2704 input.checked = aH.elementComments;
nickjillings@1475 2705 input.onchange = function()
nickjillings@1475 2706 {
nickjillings@1475 2707 var IDSplit = event.currentTarget.id.split('-');
nickjillings@1475 2708 specificationNode.audioHolders[IDSplit[1]].elementComments = event.currentTarget.checked;
nickjillings@1475 2709 };
nickjillings@1454 2710 text.style.margin = "5px";
nickjillings@1454 2711 input.style.margin = "5px";
nickjillings@1454 2712 attributes.appendChild(text);
nickjillings@1454 2713 attributes.appendChild(input);
nickjillings@1594 2714
nickjillings@1454 2715 // Test Session Pre Test
nickjillings@1454 2716 var preTest = document.createElement("div");
nickjillings@1454 2717 preTest.id = aHTML.id+"-pretest";
nickjillings@1454 2718 preTest.className = "SecondLevel";
nickjillings@1454 2719 var title = document.createElement("h3");
nickjillings@1454 2720 title.textContent = "Pre test Survey";
nickjillings@1454 2721 preTest.appendChild(title);
nickjillings@1454 2722 var div = document.createElement("div");
nickjillings@1454 2723 div.name = "attributes";
nickjillings@1453 2724
nickjillings@1454 2725 for (var j=0; j<aH.preTest.options.length; j++)
nickjillings@1454 2726 {
nickjillings@1454 2727 var node = PPSurveyToHTML(aH.preTest.options[j]);
nickjillings@1454 2728 node.className = "SecondLevel";
nickjillings@1454 2729 node.id = preTest.id+"-"+j;
nickjillings@1475 2730 var button_delete = document.createElement("button");
nickjillings@1475 2731 button_delete.textContent = "Delete";
nickjillings@1475 2732 button_delete.onclick = function(event)
nickjillings@1475 2733 {
nickjillings@1475 2734 var node = event.currentTarget.parentElement;
nickjillings@1475 2735 var IDSplit = node.id.split("-");
nickjillings@1475 2736 var preTest = specificationNode.audioHolders[IDSplit[1]].preTest;
nickjillings@1475 2737 preTest.options.splice(IDSplit[3],1);
nickjillings@1475 2738 node.parentElement.removeChild(node);
nickjillings@1475 2739 };
nickjillings@1475 2740 node.appendChild(button_delete);
nickjillings@1454 2741 preTest.appendChild(node);
nickjillings@1453 2742 }
nickjillings@1453 2743
nickjillings@1454 2744 aHTML.appendChild(preTest);
nickjillings@1454 2745
nickjillings@1454 2746 // Test Session Post Test
nickjillings@1454 2747 var postTest = document.createElement("div");
nickjillings@1454 2748 postTest.id = aHTML.id+"-postTest";
nickjillings@1454 2749 postTest.className = "SecondLevel";
nickjillings@1454 2750 var title = document.createElement("h3");
nickjillings@1454 2751 title.textContent = "Post test Survey";
nickjillings@1454 2752 postTest.appendChild(title);
nickjillings@1454 2753 var div = document.createElement("div");
nickjillings@1454 2754 div.name = "attributes";
nickjillings@1454 2755
nickjillings@1454 2756 for (var j=0; j<aH.postTest.options.length; j++)
nickjillings@1454 2757 {
nickjillings@1454 2758 var node = PPSurveyToHTML(aH.postTest.options[j]);
nickjillings@1454 2759 node.className = "SecondLevel";
nickjillings@1454 2760 node.id = postTest.id+"-"+j;
nickjillings@1475 2761 var button_delete = document.createElement("button");
nickjillings@1475 2762 button_delete.textContent = "Delete";
nickjillings@1475 2763 button_delete.onclick = function(event)
nickjillings@1475 2764 {
nickjillings@1475 2765 var node = event.currentTarget.parentElement;
nickjillings@1475 2766 var IDSplit = node.id.split("-");
nickjillings@1475 2767 var postTest = specificationNode.audioHolders[IDSplit[1]].postTest;
nickjillings@1475 2768 postTest.options.splice(IDSplit[3],1);
nickjillings@1475 2769 node.parentElement.removeChild(node);
nickjillings@1475 2770 };
nickjillings@1475 2771 node.appendChild(button_delete);
nickjillings@1454 2772 postTest.appendChild(node);
nickjillings@1453 2773 }
nickjillings@1453 2774
nickjillings@1454 2775 aHTML.appendChild(postTest);
nickjillings@1454 2776
nickjillings@1454 2777 //Audio Elements
nickjillings@1454 2778 var audioElems = document.createElement("div");
nickjillings@1454 2779 audioElems.id = aHTML.id+"-audioElements";
nickjillings@1454 2780 audioElems.className = "SecondLevel";
nickjillings@1454 2781 var title = document.createElement("h3");
nickjillings@1454 2782 title.textContent = "Audio Elements";
nickjillings@1454 2783 audioElems.appendChild(title);
nickjillings@1428 2784 for (var j=0; j<aH.audioElements.length; j++)
nickjillings@1454 2785 {
nickjillings@1454 2786 var entry = document.createElement("div");
nickjillings@1454 2787 entry.className = "SecondLevel";
nickjillings@1428 2788 entry.id = audioElems.id+"-"+aH.audioElements[j].id;
nickjillings@1454 2789 var text = document.createElement("span");
nickjillings@1454 2790 text.textContent = "ID:";
nickjillings@1454 2791 var input = document.createElement("input");
nickjillings@1454 2792 input.id = entry.id+"-id";
nickjillings@1428 2793 input.value = aH.audioElements[j].id;
nickjillings@1475 2794 input.onchange = function() {
nickjillings@1475 2795 var IDSplit = event.currentTarget.id.split("-");
nickjillings@1475 2796 var ahNode = specificationNode.audioHolders[IDSplit[1]];
nickjillings@1475 2797 ahNode.audioElements[IDSplit[3]].id = event.currentTarget.value;
nickjillings@1475 2798 };
nickjillings@1454 2799 text.style.margin = "5px";
nickjillings@1454 2800 input.style.margin = "5px";
nickjillings@1454 2801 entry.appendChild(text);
nickjillings@1454 2802 entry.appendChild(input);
nickjillings@1454 2803 text = document.createElement("span");
nickjillings@1454 2804 text.textContent = "URL:";
nickjillings@1454 2805 input = document.createElement("input");
nickjillings@1454 2806 input.id = entry.id+"-URL";
nickjillings@1428 2807 input.value = aH.audioElements[j].url;
nickjillings@1475 2808 input.onchange = function() {
nickjillings@1475 2809 var IDSplit = event.currentTarget.id.split("-");
nickjillings@1475 2810 var ahNode = specificationNode.audioHolders[IDSplit[1]];
nickjillings@1475 2811 ahNode.audioElements[IDSplit[3]].url = event.currentTarget.value;
nickjillings@1475 2812 };
nickjillings@1454 2813 text.style.margin = "5px";
nickjillings@1454 2814 input.style.margin = "5px";
nickjillings@1454 2815 entry.appendChild(text);
nickjillings@1454 2816 entry.appendChild(input);
nickjillings@1428 2817 text = document.createElement("span");
nickjillings@1428 2818 text.textContent = "Gain:";
nickjillings@1428 2819 input = document.createElement("input");
nickjillings@1428 2820 input.type = "range";
nickjillings@1428 2821 input.id = entry.id+"-gain";
nickjillings@1428 2822 input.value = aH.audioElements[j].gain;
nickjillings@1428 2823 input.min = -25;
nickjillings@1428 2824 input.max = 6;
nickjillings@1428 2825 input.step = 1;
nickjillings@1428 2826 input.onchange = function() {
nickjillings@1428 2827 var IDSplit = event.currentTarget.id.split("-");
nickjillings@1428 2828 var ahNode = specificationNode.audioHolders[IDSplit[1]];
nickjillings@1428 2829 ahNode.audioElements[IDSplit[3]].gain = decibelToLinear(Number(event.currentTarget.value));
nickjillings@1428 2830 var textRet = document.getElementById(event.currentTarget.id+"-ret");
nickjillings@1428 2831 textRet.textContent = String(event.currentTarget.value)+"dB";
nickjillings@1428 2832 };
nickjillings@1428 2833 var textRet = document.createElement("span");
nickjillings@1428 2834 textRet.textContent = String(linearToDecibel(aH.audioElements[j].gain))+"dB";
nickjillings@1428 2835 textRet.id = entry.id+"-gain-ret";
nickjillings@1428 2836 text.style.margin = "5px";
nickjillings@1428 2837 input.style.margin = "5px";
nickjillings@1428 2838 entry.appendChild(text);
nickjillings@1428 2839 entry.appendChild(input);
nickjillings@1428 2840 entry.appendChild(textRet);
nickjillings@1475 2841 var button_delete = document.createElement("button");
nickjillings@1475 2842 button_delete.textContent = "Delete";
nickjillings@1475 2843 button_delete.onclick = function() {
nickjillings@1475 2844 var node = event.currentTarget.parentElement;
nickjillings@1475 2845 var IDSplit = node.id.split("-");
nickjillings@1475 2846 var ahNode = specificationNode.audioHolders[IDSplit[1]];
nickjillings@1475 2847 ahNode.audioElements.splice(IDSplit[3],1);
nickjillings@1475 2848 node.parentElement.removeChild(node);
nickjillings@1475 2849 };
nickjillings@1475 2850 entry.appendChild(button_delete);
nickjillings@1454 2851 audioElems.appendChild(entry);
nickjillings@1453 2852 }
nickjillings@1454 2853 aHTML.appendChild(audioElems);
nickjillings@1454 2854 }
nickjillings@1454 2855
nickjillings@1454 2856 function PPSurveyToHTML(node)
nickjillings@1454 2857 {
nickjillings@1454 2858 var holder = document.createElement("div");
nickjillings@1454 2859 var title = document.createElement("h4");
nickjillings@1454 2860 holder.appendChild(title);
nickjillings@1454 2861 var attributes = document.createElement("div");
nickjillings@1454 2862 holder.appendChild(attributes);
nickjillings@1454 2863 switch(node.type)
nickjillings@1454 2864 {
nickjillings@1454 2865 case "statement":
nickjillings@1454 2866 title.textContent = "Statement";
nickjillings@1454 2867 var tA = document.createElement("textarea");
nickjillings@1454 2868 attributes.style.height = "150px";
nickjillings@1454 2869 tA.style.width = "500px";
nickjillings@1454 2870 tA.style.height = "100px";
nickjillings@1454 2871 tA.value = node.statement;
nickjillings@1454 2872 attributes.appendChild(tA);
nickjillings@1454 2873 break;
nickjillings@1454 2874 case "question":
nickjillings@1454 2875 title.textContent = "Question";
nickjillings@1454 2876 var text = document.createElement("span");
nickjillings@1454 2877 text.textContent = "ID :";
nickjillings@1454 2878 var input = document.createElement("input");
nickjillings@1454 2879 input.name = "id";
nickjillings@1454 2880 input.value = node.id;
nickjillings@1454 2881 text.style.margin = "5px";
nickjillings@1454 2882 input.style.margin = "5px";
nickjillings@1454 2883 attributes.appendChild(text);
nickjillings@1454 2884 attributes.appendChild(input);
nickjillings@1454 2885 text = document.createElement("span");
nickjillings@1454 2886 text.textContent = "Question";
nickjillings@1454 2887 input = document.createElement("input");
nickjillings@1454 2888 input.name = "question";
nickjillings@1456 2889 input.style.width = "400px";
nickjillings@1454 2890 input.value = node.question;
nickjillings@1454 2891 text.style.margin = "5px";
nickjillings@1454 2892 input.style.margin = "5px";
nickjillings@1454 2893 attributes.appendChild(text);
nickjillings@1454 2894 attributes.appendChild(input);
nickjillings@1454 2895 text = document.createElement("span");
nickjillings@1454 2896 text.textContent = "Mandatory";
nickjillings@1454 2897 input = document.createElement("input");
nickjillings@1454 2898 input.name = "mandatory";
nickjillings@1454 2899 input.type = "checkbox";
nickjillings@1454 2900 input.checked = node.mandatory;
nickjillings@1454 2901 text.style.margin = "5px";
nickjillings@1454 2902 input.style.margin = "5px";
nickjillings@1454 2903 attributes.appendChild(text);
nickjillings@1454 2904 attributes.appendChild(input);
nickjillings@1456 2905 text = document.createElement("span");
nickjillings@1456 2906 text.textContent = "Reply box size";
nickjillings@1456 2907 input = document.createElement("select");
nickjillings@1456 2908 input.name = "boxsize";
nickjillings@1456 2909 var option = document.createElement("option");
nickjillings@1456 2910 option.textContent = "Normal";
nickjillings@1456 2911 option.value = "normal";
nickjillings@1456 2912 input.appendChild(option);
nickjillings@1456 2913 option = document.createElement("option");
nickjillings@1456 2914 option.textContent = "Large";
nickjillings@1456 2915 option.value = "large";
nickjillings@1456 2916 input.appendChild(option);
nickjillings@1456 2917 option = document.createElement("option");
nickjillings@1456 2918 option.textContent = "Small";
nickjillings@1456 2919 option.value = "small";
nickjillings@1456 2920 input.appendChild(option);
nickjillings@1456 2921 option = document.createElement("option");
nickjillings@1456 2922 option.textContent = "Huge";
nickjillings@1456 2923 option.value = "huge";
nickjillings@1456 2924 input.appendChild(option);
nickjillings@1456 2925 text.style.margin = "5px";
nickjillings@1456 2926 input.style.margin = "5px";
nickjillings@1456 2927 attributes.appendChild(text);
nickjillings@1456 2928 attributes.appendChild(input);
nickjillings@1456 2929 input.value = node.boxsize;
nickjillings@1454 2930 break;
nickjillings@1453 2931 }
nickjillings@1454 2932 return holder;
nickjillings@1594 2933 }
nickjillings@1594 2934 }
nickjillings@1476 2935 function exportToXML()
nickjillings@1476 2936 {
nickjillings@1476 2937 var xmlDoc = specificationNode.encode();
nickjillings@1477 2938 var oSerializer = new XMLSerializer();
nickjillings@1477 2939 xmlDoc = oSerializer.serializeToString(xmlDoc);
nickjillings@1755 2940 var parent = document.createElement("div");
nickjillings@1477 2941 var file = [xmlDoc];
nickjillings@1755 2942 var bb = new Blob(file,{type : 'application/xml'});
nickjillings@1755 2943 var dnlk = window.URL.createObjectURL(bb);
nickjillings@1755 2944 var a = document.createElement("a");
nickjillings@1755 2945 a.hidden = '';
nickjillings@1755 2946 a.href = dnlk;
nickjillings@1755 2947 a.download = "save.xml";
nickjillings@1755 2948 a.textContent = "Save File";
nickjillings@1755 2949
nickjillings@1476 2950 popupInstance.showPopup();
nickjillings@1476 2951 popupInstance.popupBody.innerHTML = null;
nickjillings@1476 2952 var body = document.createElement("span");
nickjillings@1476 2953 body.textContent = "Right click and save the file using the link below. Place this file in your WAET directory as 'project.xml' in the example_eval/ directory. Place your media files in the location specified by the Host URL entries. If you wish to review this XML or edit it, refresh this tool and drag your XML document into the page on the welcome screen.";
nickjillings@1476 2954 popupInstance.popupBody.appendChild(body);
nickjillings@1476 2955 popupInstance.popupBody.appendChild(a);
nickjillings@1476 2956 popupInstance.popupTitle.innerHTML = "<span>Thank You</span>";
nickjillings@1756 2957 }
nickjillings@1591 2958 </script>
nickjillings@1591 2959 <style>
nickjillings@1453 2960 div.popup {
nickjillings@1453 2961 width: 500px;
nickjillings@1453 2962 position: absolute;
nickjillings@1453 2963 height: 400px;
nickjillings@1453 2964 background-color: #fff;
nickjillings@1453 2965 border-radius: 10px;
nickjillings@1453 2966 box-shadow: 0px 0px 50px #000;
nickjillings@1453 2967 z-index: 2;
nickjillings@1591 2968 }
nickjillings@1453 2969
nickjillings@1453 2970 button.popupButton {
nickjillings@1453 2971 /* Button for popup window
nickjillings@1453 2972 */
nickjillings@1453 2973 min-width: 50px;
nickjillings@1453 2974 height: 25px;
nickjillings@1453 2975 position: relative;
nickjillings@1453 2976 border-radius: 5px;
nickjillings@1453 2977 border: #444;
nickjillings@1453 2978 border-width: 1px;
nickjillings@1453 2979 border-style: solid;
nickjillings@1453 2980 background-color: #fff;
nickjillings@1453 2981 }
nickjillings@1453 2982
nickjillings@1453 2983 div.dragndrop {
nickjillings@1453 2984 margin-top: 10px;
nickjillings@1453 2985 border:#000000;
nickjillings@1453 2986 border-style: dashed;
nickjillings@1591 2987 border-width: 2px;
nickjillings@1453 2988 }
nickjillings@1453 2989 div.dndheaderelement {
nickjillings@1453 2990 float: left;
nickjillings@1453 2991 height: 100%;
nickjillings@1453 2992 border-right: #DDDDDD;
nickjillings@1453 2993 border-right-width: 1px;
nickjillings@1453 2994 border-right-style: solid;
nickjillings@1453 2995 }
nickjillings@1453 2996 div.dndheaderelement span{
nickjillings@1453 2997 padding-left: 5px;
nickjillings@1453 2998 }
nickjillings@1454 2999
nickjillings@1454 3000 div.topLevel {
nickjillings@1454 3001 border: #000;
nickjillings@1591 3002 border-style: solid;
nickjillings@1454 3003 border-width: 5px;
nickjillings@1454 3004 padding: 10px;
nickjillings@1454 3005 margin: 10px;
nickjillings@1591 3006 }
nickjillings@1454 3007
nickjillings@1454 3008 div.SecondLevel {
nickjillings@1454 3009 border: #000;
nickjillings@1454 3010 border-style: solid;
nickjillings@1454 3011 border-width: 1px;
nickjillings@1454 3012 padding: 10px;
nickjillings@1454 3013 margin: 10px;
nickjillings@1756 3014 }
nickjillings@1591 3015 </style>
nickjillings@1749 3016 </head>
nickjillings@1749 3017
nickjillings@1749 3018 <body>
nickjillings@1475 3019 <div id="export">
nickjillings@1477 3020 <button id="exportToXML" onclick="exportToXML();">Export XML</button>
nickjillings@1756 3021 </div>
nickjillings@1453 3022 <div id="content"></div>
nickjillings@1749 3023 </body>
nickjillings@1749 3024 </html>