annotate test_create/test_create.html @ 1316:279930a008ca

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