annotate test_create/test_create.html @ 319:f73d9333ab0d Dev_main

More test_creators
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Wed, 07 Oct 2015 22:16:06 +0100
parents f46398fdf56c
children d8fd1699f6de
rev   line source
n@156 1 <!DOCTYPE html>
n@156 2 <html lang="en">
n@156 3 <head>
n@156 4 <meta charset="utf-8">
n@156 5
n@156 6 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
n@156 7 Remove this if you use the .htaccess -->
n@156 8 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
n@156 9
n@311 10 <title>WAET: Test Creator</title>
n@156 11
n@156 12 <meta name="viewport" content="width=device-width; initial-scale=1.0">
n@311 13 <script type="text/javascript">
n@157 14
n@311 15 var APEInterfaceOptions = [["playhead","page-count"],["Show the playhead/scrubber bar", "Show test page count"]];
n@311 16 var APEInterfaceChecks = [["fragmentPlayed","fragmentFullPlayback","fragmentMoved","fragmentComments"],["All Fragments Played","All Fragments Played in entirety","All sliders moved","All fragments have comments"]];
n@319 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"]];
n@311 18 var MUSHRAInterfaceOptions = [[],[]];
n@311 19 var MUSHRAInterfaceChecks = [["fragmentPlayed","fragmentMoved","fragmentComments"],["All Fragments Played","All sliders moved","All fragments have comments"]];
n@319 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"]];
n@311 21 var popupInstance;
n@311 22 var specificationNode;
n@311 23 var audioContext;
n@319 24 var audioObjects = [];
n@311 25 window.onload = function()
n@311 26 {
n@311 27 var AudioContext = window.AudioContext || window.webkitAudioContext;
n@311 28 audioContext = new AudioContext;
n@311 29 popupInstance = new popup();
n@311 30 popupInstance.advanceState();
n@311 31 specificationNode = new Specification();
n@157 32 };
n@157 33
n@311 34 function popup()
n@311 35 {
n@311 36 var x = window.innerWidth;
n@311 37 var y = window.innerHeight;
n@311 38 this.popupHolder = document.createElement('div');
n@311 39 this.popupHolder.style.visibility = 'hidden';
n@311 40 this.popupContent = document.createElement('div');
n@311 41 this.popupTitle = document.createElement('div');
n@311 42 this.popupBody = document.createElement('div');
n@311 43 this.popupFooter = document.createElement('div');
n@311 44 this.popupTitleText = document.createElement('span');
n@311 45 this.popupTitle.appendChild(this.popupTitleText);
n@311 46
n@311 47 this.popupHolder.className = "popup";
n@311 48 this.popupHolder.style.left = (x-500)/2 +'px';
n@311 49 this.popupHolder.style.top = (y-400)/2 + 'px';
n@311 50 this.popupContent.style.padding = "20px";
n@311 51 this.popupHolder.appendChild(this.popupContent);
n@311 52
n@311 53 this.popupTitle.style.width = "100%";
n@311 54 this.popupTitle.style.height = "50px";
n@311 55 this.popupTitle.style.fontSize = "xx-large";
n@311 56 this.popupContent.appendChild(this.popupTitle);
n@311 57
n@311 58 this.popupBody.style.width = "100%";
n@311 59 this.popupBody.style.height = "280px";
n@311 60 this.popupContent.appendChild(this.popupBody);
n@311 61
n@311 62 this.popupFooter.style.width = "100%";
n@311 63 this.popupFooter.style.height = "30px";
n@311 64 this.popupContent.appendChild(this.popupFooter);
n@311 65 var body = document.getElementsByTagName('body')[0];
n@311 66 body.appendChild(this.popupHolder);
n@311 67
n@311 68 this.pageBlank = document.createElement('div');
n@311 69 body.appendChild(this.pageBlank);
n@311 70 this.pageBlank.style.width = "100%";
n@311 71 this.pageBlank.style.height = "100%";
n@311 72 this.pageBlank.style.position = "absolute";
n@311 73 this.pageBlank.style.left = "0px";
n@311 74 this.pageBlank.style.top = "0px";
n@311 75 this.pageBlank.style.backgroundColor = "rgba(0,0,0,0.5)";
n@311 76 this.pageBlank.style.visibility = 'hidden';
n@311 77
n@311 78 this.state = 0;
n@319 79 this.dataTransfer = null;
n@311 80
n@311 81 this.showPopup = function()
n@311 82 {
n@311 83 this.popupHolder.style.visibility = 'visible';
n@311 84 this.popupHolder.style.zIndex = "3";
n@311 85 this.pageBlank.style.visibility = 'visible';
n@311 86 this.pageBlank.style.zIndex = "2";
n@311 87 };
n@311 88
n@311 89 this.hidePopup = function()
n@311 90 {
n@311 91 this.popupHolder.style.visibility = 'hidden';
n@311 92 this.popupHolder.style.zIndex = "-1";
n@311 93 this.pageBlank.style.visibility = 'hidden';
n@311 94 this.pageBlank.style.zIndex = "-2";
n@311 95 };
n@311 96
n@311 97 this.init = function()
n@311 98 {
n@311 99 this.popupTitleText.textContent = "Welcome";
n@311 100 var text = document.createElement('span');
n@311 101 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";
n@311 102 var dnd = document.createElement('div');
n@311 103 dnd.style.width = "100%";
n@311 104 dnd.style.height = "50px";
n@311 105 dnd.className = "dragndrop";
n@311 106 this.popupBody.appendChild(text);
n@311 107 this.popupBody.appendChild(dnd);
n@311 108 this.showPopup();
n@311 109
n@311 110 var button = document.createElement('button');
n@311 111 button.className = "popupButton";
n@311 112 button.textContent = "New File";
n@311 113 button.onclick = function(event) {
n@311 114 popupInstance.advanceState();
n@311 115 };
n@311 116 this.popupFooter.appendChild(button);
n@311 117 };
n@311 118
n@311 119 this.advanceState = function()
n@311 120 {
n@311 121 this.popupBody.innerHTML = null;
n@311 122 this.popupFooter.innerHTML = null;
n@311 123 this.popupTitleText.textContent = null;
n@311 124 switch(this.state)
n@311 125 {
n@311 126 case 0:
n@311 127 this.init();
n@311 128 break;
n@311 129 case 1:
n@311 130 this.popupTitleText.textContent = "Test Type";
n@311 131 var text = document.createElement("span");
n@311 132 text.textContent = "What type of test would you like to use. Currently APE (Audio Perceptual Evaluation) and MUSHRA style interfaces are available";
n@311 133 this.popupBody.appendChild(text);
n@311 134 var select = document.createElement("select");
n@311 135 select.id="interface-select";
n@311 136 var opt1 = document.createElement("option");
n@311 137 opt1.value = "APE";
n@311 138 opt1.textContent = "APE";
n@311 139 select.appendChild(opt1);
n@311 140 var opt2 = document.createElement("option");
n@311 141 opt2.value = "MUSHRA";
n@311 142 opt2.textContent = "MUSHRA";
n@311 143 select.appendChild(opt2);
n@311 144 this.popupBody.appendChild(select);
n@311 145
n@311 146 var button = document.createElement('button');
n@311 147 button.className = "popupButton";
n@311 148 button.textContent = "Submit";
n@311 149 button.onclick = function(event) {
n@311 150 var select = document.getElementById("interface-select");
n@311 151 specificationNode.interfaceType = select.value;
n@311 152 specificationNode.collectMetrics = true;
n@311 153 popupInstance.advanceState();
n@311 154 };
n@311 155 this.popupFooter.appendChild(button);
n@311 156 break;
n@311 157 case 2:
n@311 158 this.popupTitleText.textContent = "Test Options";
n@311 159 var holder = document.createElement('div');
n@311 160 holder.style.margin = "5px";
n@311 161 var checkbox = document.createElement('input');
n@311 162 checkbox.type = 'checkbox';
n@311 163 checkbox.id = "Randomise-Page";
n@311 164 var text = document.createElement('span');
n@311 165 text.textContent = "Randomise Page Order";
n@311 166 holder.appendChild(checkbox);
n@311 167 holder.appendChild(text);
n@311 168 this.popupBody.appendChild(holder);
n@311 169 switch(specificationNode.interfaceType)
n@311 170 {
n@311 171 case "APE":
n@311 172 for (var i=0; i<APEInterfaceOptions[0].length; i++)
n@311 173 {
n@311 174 holder = document.createElement('div');
n@311 175 holder.style.margin = "5px";
n@311 176 checkbox = document.createElement('input');
n@311 177 checkbox.type = 'checkbox';
n@311 178 checkbox.setAttribute("name","option");
n@311 179 checkbox.id = APEInterfaceOptions[0][i];
n@311 180 text = document.createElement('span');
n@311 181 text.textContent = APEInterfaceOptions[1][i];
n@311 182 holder.appendChild(checkbox);
n@311 183 holder.appendChild(text);
n@311 184 this.popupBody.appendChild(holder);
n@311 185 }
n@311 186 for (var i=0; i<APEInterfaceChecks[0].length; i++)
n@311 187 {
n@311 188 holder = document.createElement('div');
n@311 189 holder.style.margin = "5px";
n@311 190 checkbox = document.createElement('input');
n@311 191 checkbox.type = 'checkbox';
n@311 192 checkbox.setAttribute("name","check");
n@311 193 checkbox.id = APEInterfaceChecks[0][i];
n@311 194 text = document.createElement('span');
n@311 195 text.textContent = APEInterfaceChecks[1][i];
n@311 196 holder.appendChild(checkbox);
n@311 197 holder.appendChild(text);
n@311 198 this.popupBody.appendChild(holder);
n@311 199 }
n@311 200 break;
n@311 201 case "MUSHRA":
n@311 202 for (var i=0; i<MUSHRAInterfaceOptions[0].length; i++)
n@311 203 {
n@311 204 holder = document.createElement('div');
n@311 205 holder.style.margin = "5px";
n@311 206 checkbox = document.createElement('input');
n@311 207 checkbox.type = 'checkbox';
n@311 208 checkbox.setAttribute("name","option");
n@311 209 checkbox.id = MUSHRAInterfaceOptions[0][i];
n@311 210 text = document.createElement('span');
n@311 211 text.textContent = MUSHRAInterfaceOptions[1][i];
n@311 212 holder.appendChild(checkbox);
n@311 213 holder.appendChild(text);
n@311 214 this.popupBody.appendChild(holder);
n@311 215 }
n@311 216 for (var i=0; i<MUSHRAInterfaceChecks[0].length; i++)
n@311 217 {
n@311 218 holder = document.createElement('div');
n@311 219 holder.style.margin = "5px";
n@311 220 checkbox = document.createElement('input');
n@311 221 checkbox.type = 'checkbox';
n@311 222 checkbox.setAttribute("name","check");
n@311 223 checkbox.id = MUSHRAInterfaceChecks[0][i];
n@311 224 text = document.createElement('span');
n@311 225 text.textContent = MUSHRAInterfaceChecks[1][i];
n@311 226 holder.appendChild(checkbox);
n@311 227 holder.appendChild(text);
n@311 228 this.popupBody.appendChild(holder);
n@311 229 }
n@311 230 }
n@311 231 var button = document.createElement('button');
n@311 232 button.className = "popupButton";
n@311 233 button.textContent = "Submit";
n@311 234 button.onclick = function(event) {
n@311 235 var optHold = popupInstance.popupBody;
n@311 236 var opt = optHold.firstChild;
n@311 237 var input = opt.getElementsByTagName('input')[0];
n@311 238 specificationNode.randomiseOrder = input.checked;
n@311 239 while(opt.nextSibling != null)
n@311 240 {
n@311 241 opt = opt.nextSibling;
n@311 242 input = opt.getElementsByTagName('input')[0];
n@311 243 if (input.checked)
n@311 244 {
n@311 245 specificationNode.commonInterface.options.push(new specificationNode.commonInterface.optionNode(input));
n@311 246 }
n@311 247
n@311 248 }
n@311 249 popupInstance.advanceState();
n@311 250 };
n@311 251 this.popupFooter.appendChild(button);
n@311 252 break;
n@311 253 case 3:
n@319 254 audioObjects = [];
n@311 255 this.popupTitleText.textContent = "Test Page";
n@311 256 var span = document.createElement('span');
n@311 257 span.textContent = "Drag and drop your audio files into the box below to add them to a test page";
n@311 258 this.popupBody.appendChild(span);
n@311 259 var dnd = document.createElement('div');
n@311 260 dnd.id = "audio-holder-drop";
n@311 261 dnd.style.width = "100%";
n@311 262 dnd.style.minHeight = "50px";
n@311 263 dnd.style.maxHeight = "220px";
n@311 264 dnd.style.overflow = 'auto';
n@311 265 dnd.className = "dragndrop";
n@311 266 dnd.ondragover = function(e) {
n@311 267 if(e.preventDefault) {e.preventDefault();}
n@311 268 return false;
n@311 269 };
n@311 270 dnd.ondragenter = function(e) {
n@311 271 if(e.preventDefault) {e.preventDefault();}
n@311 272 return false;
n@311 273 };
n@311 274 dnd.ondrop = function(e) {
n@311 275 if(e.preventDefault) {e.preventDefault();}
n@311 276 var dt = e.dataTransfer;
n@311 277 var body = document.getElementById("audio-holder-drop");
n@311 278 var files = dt.files;
n@311 279 for (var i = 0, f; f = files[i]; i++)
n@311 280 {
n@319 281 var ao = new audioObject();
n@319 282 ao.constructTrack(f);
n@319 283 audioObjects.push(ao);
n@311 284 var dndHeader = document.createElement('div');
n@311 285 dndHeader.style.width = "100%";
n@311 286 dndHeader.style.height = "20px";
n@311 287 dndHeader.style.borderBottom = "#DDD";
n@311 288 dndHeader.style.borderBottomWidth = "1px";
n@311 289 dndHeader.style.borderBottomStyle = "solid";
n@319 290 dndHeader.setAttribute('aoID',audioObjects.length-1);
n@311 291 var dndHInclude = document.createElement('div');
n@311 292 dndHInclude.style.width = "30px";
n@311 293 dndHInclude.className = "dndheaderelement";
n@311 294 var includeCheck = document.createElement('input');
n@311 295 includeCheck.type = "checkbox";
n@311 296 includeCheck.name = "include-check";
n@311 297 includeCheck.checked = true;
n@319 298 includeCheck.onchange = function()
n@319 299 {
n@319 300 var i = event.currentTarget.parentElement.parentElement.getAttribute('aoID');
n@319 301 audioObjects[i].include = event.currentTarget.checked;
n@319 302 };
n@311 303 dndHInclude.appendChild(includeCheck);
n@311 304 dndHeader.appendChild(dndHInclude);
n@311 305 var dndHTitle = document.createElement('div');
n@311 306 dndHTitle.style.width = "180px";
n@311 307 dndHTitle.className = "dndheaderelement";
n@311 308 var text = document.createElement('span');
n@311 309 text.textContent = f.name;
n@311 310 dndHTitle.appendChild(text);
n@311 311 dndHeader.appendChild(dndHTitle);
n@311 312 var dndHID = document.createElement('div');
n@311 313 dndHID.style.width = "100px";
n@311 314 dndHID.className = "dndheaderelement";
n@311 315 var IDInput = document.createElement('input');
n@319 316 IDInput.name = "audio-fragment-ID";
n@311 317 IDInput.value = f.name.split('.')[0];
n@319 318 IDInput.onchange = function()
n@319 319 {
n@319 320 var allIDInput = document.getElementsByName("audio-fragment-ID");
n@319 321 var isCopy = new Array(allIDInput.length);
n@319 322 isCopy.fill(0,0,this.length);
n@319 323 if (allIDInput.length > 1)
n@319 324 {
n@319 325 for (var j=0; j<allIDInput.length; j++)
n@319 326 {
n@319 327 var textCompare1 = allIDInput[j].value;
n@319 328 for (var k=j+1; k<allIDInput.length; k++)
n@319 329 {
n@319 330 var textCompare2 = allIDInput[k].value;
n@319 331 if (textCompare1 == textCompare2)
n@319 332 {
n@319 333 isCopy[j] = 1;
n@319 334 isCopy[k] = 1;
n@319 335 }
n@319 336 }
n@319 337 }
n@319 338 }
n@319 339 var button = document.getElementById('submit');
n@319 340 button.disabled = false;
n@319 341 for (var j=0; j<allIDInput.length; j++)
n@319 342 {
n@319 343 if (isCopy[j] == 1)
n@319 344 {
n@319 345 allIDInput[j].style.backgroundColor = '#F22';
n@319 346 button.disabled = true;
n@319 347 }
n@319 348 else
n@319 349 {
n@319 350 allIDInput[j].style.backgroundColor = '#FFF';
n@319 351 audioObjects[j].id = allIDInput[j].value;
n@319 352 }
n@319 353 }
n@319 354 };
n@311 355 IDInput.style.width = "96px";
n@311 356 dndHID.appendChild(IDInput);
n@311 357 dndHeader.appendChild(dndHID);
n@311 358 var dndHPlay = document.createElement('div');
n@311 359 dndHPlay.style.width = "100px";
n@311 360 dndHPlay.className = "dndheaderelement";
n@319 361 var audio = document.createElement('button');
n@319 362 audio.textContent = 'Play';
n@319 363 audio.className = "popupButton";
n@319 364 audio.style.height = "inherit";
n@319 365 audio.onclick = function()
n@319 366 {
n@319 367 var i = event.currentTarget.parentElement.parentElement.getAttribute('aoID');
n@319 368 audioObjects[i].play();
n@319 369 };
n@311 370 dndHPlay.appendChild(audio);
n@311 371 dndHeader.appendChild(dndHPlay);
n@311 372 dnd.appendChild(dndHeader);
n@319 373 IDInput.onchange();
n@311 374 }
n@311 375 };
n@311 376 var dndHeader = document.createElement('div');
n@311 377 dndHeader.style.width = "100%";
n@311 378 dndHeader.style.height = "15px";
n@311 379 dndHeader.style.borderBottom = "#DDD";
n@311 380 dndHeader.style.borderBottomWidth = "1px";
n@311 381 dndHeader.style.borderBottomStyle = "solid";
n@311 382 var dndHInclude = document.createElement('div');
n@311 383 dndHInclude.style.width = "30px";
n@311 384 dndHInclude.className = "dndheaderelement";
n@311 385 var text = document.createElement('span');
n@311 386 text.textContent = "Inc.";
n@311 387 dndHInclude.appendChild(text);
n@311 388 dndHeader.appendChild(dndHInclude);
n@311 389 var dndHTitle = document.createElement('div');
n@311 390 dndHTitle.style.width = "180px";
n@311 391 dndHTitle.className = "dndheaderelement";
n@311 392 text = document.createElement('span');
n@311 393 text.textContent = "File Name";
n@311 394 dndHTitle.appendChild(text);
n@311 395 dndHeader.appendChild(dndHTitle);
n@311 396 var dndHID = document.createElement('div');
n@311 397 dndHID.style.width = "100px";
n@311 398 dndHID.className = "dndheaderelement";
n@311 399 text = document.createElement('span');
n@311 400 text.textContent = "ID";
n@311 401 dndHID.appendChild(text);
n@311 402 dndHeader.appendChild(dndHID);
n@311 403 var dndHPlay = document.createElement('div');
n@311 404 dndHPlay.style.width = "100px";
n@311 405 dndHPlay.className = "dndheaderelement";
n@311 406 text = document.createElement('span');
n@311 407 text.textContent = "Sample";
n@311 408 dndHPlay.appendChild(text);
n@311 409 dndHeader.appendChild(dndHPlay);
n@311 410 dnd.appendChild(dndHeader);
n@311 411 this.popupBody.appendChild(dnd);
n@311 412 var button = document.createElement('button');
n@319 413 button.id = 'submit';
n@311 414 button.className = "popupButton";
n@311 415 button.textContent = "Submit";
n@311 416 button.onclick = function(event)
n@311 417 {
n@319 418 // Construct the audio-holder nodes;
n@319 419 for (var i=0; i<audioObjects.length; i++)
n@319 420 {
n@319 421 if (!audioObjects[i].include)
n@319 422 {
n@319 423 audioObjects.pop(audioObjects[i]);
n@319 424 }
n@319 425 }
n@319 426 if (audioObjects.length != 0)
n@319 427 {
n@319 428 popupInstance.advanceState();
n@319 429 }
n@311 430 };
n@311 431 this.popupFooter.appendChild(button);
n@319 432 break;
n@319 433 case 4:
n@319 434 this.popupTitleText.textContent = "Test Page - Options";
n@319 435 var span = document.createElement('span');
n@319 436 span.textContent = "Set your test page options here";
n@319 437 this.popupBody.appendChild(span);
n@319 438 var pair = document.createElement('div');
n@319 439 pair.style.margin = '5px';
n@319 440 var text = document.createElement('span');
n@319 441 text.textContent = "Page ID:";
n@319 442 var input = document.createElement('input');
n@319 443 input.value = specificationNode.audioHolders.length;
n@319 444 input.id = "id";
n@319 445 pair.appendChild(text);
n@319 446 pair.appendChild(input);
n@319 447 this.popupBody.appendChild(pair);
n@319 448 pair = document.createElement('div');
n@319 449 pair.style.margin = '5px';
n@319 450 text = document.createElement('span');
n@319 451 text.textContent = "Randomise Fragment Order";
n@319 452 input = document.createElement('input');
n@319 453 input.type = "checkbox";
n@319 454 input.id = "randomiseOrder";
n@319 455 pair.appendChild(input);
n@319 456 pair.appendChild(text);
n@319 457 this.popupBody.appendChild(pair);
n@319 458 pair = document.createElement('div');
n@319 459 pair.style.margin = '5px';
n@319 460 text = document.createElement('span');
n@319 461 text.textContent = "Loop Fragment Playback";
n@319 462 input = document.createElement('input');
n@319 463 input.type = "checkbox";
n@319 464 input.id = "loop";
n@319 465 pair.appendChild(input);
n@319 466 pair.appendChild(text);
n@319 467 this.popupBody.appendChild(pair);
n@319 468 pair = document.createElement('div');
n@319 469 pair.style.margin = '5px';
n@319 470 text = document.createElement('span');
n@319 471 text.textContent = "Show fragment comment boxes";
n@319 472 input = document.createElement('input');
n@319 473 input.type = "checkbox";
n@319 474 input.id = "elementComments";
n@319 475 pair.appendChild(input);
n@319 476 pair.appendChild(text);
n@319 477 this.popupBody.appendChild(pair);
n@319 478 var button = document.createElement('button');
n@319 479 button.id = 'submit';
n@319 480 button.className = "popupButton";
n@319 481 button.textContent = "Next";
n@319 482 button.onclick = function(event)
n@319 483 {
n@319 484 var ah = new specificationNode.audioHolderNode(specificationNode);
n@319 485 ah.id = document.getElementById('id').value;
n@319 486 ah.presentedId = specificationNode.audioHolders.length;
n@319 487 ah.hostURL = ah.id+'/';
n@319 488 ah.randomiseOrder = document.getElementById('randomiseOrder').checked;
n@319 489 ah.loop = document.getElementById('loop').checked;
n@319 490 ah.elementComments = document.getElementById('elementComments').checked;
n@319 491 for (var i=0; i<audioObjects.length; i++)
n@319 492 {
n@319 493 ah.audioElements.push(new ah.audioElementNode(ah,audioObjects[i]));
n@319 494 }
n@319 495 specificationNode.audioHolders.push(ah);
n@319 496 popupInstance.advanceState();
n@319 497 };
n@319 498 this.popupFooter.appendChild(button);
n@319 499 break;
n@319 500 case 5:
n@319 501 this.dataTransfer = null;
n@319 502 this.popupTitleText.textContent = "Test Page - Pre/Post Survey";
n@319 503 var span = document.createElement('span');
n@319 504 span.textContent = "Add your pre test page options here";
n@319 505 this.popupBody.appendChild(span);
n@319 506 var preHolder = document.createElement('div');
n@319 507 preHolder.id = "preHolder";
n@319 508 preHolder.style.width = "460px";
n@319 509 preHolder.style.minHeight = "100px";
n@319 510 preHolder.style.maxHeight = "220px";
n@319 511 preHolder.style.overflow = 'auto';
n@319 512 preHolder.style.border = "black";
n@319 513 preHolder.style.borderStyle = "solid";
n@319 514 preHolder.style.borderWidth = "1px";
n@319 515 this.popupBody.appendChild(preHolder);
n@319 516 var audioHolder = specificationNode.audioHolders[specificationNode.audioHolders.length-1];
n@319 517 var preHeaderHolder = document.createElement('div');
n@319 518 preHeaderHolder.style.width = "456px";
n@319 519 preHeaderHolder.style.height= "20px";
n@319 520 preHeaderHolder.style.margin= "2px";
n@319 521 preHeaderHolder.style.borderBottom = "#DDD";
n@319 522 preHeaderHolder.style.borderBottomWidth = "1px";
n@319 523 preHeaderHolder.style.borderBottomStyle = "solid";
n@319 524 var mvH = document.createElement('div');
n@319 525 mvH.className = "dndheaderelement";
n@319 526 mvH.style.width = "50px";
n@319 527 var text = document.createElement('span');
n@319 528 text.textContent = "Order";
n@319 529 mvH.appendChild(text);
n@319 530 preHeaderHolder.appendChild(mvH);
n@319 531 var idH = document.createElement('div');
n@319 532 idH.className = "dndheaderelement";
n@319 533 idH.style.width = "150px";
n@319 534 text = document.createElement('span');
n@319 535 text.textContent = "ID";
n@319 536 idH.appendChild(text);
n@319 537 preHeaderHolder.appendChild(idH);
n@319 538 var tH = document.createElement('div');
n@319 539 tH.className = "dndheaderelement";
n@319 540 tH.style.width = "150px";
n@319 541 text = document.createElement('span');
n@319 542 text.textContent = "Type";
n@319 543 tH.appendChild(text);
n@319 544 preHeaderHolder.appendChild(tH);
n@319 545 var editH = document.createElement('div');
n@319 546 editH.className = "dndheaderelement";
n@319 547 editH.style.width = "50px";
n@319 548 text = document.createElement('span');
n@319 549 text.textContent = "Edit";
n@319 550 editH.appendChild(text);
n@319 551 preHeaderHolder.appendChild(editH);
n@319 552 var deleteH = document.createElement('div');
n@319 553 deleteH.className = "dndheaderelement";
n@319 554 deleteH.style.width = "50px";
n@319 555 text = document.createElement('span');
n@319 556 text.textContent = "Delete";
n@319 557 deleteH.appendChild(text);
n@319 558 preHeaderHolder.appendChild(deleteH);
n@319 559 preHolder.appendChild(preHeaderHolder);
n@319 560
n@319 561
n@319 562 for (var i=0; i<audioHolder.preTest.options.length; i++)
n@319 563 {
n@319 564 var optionNode = audioHolder.preTest.options[i];
n@319 565 var entry = document.createElement('div');
n@319 566 entry.style.width = "456px";
n@319 567 entry.style.height= "20px";
n@319 568 entry.style.margin= "2px";
n@319 569 entry.style.borderBottom = "#DDD";
n@319 570 entry.style.borderBottomWidth = "1px";
n@319 571 entry.style.borderBottomStyle = "solid";
n@319 572 entry.setAttribute("node-id",i);
n@319 573 var node = audioHolder.preTest.options[i];
n@319 574 var mvH = document.createElement('div');
n@319 575 mvH.className = "dndheaderelement";
n@319 576 mvH.style.width = "50px";
n@319 577 var mvup = document.createElement("button");
n@319 578 mvup.textContent = "Up";
n@319 579 mvup.style.width = "25px";
n@319 580 mvup.style.padding = "1px 0px";
n@319 581 mvup.onclick = function()
n@319 582 {
n@319 583 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 584 if (i != 0)
n@319 585 {
n@319 586 var next = audioHolder.preTest.options[i-1];
n@319 587 var cur = audioHolder.preTest.options[i];
n@319 588 audioHolder.preTest.options[i-1] = cur;
n@319 589 audioHolder.preTest.options[i] = next;
n@319 590 popupInstance.state = 5;
n@319 591 popupInstance.advanceState();
n@319 592 }
n@319 593 };
n@319 594 mvH.appendChild(mvup);
n@319 595 var mvdn = document.createElement("button");
n@319 596 mvdn.textContent = "Dn";
n@319 597 mvdn.style.width = "25px";
n@319 598 mvdn.style.padding = "1px 0px";
n@319 599 mvdn.onclick = function()
n@319 600 {
n@319 601 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 602 if (i != audioHolder.preTest.options.length-1)
n@319 603 {
n@319 604 var next = audioHolder.preTest.options[i+1];
n@319 605 var cur = audioHolder.preTest.options[i];
n@319 606 audioHolder.preTest.options[i+1] = cur;
n@319 607 audioHolder.preTest.options[i] = next;
n@319 608 popupInstance.state = 5;
n@319 609 popupInstance.advanceState();
n@319 610 }
n@319 611 };
n@319 612 mvH.appendChild(mvdn);
n@319 613 entry.appendChild(mvH);
n@319 614 var idH = document.createElement('div');
n@319 615 idH.className = "dndheaderelement";
n@319 616 idH.style.width = "150px";
n@319 617 if (optionNode.type != "statement")
n@319 618 {
n@319 619 var span = document.createElement('span');
n@319 620 span.textContent = optionNode.id;
n@319 621 idH.appendChild(span);
n@319 622 }
n@319 623 entry.appendChild(idH);
n@319 624 var typeH = document.createElement('div');
n@319 625 typeH.className = "dndheaderelement";
n@319 626 typeH.style.width = "150px";
n@319 627 var span = document.createElement('span');
n@319 628 span.textContent = optionNode.type;
n@319 629 typeH.appendChild(span);
n@319 630 entry.appendChild(typeH);
n@319 631 var editH = document.createElement('div');
n@319 632 editH.className = "dndheaderelement";
n@319 633 editH.style.width = "50px";
n@319 634 var editButton = document.createElement("button");
n@319 635 editButton.textContent = "Edit";
n@319 636 editButton.style.width = "48px";
n@319 637 editButton.style.padding = "1px 0px";
n@319 638 editButton.onclick = function()
n@319 639 {
n@319 640 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 641 popupInstance.dataTransfer = new function() {
n@319 642 this.title = "Edit Test Node";
n@319 643 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].preTest;
n@319 644 this.node = this.parent.options[i];
n@319 645 this.previousState = 5;
n@319 646 };
n@319 647 popupInstance.advanceState();
n@319 648 };
n@319 649 editH.appendChild(editButton);
n@319 650 entry.appendChild(editH);
n@319 651 var deleteH = document.createElement('div');
n@319 652 deleteH.className = "dndheaderelement";
n@319 653 deleteH.style.width = "50px";
n@319 654 var deleteButton = document.createElement("button");
n@319 655 deleteButton.textContent = "Del";
n@319 656 deleteButton.style.width = "48px";
n@319 657 deleteButton.style.padding = "1px 0px";
n@319 658 deleteButton.onclick = function()
n@319 659 {
n@319 660 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 661 var j = i+1;
n@319 662 while(j < audioHolder.preTest.options.length)
n@319 663 {
n@319 664 audioHolder.preTest.options[i] = audioHolder.preTest.options[j];
n@319 665 j++;
n@319 666 i++;
n@319 667 }
n@319 668 audioHolder.preTest.options.pop();
n@319 669 popupInstance.state = 5;
n@319 670 popupInstance.advanceState();
n@319 671 };
n@319 672 deleteH.appendChild(deleteButton);
n@319 673 entry.appendChild(deleteH);
n@319 674 preHolder.appendChild(entry);
n@319 675 }
n@319 676 var entry = document.createElement('div');
n@319 677 entry.style.width = "456px";
n@319 678 entry.style.height= "20px";
n@319 679 entry.style.margin= "2px";
n@319 680 entry.style.borderBottom = "#DDD";
n@319 681 entry.style.borderBottomWidth = "1px";
n@319 682 entry.style.borderBottomStyle = "solid";
n@319 683 entry.align = "center";
n@319 684 var addPre = document.createElement('button');
n@319 685 addPre.className = "popupButton";
n@319 686 addPre.textContent = "Add New Entry";
n@319 687 addPre.style.height = "20px";
n@319 688 addPre.onclick = function()
n@319 689 {
n@319 690 popupInstance.dataTransfer = new function() {
n@319 691 this.title = "New Pre Test Node";
n@319 692 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].preTest;
n@319 693 this.node = null;
n@319 694 this.previousState = 5;
n@319 695 };
n@319 696 popupInstance.advanceState();
n@319 697 };
n@319 698 entry.appendChild(addPre);
n@319 699 preHolder.appendChild(entry);
n@319 700
n@319 701 var span = document.createElement('span');
n@319 702 span.textContent = "Add your post test page options here";
n@319 703 this.popupBody.appendChild(span);
n@319 704 var postHolder = document.createElement('div');
n@319 705 postHolder.id = "preHolder";
n@319 706 postHolder.style.width = "100%";
n@319 707 postHolder.style.minHeight = "100px";
n@319 708 postHolder.style.maxHeight = "220px";
n@319 709 postHolder.style.overflow = 'auto';
n@319 710 postHolder.style.border = "black";
n@319 711 postHolder.style.borderStyle = "solid";
n@319 712 postHolder.style.borderWidth = "1px";
n@319 713 this.popupBody.appendChild(postHolder);
n@319 714 var postHeaderHolder = document.createElement('div');
n@319 715 postHeaderHolder.style.width = "456px";
n@319 716 postHeaderHolder.style.height= "20px";
n@319 717 postHeaderHolder.style.margin= "2px";
n@319 718 postHeaderHolder.style.borderBottom = "#DDD";
n@319 719 postHeaderHolder.style.borderBottomWidth = "1px";
n@319 720 postHeaderHolder.style.borderBottomStyle = "solid";
n@319 721 var mvH = document.createElement('div');
n@319 722 mvH.className = "dndheaderelement";
n@319 723 mvH.style.width = "50px";
n@319 724 var text = document.createElement('span');
n@319 725 text.textContent = "Order";
n@319 726 mvH.appendChild(text);
n@319 727 postHeaderHolder.appendChild(mvH);
n@319 728 var idH = document.createElement('div');
n@319 729 idH.className = "dndheaderelement";
n@319 730 idH.style.width = "150px";
n@319 731 text = document.createElement('span');
n@319 732 text.textContent = "ID";
n@319 733 idH.appendChild(text);
n@319 734 postHeaderHolder.appendChild(idH);
n@319 735 var tH = document.createElement('div');
n@319 736 tH.className = "dndheaderelement";
n@319 737 tH.style.width = "150px";
n@319 738 text = document.createElement('span');
n@319 739 text.textContent = "Type";
n@319 740 tH.appendChild(text);
n@319 741 postHeaderHolder.appendChild(tH);
n@319 742 var editH = document.createElement('div');
n@319 743 editH.className = "dndheaderelement";
n@319 744 editH.style.width = "50px";
n@319 745 text = document.createElement('span');
n@319 746 text.textContent = "Edit";
n@319 747 editH.appendChild(text);
n@319 748 postHeaderHolder.appendChild(editH);
n@319 749 var deleteH = document.createElement('div');
n@319 750 deleteH.className = "dndheaderelement";
n@319 751 deleteH.style.width = "50px";
n@319 752 text = document.createElement('span');
n@319 753 text.textContent = "Delete";
n@319 754 deleteH.appendChild(text);
n@319 755 postHeaderHolder.appendChild(deleteH);
n@319 756 postHolder.appendChild(postHeaderHolder);
n@319 757
n@319 758 for (var i=0; i<audioHolder.postTest.options.length; i++)
n@319 759 {
n@319 760 var optionNode = audioHolder.postTest.options[i];
n@319 761 var entry = document.createElement('div');
n@319 762 entry.style.width = "456px";
n@319 763 entry.style.height= "20px";
n@319 764 entry.style.margin= "2px";
n@319 765 entry.style.borderBottom = "#DDD";
n@319 766 entry.style.borderBottomWidth = "1px";
n@319 767 entry.style.borderBottomStyle = "solid";
n@319 768 entry.setAttribute("node-id",i);
n@319 769 var node = audioHolder.postTest.options[i];
n@319 770 var mvH = document.createElement('div');
n@319 771 mvH.className = "dndheaderelement";
n@319 772 mvH.style.width = "50px";
n@319 773 var mvup = document.createElement("button");
n@319 774 mvup.textContent = "Up";
n@319 775 mvup.style.width = "25px";
n@319 776 mvup.style.padding = "1px 0px";
n@319 777 mvup.onclick = function()
n@319 778 {
n@319 779 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 780 if (i != 0)
n@319 781 {
n@319 782 var next = audioHolder.postTest.options[i-1];
n@319 783 var cur = audioHolder.postTest.options[i];
n@319 784 audioHolder.postTest.options[i-1] = cur;
n@319 785 audioHolder.postTest.options[i] = next;
n@319 786 popupInstance.state = 5;
n@319 787 popupInstance.advanceState();
n@319 788 }
n@319 789 };
n@319 790 mvH.appendChild(mvup);
n@319 791 var mvdn = document.createElement("button");
n@319 792 mvdn.textContent = "Dn";
n@319 793 mvdn.style.width = "25px";
n@319 794 mvdn.style.padding = "1px 0px";
n@319 795 mvdn.onclick = function()
n@319 796 {
n@319 797 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 798 if (i != audioHolder.postTest.options.length-1)
n@319 799 {
n@319 800 var next = audioHolder.postTest.options[i+1];
n@319 801 var cur = audioHolder.postTest.options[i];
n@319 802 audioHolder.postTest.options[i+1] = cur;
n@319 803 audioHolder.postTest.options[i] = next;
n@319 804 popupInstance.state = 5;
n@319 805 popupInstance.advanceState();
n@319 806 }
n@319 807 };
n@319 808 mvH.appendChild(mvdn);
n@319 809 entry.appendChild(mvH);
n@319 810 var idH = document.createElement('div');
n@319 811 idH.className = "dndheaderelement";
n@319 812 idH.style.width = "150px";
n@319 813 if (optionNode.type != "statement")
n@319 814 {
n@319 815 var span = document.createElement('span');
n@319 816 span.textContent = optionNode.id;
n@319 817 idH.appendChild(span);
n@319 818 }
n@319 819 entry.appendChild(idH);
n@319 820 var typeH = document.createElement('div');
n@319 821 typeH.className = "dndheaderelement";
n@319 822 typeH.style.width = "150px";
n@319 823 var span = document.createElement('span');
n@319 824 span.textContent = optionNode.type;
n@319 825 typeH.appendChild(span);
n@319 826 entry.appendChild(typeH);
n@319 827 var editH = document.createElement('div');
n@319 828 editH.className = "dndheaderelement";
n@319 829 editH.style.width = "50px";
n@319 830 var editButton = document.createElement("button");
n@319 831 editButton.textContent = "Edit";
n@319 832 editButton.style.width = "48px";
n@319 833 editButton.style.padding = "1px 0px";
n@319 834 editButton.onclick = function()
n@319 835 {
n@319 836 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 837 popupInstance.dataTransfer = new function() {
n@319 838 this.title = "Edit Test Node";
n@319 839 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].postTest;
n@319 840 this.node = this.parent.options[i];
n@319 841 this.previousState = 5;
n@319 842 };
n@319 843 popupInstance.advanceState();
n@319 844 };
n@319 845 editH.appendChild(editButton);
n@319 846 entry.appendChild(editH);
n@319 847 var deleteH = document.createElement('div');
n@319 848 deleteH.className = "dndheaderelement";
n@319 849 deleteH.style.width = "50px";
n@319 850 var deleteButton = document.createElement("button");
n@319 851 deleteButton.textContent = "Del";
n@319 852 deleteButton.style.width = "48px";
n@319 853 deleteButton.style.padding = "1px 0px";
n@319 854 deleteButton.onclick = function()
n@319 855 {
n@319 856 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 857 var j = i+1;
n@319 858 while(j < audioHolder.postTest.options.length)
n@319 859 {
n@319 860 audioHolder.postTest.options[i] = audioHolder.postTest.options[j];
n@319 861 j++;
n@319 862 i++;
n@319 863 }
n@319 864 audioHolder.postTest.options.pop();
n@319 865 popupInstance.state = 5;
n@319 866 popupInstance.advanceState();
n@319 867 };
n@319 868 deleteH.appendChild(deleteButton);
n@319 869 entry.appendChild(deleteH);
n@319 870 postHolder.appendChild(entry);
n@319 871 }
n@319 872
n@319 873 var entry = document.createElement('div');
n@319 874 entry.style.width = "456px";
n@319 875 entry.style.height= "20px";
n@319 876 entry.style.margin= "2px";
n@319 877 entry.style.borderBottom = "#DDD";
n@319 878 entry.style.borderBottomWidth = "1px";
n@319 879 entry.style.borderBottomStyle = "solid";
n@319 880 entry.align = "center";
n@319 881 var addPost = document.createElement('button');
n@319 882 addPost.className = "popupButton";
n@319 883 addPost.textContent = "Add New Entry";
n@319 884 addPost.style.height = "20px";
n@319 885 addPost.onclick = function()
n@319 886 {
n@319 887 popupInstance.dataTransfer = new function() {
n@319 888 this.title = "New Pre Test Node";
n@319 889 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].postTest;
n@319 890 this.node = null;
n@319 891 this.previousState = 5;
n@319 892 };
n@319 893 popupInstance.advanceState();
n@319 894 };
n@319 895 entry.appendChild(addPost);
n@319 896 postHolder.appendChild(entry);
n@319 897
n@319 898 var button = document.createElement('button');
n@319 899 button.id = 'submit';
n@319 900 button.className = "popupButton";
n@319 901 button.textContent = "Finish";
n@319 902 button.onclick = function(event)
n@319 903 {
n@319 904 popupInstance.state = 7;
n@319 905 popupInstance.advanceState();
n@319 906 };
n@319 907 this.popupFooter.appendChild(button);
n@319 908 button = document.createElement('button');
n@319 909 button.id = 'submit';
n@319 910 button.className = "popupButton";
n@319 911 button.textContent = "Add Another Page";
n@319 912 button.onclick = function(event)
n@319 913 {
n@319 914 popupInstance.state = 3;
n@319 915 popupInstance.advanceState();
n@319 916 };
n@319 917 this.popupFooter.appendChild(button);
n@319 918 break;
n@319 919 case 6:
n@319 920 this.popupTitleText.textContent = this.dataTransfer.title;
n@319 921 var span = document.createElement('span');
n@319 922 span.textContent = "Select survey settings here";
n@319 923 this.popupBody.appendChild(span);
n@319 924 var div = document.createElement('div');
n@319 925 span = document.createElement("span");
n@319 926 span.textContent = "Survey Type";
n@319 927 var select = document.createElement("select");
n@319 928 select.id="survey-select";
n@319 929 var option = document.createElement('option');
n@319 930 option.textContent = "Statement";
n@319 931 option.value = "statement";
n@319 932 select.appendChild(option);
n@319 933 option = document.createElement('option');
n@319 934 option.textContent = "Question";
n@319 935 option.value = "question";
n@319 936 select.appendChild(option);
n@319 937 option = document.createElement('option');
n@319 938 option.textContent = "Number";
n@319 939 option.value = "number";
n@319 940 select.appendChild(option);
n@319 941 option = document.createElement('option');
n@319 942 option.textContent = "Radio";
n@319 943 option.value = "radio";
n@319 944 select.appendChild(option);
n@319 945 option = document.createElement('option');
n@319 946 option.textContent = "Checkbox";
n@319 947 option.value = "checkbox";
n@319 948 select.appendChild(option);
n@319 949 this.popupBody.appendChild(select);
n@319 950 var options = document.createElement('div');
n@319 951 options.id = "survey-options";
n@319 952 this.popupBody.appendChild(options);
n@319 953 var button = document.createElement('button');
n@319 954 button.id = 'submit';
n@319 955 button.className = "popupButton";
n@319 956 button.textContent = "Add";
n@319 957 button.onclick = function(event)
n@319 958 {
n@319 959 var parent = popupInstance.dataTransfer.parent;
n@319 960 if (popupInstance.dataTransfer.node == null)
n@319 961 {
n@319 962 var node = new parent.OptionNode();
n@319 963 } else
n@319 964 {
n@319 965 var node = popupInstance.dataTransfer.node;
n@319 966 }
n@319 967 node.type = document.getElementById("survey-select").value;
n@319 968 switch(node.type)
n@319 969 {
n@319 970 case "statement":
n@319 971 node.statement = document.getElementById("statement").value;
n@319 972 break;
n@319 973 case "question":
n@319 974 node.question = document.getElementById("question").value;
n@319 975 node.id = document.getElementById("ID").value;
n@319 976 node.mandatory = document.getElementById("mandatory").checked;
n@319 977 node.boxsize = document.getElementById("boxsize").value;
n@319 978 break;
n@319 979 }
n@319 980 if (popupInstance.dataTransfer.node == null)
n@319 981 {parent.options.push(node);}
n@319 982 popupInstance.state = popupInstance.dataTransfer.previousState;
n@319 983 popupInstance.advanceState();
n@319 984 };
n@319 985 this.popupFooter.appendChild(button);
n@319 986 select.onchange = function()
n@319 987 {
n@319 988 var options = document.getElementById("survey-options");
n@319 989 options.innerHTML = null;
n@319 990 switch(this.value)
n@319 991 {
n@319 992 case "statement":
n@319 993 var span = document.createElement('span');
n@319 994 span.textContent = "Enter Statement";
n@319 995 var tA = document.createElement('textarea');
n@319 996 tA.id = "statement";
n@319 997 tA.style.width = "460px";
n@319 998 tA.style.height = "96px";
n@319 999 if (popupInstance.dataTransfer.node != null)
n@319 1000 {tA.value = this.dataTransfer.node.statement;}
n@319 1001 options.appendChild(span);
n@319 1002 options.appendChild(tA);
n@319 1003 break;
n@319 1004 case "question":
n@319 1005 var span = document.createElement('span');
n@319 1006 span.textContent = "Enter Question";
n@319 1007 var tA = document.createElement('textarea');
n@319 1008 tA.style.width = "460px";
n@319 1009 tA.style.height = "54px";
n@319 1010 tA.id = "question";
n@319 1011 options.appendChild(span);
n@319 1012 options.appendChild(tA);
n@319 1013 var div = document.createElement('div');
n@319 1014 var input = document.createElement('input');
n@319 1015 input.id = "ID";
n@319 1016 span = document.createElement('span');
n@319 1017 span.textContent = "ID:";
n@319 1018 div.appendChild(span);
n@319 1019 div.appendChild(input);
n@319 1020 options.appendChild(div);
n@319 1021 div = document.createElement('div');
n@319 1022 input = document.createElement('input');
n@319 1023 input.type = "checkbox";
n@319 1024 input.id = "mandatory";
n@319 1025 span = document.createElement('span');
n@319 1026 span.textContent = "Mandatory";
n@319 1027 div.appendChild(span);
n@319 1028 div.appendChild(input);
n@319 1029 options.appendChild(div);
n@319 1030 div = document.createElement('div');
n@319 1031 var boxsize = document.createElement("select");
n@319 1032 boxsize.id = "boxsize";
n@319 1033 var selOpt = document.createElement("option");
n@319 1034 selOpt.value = "normal";
n@319 1035 selOpt.textContent = "Normal";
n@319 1036 boxsize.appendChild(selOpt);
n@319 1037 selOpt = document.createElement("option");
n@319 1038 selOpt.value = "small";
n@319 1039 selOpt.textContent = "Small";
n@319 1040 boxsize.appendChild(selOpt);
n@319 1041 selOpt = document.createElement("option");
n@319 1042 selOpt.value = "large";
n@319 1043 selOpt.textContent = "Large";
n@319 1044 boxsize.appendChild(selOpt);
n@319 1045 selOpt = document.createElement("option");
n@319 1046 selOpt.value = "huge";
n@319 1047 selOpt.textContent = "Huge";
n@319 1048 boxsize.appendChild(selOpt);
n@319 1049 span = document.createElement('span');
n@319 1050 span.textContent = "Response Text Area";
n@319 1051 div.appendChild(span);
n@319 1052 div.appendChild(boxsize);
n@319 1053 options.appendChild(div);
n@319 1054 if (popupInstance.dataTransfer.node != null)
n@319 1055 {
n@319 1056 tA.value = popupInstance.dataTransfer.node.question;
n@319 1057 document.getElementById("ID").value = popupInstance.dataTransfer.node.id;
n@319 1058 document.getElementById("mandatory").value = popupInstance.dataTransfer.node.mandatory;
n@319 1059 document.getElementById("boxsize").value = popupInstance.dataTransfer.node.boxsize;
n@319 1060 }
n@319 1061 break;
n@319 1062 case "number":
n@319 1063 var span = document.createElement('span');
n@319 1064 span.textContent = "Enter Question";
n@319 1065 var tA = document.createElement('textarea');
n@319 1066 tA.style.width = "460px";
n@319 1067 tA.style.height = "54px";
n@319 1068 tA.id = "question";
n@319 1069 options.appendChild(span);
n@319 1070 options.appendChild(tA);
n@319 1071 var div = document.createElement('div');
n@319 1072 var input = document.createElement('input');
n@319 1073 input.id = "ID";
n@319 1074 span = document.createElement('span');
n@319 1075 span.textContent = "ID:";
n@319 1076 div.appendChild(span);
n@319 1077 div.appendChild(input);
n@319 1078 options.appendChild(div);
n@319 1079 div = document.createElement('div');
n@319 1080 input = document.createElement('input');
n@319 1081 input.type = "checkbox";
n@319 1082 input.id = "mandatory";
n@319 1083 span = document.createElement('span');
n@319 1084 span.textContent = "Mandatory";
n@319 1085 div.appendChild(span);
n@319 1086 div.appendChild(input);
n@319 1087 options.appendChild(div);
n@319 1088 div = document.createElement('div');
n@319 1089 break;
n@319 1090 }
n@319 1091 };
n@319 1092 if (this.dataTransfer.node != null)
n@319 1093 {
n@319 1094 select.value = this.dataTransfer.node.type;
n@319 1095 }
n@319 1096 select.onchange();
n@319 1097 break;
n@319 1098 case 7:
n@319 1099 this.dataTransfer = null;
n@319 1100 this.popupTitleText.textContent = "Test Session - Pre/Post Survey";
n@319 1101 var span = document.createElement('span');
n@319 1102 span.textContent = "Add your pre test session and post test session survey options here";
n@319 1103 this.popupBody.appendChild(span);
n@319 1104 var preHolder = document.createElement('div');
n@319 1105 preHolder.id = "preHolder";
n@319 1106 preHolder.style.width = "460px";
n@319 1107 preHolder.style.minHeight = "100px";
n@319 1108 preHolder.style.maxHeight = "220px";
n@319 1109 preHolder.style.overflow = 'auto';
n@319 1110 preHolder.style.border = "black";
n@319 1111 preHolder.style.borderStyle = "solid";
n@319 1112 preHolder.style.borderWidth = "1px";
n@319 1113 this.popupBody.appendChild(preHolder);
n@319 1114 var preHeaderHolder = document.createElement('div');
n@319 1115 preHeaderHolder.style.width = "456px";
n@319 1116 preHeaderHolder.style.height= "20px";
n@319 1117 preHeaderHolder.style.margin= "2px";
n@319 1118 preHeaderHolder.style.borderBottom = "#DDD";
n@319 1119 preHeaderHolder.style.borderBottomWidth = "1px";
n@319 1120 preHeaderHolder.style.borderBottomStyle = "solid";
n@319 1121 var mvH = document.createElement('div');
n@319 1122 mvH.className = "dndheaderelement";
n@319 1123 mvH.style.width = "50px";
n@319 1124 var text = document.createElement('span');
n@319 1125 text.textContent = "Order";
n@319 1126 mvH.appendChild(text);
n@319 1127 preHeaderHolder.appendChild(mvH);
n@319 1128 var idH = document.createElement('div');
n@319 1129 idH.className = "dndheaderelement";
n@319 1130 idH.style.width = "150px";
n@319 1131 text = document.createElement('span');
n@319 1132 text.textContent = "ID";
n@319 1133 idH.appendChild(text);
n@319 1134 preHeaderHolder.appendChild(idH);
n@319 1135 var tH = document.createElement('div');
n@319 1136 tH.className = "dndheaderelement";
n@319 1137 tH.style.width = "150px";
n@319 1138 text = document.createElement('span');
n@319 1139 text.textContent = "Type";
n@319 1140 tH.appendChild(text);
n@319 1141 preHeaderHolder.appendChild(tH);
n@319 1142 var editH = document.createElement('div');
n@319 1143 editH.className = "dndheaderelement";
n@319 1144 editH.style.width = "50px";
n@319 1145 text = document.createElement('span');
n@319 1146 text.textContent = "Edit";
n@319 1147 editH.appendChild(text);
n@319 1148 preHeaderHolder.appendChild(editH);
n@319 1149 var deleteH = document.createElement('div');
n@319 1150 deleteH.className = "dndheaderelement";
n@319 1151 deleteH.style.width = "50px";
n@319 1152 text = document.createElement('span');
n@319 1153 text.textContent = "Delete";
n@319 1154 deleteH.appendChild(text);
n@319 1155 preHeaderHolder.appendChild(deleteH);
n@319 1156 preHolder.appendChild(preHeaderHolder);
n@319 1157
n@319 1158
n@319 1159 for (var i=0; i<specificationNode.preTest.options.length; i++)
n@319 1160 {
n@319 1161 var optionNode = specificationNode.preTest.options[i];
n@319 1162 var entry = document.createElement('div');
n@319 1163 entry.style.width = "456px";
n@319 1164 entry.style.height= "20px";
n@319 1165 entry.style.margin= "2px";
n@319 1166 entry.style.borderBottom = "#DDD";
n@319 1167 entry.style.borderBottomWidth = "1px";
n@319 1168 entry.style.borderBottomStyle = "solid";
n@319 1169 entry.setAttribute("node-id",i);
n@319 1170 var node = specificationNode.preTest.options[i];
n@319 1171 var mvH = document.createElement('div');
n@319 1172 mvH.className = "dndheaderelement";
n@319 1173 mvH.style.width = "50px";
n@319 1174 var mvup = document.createElement("button");
n@319 1175 mvup.textContent = "Up";
n@319 1176 mvup.style.width = "25px";
n@319 1177 mvup.style.padding = "1px 0px";
n@319 1178 mvup.onclick = function()
n@319 1179 {
n@319 1180 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 1181 if (i != 0)
n@319 1182 {
n@319 1183 var next = specificationNode.preTest.options[i-1];
n@319 1184 var cur = specificationNode.preTest.options[i];
n@319 1185 specificationNode.preTest.options[i-1] = cur;
n@319 1186 specificationNode.preTest.options[i] = next;
n@319 1187 popupInstance.state = 7;
n@319 1188 popupInstance.advanceState();
n@319 1189 }
n@319 1190 };
n@319 1191 mvH.appendChild(mvup);
n@319 1192 var mvdn = document.createElement("button");
n@319 1193 mvdn.textContent = "Dn";
n@319 1194 mvdn.style.width = "25px";
n@319 1195 mvdn.style.padding = "1px 0px";
n@319 1196 mvdn.onclick = function()
n@319 1197 {
n@319 1198 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 1199 if (i != specificationNode.preTest.options.length-1)
n@319 1200 {
n@319 1201 var next = specificationNode.preTest.options[i+1];
n@319 1202 var cur = specificationNode.preTest.options[i];
n@319 1203 specificationNode.preTest.options[i+1] = cur;
n@319 1204 specificationNode.preTest.options[i] = next;
n@319 1205 popupInstance.state = 7;
n@319 1206 popupInstance.advanceState();
n@319 1207 }
n@319 1208 };
n@319 1209 mvH.appendChild(mvdn);
n@319 1210 entry.appendChild(mvH);
n@319 1211 var idH = document.createElement('div');
n@319 1212 idH.className = "dndheaderelement";
n@319 1213 idH.style.width = "150px";
n@319 1214 if (optionNode.type != "statement")
n@319 1215 {
n@319 1216 var span = document.createElement('span');
n@319 1217 span.textContent = optionNode.id;
n@319 1218 idH.appendChild(span);
n@319 1219 }
n@319 1220 entry.appendChild(idH);
n@319 1221 var typeH = document.createElement('div');
n@319 1222 typeH.className = "dndheaderelement";
n@319 1223 typeH.style.width = "150px";
n@319 1224 var span = document.createElement('span');
n@319 1225 span.textContent = optionNode.type;
n@319 1226 typeH.appendChild(span);
n@319 1227 entry.appendChild(typeH);
n@319 1228 var editH = document.createElement('div');
n@319 1229 editH.className = "dndheaderelement";
n@319 1230 editH.style.width = "50px";
n@319 1231 var editButton = document.createElement("button");
n@319 1232 editButton.textContent = "Edit";
n@319 1233 editButton.style.width = "48px";
n@319 1234 editButton.style.padding = "1px 0px";
n@319 1235 editButton.onclick = function()
n@319 1236 {
n@319 1237 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 1238 popupInstance.dataTransfer = new function() {
n@319 1239 this.title = "Edit Test Node";
n@319 1240 this.parent = specificationNode.preTest;
n@319 1241 this.node = this.parent.options[i];
n@319 1242 this.previousState = 7;
n@319 1243 };
n@319 1244 popupInstace.state = 6;
n@319 1245 popupInstance.advanceState();
n@319 1246 };
n@319 1247 editH.appendChild(editButton);
n@319 1248 entry.appendChild(editH);
n@319 1249 var deleteH = document.createElement('div');
n@319 1250 deleteH.className = "dndheaderelement";
n@319 1251 deleteH.style.width = "50px";
n@319 1252 var deleteButton = document.createElement("button");
n@319 1253 deleteButton.textContent = "Del";
n@319 1254 deleteButton.style.width = "48px";
n@319 1255 deleteButton.style.padding = "1px 0px";
n@319 1256 deleteButton.onclick = function()
n@319 1257 {
n@319 1258 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 1259 var j = i+1;
n@319 1260 while(j < specificationNode.preTest.options.length)
n@319 1261 {
n@319 1262 specificationNode.preTest.options[i] = specificationNode.preTest.options[j];
n@319 1263 j++;
n@319 1264 i++;
n@319 1265 }
n@319 1266 specificationNode.preTest.options.pop();
n@319 1267 popupInstance.state = 7;
n@319 1268 popupInstance.advanceState();
n@319 1269 };
n@319 1270 deleteH.appendChild(deleteButton);
n@319 1271 entry.appendChild(deleteH);
n@319 1272 preHolder.appendChild(entry);
n@319 1273 }
n@319 1274 var entry = document.createElement('div');
n@319 1275 entry.style.width = "456px";
n@319 1276 entry.style.height= "20px";
n@319 1277 entry.style.margin= "2px";
n@319 1278 entry.style.borderBottom = "#DDD";
n@319 1279 entry.style.borderBottomWidth = "1px";
n@319 1280 entry.style.borderBottomStyle = "solid";
n@319 1281 entry.align = "center";
n@319 1282 var addPre = document.createElement('button');
n@319 1283 addPre.className = "popupButton";
n@319 1284 addPre.textContent = "Add New Entry";
n@319 1285 addPre.style.height = "20px";
n@319 1286 addPre.onclick = function()
n@319 1287 {
n@319 1288 popupInstance.dataTransfer = new function() {
n@319 1289 this.title = "New Pre Test Node";
n@319 1290 this.parent = specificationNode.preTest;
n@319 1291 this.node = null;
n@319 1292 this.previousState = 7;
n@319 1293 };
n@319 1294 popupInstance.state = 6;
n@319 1295 popupInstance.advanceState();
n@319 1296 };
n@319 1297 entry.appendChild(addPre);
n@319 1298 preHolder.appendChild(entry);
n@319 1299
n@319 1300 var span = document.createElement('span');
n@319 1301 span.textContent = "Add your post test page options here";
n@319 1302 this.popupBody.appendChild(span);
n@319 1303 var postHolder = document.createElement('div');
n@319 1304 postHolder.id = "preHolder";
n@319 1305 postHolder.style.width = "100%";
n@319 1306 postHolder.style.minHeight = "100px";
n@319 1307 postHolder.style.maxHeight = "220px";
n@319 1308 postHolder.style.overflow = 'auto';
n@319 1309 postHolder.style.border = "black";
n@319 1310 postHolder.style.borderStyle = "solid";
n@319 1311 postHolder.style.borderWidth = "1px";
n@319 1312 this.popupBody.appendChild(postHolder);
n@319 1313 var postHeaderHolder = document.createElement('div');
n@319 1314 postHeaderHolder.style.width = "456px";
n@319 1315 postHeaderHolder.style.height= "20px";
n@319 1316 postHeaderHolder.style.margin= "2px";
n@319 1317 postHeaderHolder.style.borderBottom = "#DDD";
n@319 1318 postHeaderHolder.style.borderBottomWidth = "1px";
n@319 1319 postHeaderHolder.style.borderBottomStyle = "solid";
n@319 1320 var mvH = document.createElement('div');
n@319 1321 mvH.className = "dndheaderelement";
n@319 1322 mvH.style.width = "50px";
n@319 1323 var text = document.createElement('span');
n@319 1324 text.textContent = "Order";
n@319 1325 mvH.appendChild(text);
n@319 1326 postHeaderHolder.appendChild(mvH);
n@319 1327 var idH = document.createElement('div');
n@319 1328 idH.className = "dndheaderelement";
n@319 1329 idH.style.width = "150px";
n@319 1330 text = document.createElement('span');
n@319 1331 text.textContent = "ID";
n@319 1332 idH.appendChild(text);
n@319 1333 postHeaderHolder.appendChild(idH);
n@319 1334 var tH = document.createElement('div');
n@319 1335 tH.className = "dndheaderelement";
n@319 1336 tH.style.width = "150px";
n@319 1337 text = document.createElement('span');
n@319 1338 text.textContent = "Type";
n@319 1339 tH.appendChild(text);
n@319 1340 postHeaderHolder.appendChild(tH);
n@319 1341 var editH = document.createElement('div');
n@319 1342 editH.className = "dndheaderelement";
n@319 1343 editH.style.width = "50px";
n@319 1344 text = document.createElement('span');
n@319 1345 text.textContent = "Edit";
n@319 1346 editH.appendChild(text);
n@319 1347 postHeaderHolder.appendChild(editH);
n@319 1348 var deleteH = document.createElement('div');
n@319 1349 deleteH.className = "dndheaderelement";
n@319 1350 deleteH.style.width = "50px";
n@319 1351 text = document.createElement('span');
n@319 1352 text.textContent = "Delete";
n@319 1353 deleteH.appendChild(text);
n@319 1354 postHeaderHolder.appendChild(deleteH);
n@319 1355 postHolder.appendChild(postHeaderHolder);
n@319 1356
n@319 1357 for (var i=0; i<specificationNode.postTest.options.length; i++)
n@319 1358 {
n@319 1359 var optionNode = specificationNode.postTest.options[i];
n@319 1360 var entry = document.createElement('div');
n@319 1361 entry.style.width = "456px";
n@319 1362 entry.style.height= "20px";
n@319 1363 entry.style.margin= "2px";
n@319 1364 entry.style.borderBottom = "#DDD";
n@319 1365 entry.style.borderBottomWidth = "1px";
n@319 1366 entry.style.borderBottomStyle = "solid";
n@319 1367 entry.setAttribute("node-id",i);
n@319 1368 var node = specificationNode.postTest.options[i];
n@319 1369 var mvH = document.createElement('div');
n@319 1370 mvH.className = "dndheaderelement";
n@319 1371 mvH.style.width = "50px";
n@319 1372 var mvup = document.createElement("button");
n@319 1373 mvup.textContent = "Up";
n@319 1374 mvup.style.width = "25px";
n@319 1375 mvup.style.padding = "1px 0px";
n@319 1376 mvup.onclick = function()
n@319 1377 {
n@319 1378 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 1379 if (i != 0)
n@319 1380 {
n@319 1381 var next = specificationNode.postTest.options[i-1];
n@319 1382 var cur = specificationNode.postTest.options[i];
n@319 1383 specificationNode.postTest.options[i-1] = cur;
n@319 1384 specificationNode.postTest.options[i] = next;
n@319 1385 popupInstance.state = 7;
n@319 1386 popupInstance.advanceState();
n@319 1387 }
n@319 1388 };
n@319 1389 mvH.appendChild(mvup);
n@319 1390 var mvdn = document.createElement("button");
n@319 1391 mvdn.textContent = "Dn";
n@319 1392 mvdn.style.width = "25px";
n@319 1393 mvdn.style.padding = "1px 0px";
n@319 1394 mvdn.onclick = function()
n@319 1395 {
n@319 1396 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 1397 if (i != specificationNode.postTest.options.length-1)
n@319 1398 {
n@319 1399 var next = specificationNode.postTest.options[i+1];
n@319 1400 var cur = specificationNode.postTest.options[i];
n@319 1401 specificationNode.postTest.options[i+1] = cur;
n@319 1402 specificationNode.postTest.options[i] = next;
n@319 1403 popupInstance.state = 7;
n@319 1404 popupInstance.advanceState();
n@319 1405 }
n@319 1406 };
n@319 1407 mvH.appendChild(mvdn);
n@319 1408 entry.appendChild(mvH);
n@319 1409 var idH = document.createElement('div');
n@319 1410 idH.className = "dndheaderelement";
n@319 1411 idH.style.width = "150px";
n@319 1412 if (optionNode.type != "statement")
n@319 1413 {
n@319 1414 var span = document.createElement('span');
n@319 1415 span.textContent = optionNode.id;
n@319 1416 idH.appendChild(span);
n@319 1417 }
n@319 1418 entry.appendChild(idH);
n@319 1419 var typeH = document.createElement('div');
n@319 1420 typeH.className = "dndheaderelement";
n@319 1421 typeH.style.width = "150px";
n@319 1422 var span = document.createElement('span');
n@319 1423 span.textContent = optionNode.type;
n@319 1424 typeH.appendChild(span);
n@319 1425 entry.appendChild(typeH);
n@319 1426 var editH = document.createElement('div');
n@319 1427 editH.className = "dndheaderelement";
n@319 1428 editH.style.width = "50px";
n@319 1429 var editButton = document.createElement("button");
n@319 1430 editButton.textContent = "Edit";
n@319 1431 editButton.style.width = "48px";
n@319 1432 editButton.style.padding = "1px 0px";
n@319 1433 editButton.onclick = function()
n@319 1434 {
n@319 1435 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 1436 popupInstance.dataTransfer = new function() {
n@319 1437 this.title = "Edit Test Node";
n@319 1438 this.parent = specificationNode.postTest;
n@319 1439 this.node = this.parent.options[i];
n@319 1440 this.previousState = 7;
n@319 1441 };
n@319 1442 popupInstance.state = 6;
n@319 1443 popupInstance.advanceState();
n@319 1444 };
n@319 1445 editH.appendChild(editButton);
n@319 1446 entry.appendChild(editH);
n@319 1447 var deleteH = document.createElement('div');
n@319 1448 deleteH.className = "dndheaderelement";
n@319 1449 deleteH.style.width = "50px";
n@319 1450 var deleteButton = document.createElement("button");
n@319 1451 deleteButton.textContent = "Del";
n@319 1452 deleteButton.style.width = "48px";
n@319 1453 deleteButton.style.padding = "1px 0px";
n@319 1454 deleteButton.onclick = function()
n@319 1455 {
n@319 1456 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
n@319 1457 var j = i+1;
n@319 1458 while(j < specificationNode.postTest.options.length)
n@319 1459 {
n@319 1460 specificationNode.postTest.options[i] = specificationNode.postTest.options[j];
n@319 1461 j++;
n@319 1462 i++;
n@319 1463 }
n@319 1464 audioHolder.postTest.options.pop();
n@319 1465 popupInstance.state = 7;
n@319 1466 popupInstance.advanceState();
n@319 1467 };
n@319 1468 deleteH.appendChild(deleteButton);
n@319 1469 entry.appendChild(deleteH);
n@319 1470 postHolder.appendChild(entry);
n@319 1471 }
n@319 1472
n@319 1473 var entry = document.createElement('div');
n@319 1474 entry.style.width = "456px";
n@319 1475 entry.style.height= "20px";
n@319 1476 entry.style.margin= "2px";
n@319 1477 entry.style.borderBottom = "#DDD";
n@319 1478 entry.style.borderBottomWidth = "1px";
n@319 1479 entry.style.borderBottomStyle = "solid";
n@319 1480 entry.align = "center";
n@319 1481 var addPost = document.createElement('button');
n@319 1482 addPost.className = "popupButton";
n@319 1483 addPost.textContent = "Add New Entry";
n@319 1484 addPost.style.height = "20px";
n@319 1485 addPost.onclick = function()
n@319 1486 {
n@319 1487 popupInstance.dataTransfer = new function() {
n@319 1488 this.title = "New Pre Test Node";
n@319 1489 this.parent = specificationNode.postTest;
n@319 1490 this.node = null;
n@319 1491 this.previousState = 7;
n@319 1492 };
n@319 1493 popupInstace.state = 6;
n@319 1494 popupInstance.advanceState();
n@319 1495 };
n@319 1496 entry.appendChild(addPost);
n@319 1497 postHolder.appendChild(entry);
n@319 1498
n@319 1499 var button = document.createElement('button');
n@319 1500 button.id = 'submit';
n@319 1501 button.className = "popupButton";
n@319 1502 button.textContent = "Finish";
n@319 1503 button.onclick = function(event)
n@319 1504 {
n@319 1505 popupInstance.state = 8;
n@319 1506 popupInstance.advanceState();
n@319 1507 };
n@319 1508 this.popupFooter.appendChild(button);
n@319 1509 break;
n@319 1510 case 8:
n@319 1511 this.hidePopup();
n@319 1512 this.state = 0;
n@319 1513 SpecficationToHTML();
n@162 1514 }
n@311 1515 this.state++;
n@311 1516 };
n@311 1517 };
n@311 1518
n@319 1519 function audioObject()
n@319 1520 {
n@319 1521 // Used to hold audio information in buffers for quick playback
n@319 1522 this.bufferObject;
n@319 1523 this.bufferNode = undefined;
n@319 1524 this.state = 0;
n@319 1525 this.gain = audioContext.createGain();
n@319 1526 this.gain.connect(audioContext.destination);
n@319 1527 this.include = true;
n@319 1528 this.id = undefined;
n@319 1529 this.file = undefined;
n@319 1530
n@319 1531 this.play = function()
n@319 1532 {
n@319 1533 if (this.bufferNode != undefined)
n@319 1534 {
n@319 1535 this.bufferNode.stop(0);
n@319 1536 this.bufferNode = undefined;
n@319 1537 }
n@319 1538 if(this.state == 1)
n@319 1539 {
n@319 1540 this.bufferNode = audioContext.createBufferSource();
n@319 1541 this.bufferNode.connect(this.gain);
n@319 1542 this.bufferNode.buffer = this.bufferObject;
n@319 1543 this.bufferNode.onended = function(event) {
n@319 1544 // Safari does not like using 'this' to reference the calling object!
n@319 1545 event.currentTarget = undefined;
n@319 1546 };
n@319 1547 this.bufferNode.start(audioContext.currentTime);
n@319 1548 this.bufferNode.stop(audioContext.currentTime+3);
n@319 1549 }
n@319 1550 };
n@319 1551
n@319 1552 this.constructTrack = function(file) {
n@319 1553 var reader = new FileReader();
n@319 1554 this.file = file;
n@319 1555 var audioObj = this;
n@319 1556 // Create callback to decode the data asynchronously
n@319 1557 reader.onloadend = function() {
n@319 1558 audioContext.decodeAudioData(reader.result, function(decodedData) {
n@319 1559 audioObj.bufferObject = decodedData;
n@319 1560 audioObj.state = 1;
n@319 1561 }, function(){});
n@319 1562 };
n@319 1563 reader.readAsArrayBuffer(file);
n@319 1564 };
n@319 1565 };
n@319 1566
n@311 1567 function Specification() {
n@311 1568 // Handles the decoding of the project specification XML into a simple JavaScript Object.
n@311 1569
n@311 1570 this.interfaceType = null;
n@311 1571 this.commonInterface = new function()
n@311 1572 {
n@311 1573 this.options = [];
n@311 1574 this.optionNode = function(input)
n@311 1575 {
n@311 1576 var name = input.getAttribute('name');
n@311 1577 this.type = name;
n@311 1578 if(this.type == "option")
n@311 1579 {
n@311 1580 this.name = input.id;
n@311 1581 } else if (this.type == "check")
n@311 1582 {
n@311 1583 this.check = input.id;
n@311 1584 }
n@311 1585 };
n@311 1586 };
n@311 1587 this.projectReturn = null;
n@311 1588 this.randomiseOrder = null;
n@311 1589 this.collectMetrics = null;
n@311 1590 this.testPages = null;
n@311 1591 this.audioHolders = [];
n@319 1592 this.metrics = [];
n@311 1593
n@311 1594 this.decode = function() {
n@311 1595 // projectXML - DOM Parsed document
n@311 1596 this.projectXML = projectXML.childNodes[0];
n@311 1597 var setupNode = projectXML.getElementsByTagName('setup')[0];
n@311 1598 this.interfaceType = setupNode.getAttribute('interface');
n@311 1599 this.projectReturn = setupNode.getAttribute('projectReturn');
n@311 1600 this.testPages = setupNode.getAttribute('testPages');
n@311 1601 if (setupNode.getAttribute('randomiseOrder') == "true") {
n@311 1602 this.randomiseOrder = true;
n@311 1603 } else {this.randomiseOrder = false;}
n@311 1604 if (setupNode.getAttribute('collectMetrics') == "true") {
n@311 1605 this.collectMetrics = true;
n@311 1606 } else {this.collectMetrics = false;}
n@311 1607 if (isNaN(Number(this.testPages)) || this.testPages == undefined)
n@311 1608 {
n@311 1609 this.testPages = null;
n@311 1610 } else {
n@311 1611 this.testPages = Number(this.testPages);
n@311 1612 if (this.testPages == 0) {this.testPages = null;}
n@162 1613 }
n@311 1614 var metricCollection = setupNode.getElementsByTagName('Metric');
n@162 1615
n@311 1616 this.preTest = new this.prepostNode('pretest',setupNode.getElementsByTagName('PreTest'));
n@311 1617 this.postTest = new this.prepostNode('posttest',setupNode.getElementsByTagName('PostTest'));
n@163 1618
n@311 1619 if (metricCollection.length > 0) {
n@311 1620 metricCollection = metricCollection[0].getElementsByTagName('metricEnable');
n@311 1621 for (var i=0; i<metricCollection.length; i++) {
n@311 1622 this.metrics.push(new this.metricNode(metricCollection[i].textContent));
n@311 1623 }
n@172 1624 }
n@172 1625
n@311 1626 var commonInterfaceNode = setupNode.getElementsByTagName('interface');
n@311 1627 if (commonInterfaceNode.length > 0) {
n@311 1628 commonInterfaceNode = commonInterfaceNode[0];
n@311 1629 } else {
n@311 1630 commonInterfaceNode = undefined;
n@163 1631 }
n@163 1632
n@311 1633 this.commonInterface = new function() {
n@311 1634 this.OptionNode = function(child) {
n@311 1635 this.type = child.nodeName;
n@311 1636 if (this.type == 'option')
n@311 1637 {
n@311 1638 this.name = child.getAttribute('name');
n@311 1639 }
n@311 1640 else if (this.type == 'check') {
n@311 1641 this.check = child.getAttribute('name');
n@311 1642 if (this.check == 'scalerange') {
n@311 1643 this.min = child.getAttribute('min');
n@311 1644 this.max = child.getAttribute('max');
n@311 1645 if (this.min == null) {this.min = 1;}
n@311 1646 else if (Number(this.min) > 1 && this.min != null) {
n@311 1647 this.min = Number(this.min)/100;
n@311 1648 } else {
n@311 1649 this.min = Number(this.min);
n@311 1650 }
n@311 1651 if (this.max == null) {this.max = 0;}
n@311 1652 else if (Number(this.max) > 1 && this.max != null) {
n@311 1653 this.max = Number(this.max)/100;
n@311 1654 } else {
n@311 1655 this.max = Number(this.max);
n@311 1656 }
n@311 1657 }
n@311 1658 } else if (this.type == 'anchor' || this.type == 'reference') {
n@311 1659 this.value = Number(child.textContent);
n@311 1660 this.enforce = child.getAttribute('enforce');
n@311 1661 if (this.enforce == 'true') {this.enforce = true;}
n@311 1662 else {this.enforce = false;}
n@311 1663 }
n@311 1664 };
n@311 1665 this.options = [];
n@311 1666 if (commonInterfaceNode != undefined) {
n@311 1667 var child = commonInterfaceNode.firstElementChild;
n@311 1668 while (child != undefined) {
n@311 1669 this.options.push(new this.OptionNode(child));
n@311 1670 child = child.nextElementSibling;
n@311 1671 }
n@311 1672 }
n@311 1673 };
n@311 1674
n@311 1675 var audioHolders = projectXML.getElementsByTagName('audioHolder');
n@311 1676 for (var i=0; i<audioHolders.length; i++) {
n@311 1677 this.audioHolders.push(new this.audioHolderNode(this,audioHolders[i]));
n@166 1678 }
n@167 1679
n@311 1680 // New check if we need to randomise the test order
n@311 1681 if (this.randomiseOrder)
n@311 1682 {
n@311 1683 this.audioHolders = randomiseOrder(this.audioHolders);
n@311 1684 for (var i=0; i<this.audioHolders.length; i++)
n@311 1685 {
n@311 1686 this.audioHolders[i].presentedId = i;
n@311 1687 }
n@167 1688 }
n@311 1689
n@311 1690 if (this.testPages != null || this.testPages != undefined)
n@311 1691 {
n@311 1692 if (this.testPages > audioHolders.length)
n@311 1693 {
n@311 1694 console.log('Warning: You have specified '+audioHolders.length+' tests but requested '+this.testPages+' be completed!');
n@311 1695 this.testPages = audioHolders.length;
n@311 1696 }
n@311 1697 var aH = this.audioHolders;
n@311 1698 this.audioHolders = [];
n@311 1699 for (var i=0; i<this.testPages; i++)
n@311 1700 {
n@311 1701 this.audioHolders.push(aH[i]);
n@162 1702 }
n@162 1703 }
n@311 1704 };
n@163 1705
n@319 1706 this.prepostNode = function(type) {
n@311 1707 this.type = type;
n@311 1708 this.options = [];
n@311 1709
n@319 1710 this.OptionNode = function() {
n@311 1711
n@319 1712 this.childOption = function() {
n@311 1713 this.type = 'option';
n@311 1714 this.id = element.id;
n@311 1715 this.name = element.getAttribute('name');
n@311 1716 this.text = element.textContent;
n@311 1717 };
n@311 1718
n@319 1719 this.type = undefined;
n@319 1720 this.id = undefined;
n@319 1721 this.mandatory = undefined;
n@319 1722 this.question = undefined;
n@319 1723 this.statement = undefined;
n@319 1724 this.boxsize = undefined;
n@319 1725 this.options = [];
n@319 1726 this.min = undefined;
n@319 1727 this.max = undefined;
n@319 1728 this.step = undefined;
n@319 1729
n@311 1730 };
n@172 1731 };
n@172 1732
n@311 1733 this.metricNode = function(name) {
n@311 1734 this.enabled = name;
n@311 1735 };
n@172 1736
n@319 1737 this.audioHolderNode = function(parent) {
n@311 1738 this.type = 'audioHolder';
n@319 1739 this.presentedId = undefined;
n@319 1740 this.id = undefined;
n@319 1741 this.hostURL = undefined;
n@319 1742 this.sampleRate = undefined;
n@319 1743 this.randomiseOrder = undefined;
n@319 1744 this.loop = undefined;
n@319 1745 this.elementComments = undefined;
n@319 1746 this.preTest = new parent.prepostNode('pretest');
n@319 1747 this.postTest = new parent.prepostNode('posttest');
n@319 1748 this.interfaces = [];
n@319 1749 this.commentBoxPrefix = "Comment on track";
n@319 1750 this.audioElements = [];
n@319 1751 this.commentQuestions = [];
n@319 1752
n@311 1753 this.interfaceNode = function(DOM) {
n@311 1754 var title = DOM.getElementsByTagName('title');
n@311 1755 if (title.length == 0) {this.title = null;}
n@311 1756 else {this.title = title[0].textContent;}
n@311 1757 this.options = parent.commonInterface.options;
n@311 1758 var scale = DOM.getElementsByTagName('scale');
n@311 1759 this.scale = [];
n@311 1760 for (var i=0; i<scale.length; i++) {
n@311 1761 var arr = [null, null];
n@311 1762 arr[0] = scale[i].getAttribute('position');
n@311 1763 arr[1] = scale[i].textContent;
n@311 1764 this.scale.push(arr);
n@311 1765 }
n@311 1766 };
n@311 1767
n@319 1768 this.audioElementNode = function(parent,audioObject) {
n@319 1769 this.url = audioObject.file.name;
n@319 1770 this.id = audioObject.id;
n@311 1771 this.parent = parent;
n@319 1772 this.type = "normal";
n@311 1773
n@319 1774 this.marker = undefined;
n@311 1775 };
n@311 1776
n@311 1777 this.commentQuestionNode = function(xml) {
n@311 1778 this.childOption = function(element) {
n@311 1779 this.type = 'option';
n@311 1780 this.name = element.getAttribute('name');
n@311 1781 this.text = element.textContent;
n@311 1782 };
n@311 1783 this.id = xml.id;
n@311 1784 if (xml.getAttribute('mandatory') == 'true') {this.mandatory = true;}
n@311 1785 else {this.mandatory = false;}
n@311 1786 this.type = xml.getAttribute('type');
n@311 1787 if (this.type == undefined) {this.type = 'text';}
n@311 1788 switch (this.type) {
n@311 1789 case 'text':
n@311 1790 this.question = xml.textContent;
n@311 1791 break;
n@311 1792 case 'radio':
n@311 1793 var child = xml.firstElementChild;
n@311 1794 this.options = [];
n@311 1795 while (child != undefined) {
n@311 1796 if (child.nodeName == 'statement' && this.statement == undefined) {
n@311 1797 this.statement = child.textContent;
n@311 1798 } else if (child.nodeName == 'option') {
n@311 1799 this.options.push(new this.childOption(child));
n@311 1800 }
n@311 1801 child = child.nextElementSibling;
n@311 1802 }
n@311 1803 break;
n@311 1804 case 'checkbox':
n@311 1805 var child = xml.firstElementChild;
n@311 1806 this.options = [];
n@311 1807 while (child != undefined) {
n@311 1808 if (child.nodeName == 'statement' && this.statement == undefined) {
n@311 1809 this.statement = child.textContent;
n@311 1810 } else if (child.nodeName == 'option') {
n@311 1811 this.options.push(new this.childOption(child));
n@311 1812 }
n@311 1813 child = child.nextElementSibling;
n@311 1814 }
n@311 1815 break;
n@311 1816 }
n@311 1817 };
n@319 1818 };
n@319 1819
n@319 1820 this.preTest = new this.prepostNode("pretest");
n@319 1821 this.postTest = new this.prepostNode("posttest");
n@319 1822 }
n@319 1823 function SpecficationToHTML()
n@319 1824 {
n@319 1825 // Take information from Specification Node and format it into an HTML layout
n@319 1826 var destination = document.getElementById("content");
n@319 1827 // Setup Header Node
n@319 1828 var setupNode = document.createElement("div");
n@319 1829 setupNode.className = "topLevel";
n@319 1830 setupNode.name = "setup";
n@319 1831 var title = document.createElement("h2");
n@319 1832 title.textContent = "Setup";
n@319 1833 setupNode.appendChild(title);
n@319 1834 // Interface Type
n@319 1835 var div = document.createElement("div");
n@319 1836 div.name = "attributes";
n@319 1837 div.style.margin = "5px";
n@319 1838 var select = document.createElement("select");
n@319 1839 select.id = "interfaceSelect";
n@319 1840 select.style.margin = "5px";
n@319 1841 var option = document.createElement("option");
n@319 1842 option.value = "APE";
n@319 1843 option.textContent = "APE";
n@319 1844 select.appendChild(option);
n@319 1845 option = document.createElement("option");
n@319 1846 option.value = "MUSHRA";
n@319 1847 option.textContent = "MUSHRA";
n@319 1848 select.appendChild(option);
n@319 1849 select.value = specificationNode.interfaceType;
n@319 1850 var span = document.createElement("span");
n@319 1851 span.textContent = "Interface Type";
n@319 1852 div.appendChild(span);
n@319 1853 div.appendChild(select);
n@319 1854 // Project Return Attribute
n@319 1855 span = document.createElement("span");
n@319 1856 span.style.margin = "5px";
n@319 1857 span.textContent = "Project Return";
n@319 1858 var input = document.createElement("input");
n@319 1859 input.value = specificationNode.projectReturn;
n@319 1860 input.id = "projectReturn";
n@319 1861 input.style.margin = "5px";
n@319 1862 div.appendChild(span);
n@319 1863 div.appendChild(input);
n@319 1864 // Randomise Order
n@319 1865 span = document.createElement("span");
n@319 1866 span.textContent = "Randomise Order";
n@319 1867 input = document.createElement("input");
n@319 1868 input.id = "randomiseOrder";
n@319 1869 input.style.margin = "5px";
n@319 1870 input.type = "checkbox";
n@319 1871 input.value = specificationNode.projectReturn;
n@319 1872 div.appendChild(span);
n@319 1873 div.appendChild(input);
n@319 1874 setupNode.appendChild(div);
n@319 1875
n@319 1876 // Now create the common Interface Node
n@319 1877 var commonInterface = document.createElement("div");
n@319 1878 commonInterface.id = "interface";
n@319 1879 commonInterface.className = "SecondLevel";
n@319 1880 var title = document.createElement("h3");
n@319 1881 title.textContent = "Common Interface";
n@319 1882 commonInterface.appendChild(title);
n@319 1883 var div = document.createElement("div");
n@319 1884 div.name = "attributes";
n@319 1885 var interfaceOptions;
n@319 1886 var interfaceChecks;
n@319 1887 switch(select.value)
n@319 1888 {
n@319 1889 case "APE":
n@319 1890 interfaceOptions = APEInterfaceOptions;
n@319 1891 interfaceChecks = APEInterfaceChecks;
n@319 1892 break;
n@319 1893 case "MUSHRA":
n@319 1894 interfaceOptions = MUSHRAInterfaceOptions;
n@319 1895 interfaceChecks = MUSHRAInterfaceChecks;
n@319 1896 break;
n@319 1897 }
n@319 1898 for (var i=0; i<interfaceOptions[0].length; i++)
n@319 1899 {
n@319 1900 var span = document.createElement("span");
n@319 1901 span.textContent = interfaceOptions[1][i];
n@319 1902 var input = document.createElement("input");
n@319 1903 input.type = "checkbox";
n@319 1904 input.id = interfaceOptions[0][i];
n@319 1905 div.appendChild(input);
n@319 1906 div.appendChild(span);
n@319 1907 commonInterface.appendChild(div);
n@319 1908 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
n@319 1909 {
n@319 1910 if (specificationNode.commonInterface.options[j].name == interfaceOptions[0][i])
n@319 1911 {
n@319 1912 input.checked = true;
n@319 1913 break;
n@319 1914 }
n@319 1915 }
n@319 1916 }
n@319 1917 for (var i=0; i<interfaceChecks[0].length; i++)
n@319 1918 {
n@319 1919 var span = document.createElement("span");
n@319 1920 span.textContent = interfaceChecks[1][i];
n@319 1921 var input = document.createElement("input");
n@319 1922 input.type = "checkbox";
n@319 1923 input.id = interfaceChecks[0][i];
n@319 1924 div.appendChild(input);
n@319 1925 div.appendChild(span);
n@319 1926 commonInterface.appendChild(div);
n@319 1927 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
n@319 1928 {
n@319 1929 if (specificationNode.commonInterface.options[j].check == interfaceChecks[0][i])
n@319 1930 {
n@319 1931 input.checked = true;
n@319 1932 break;
n@319 1933 }
n@319 1934 }
n@319 1935 }
n@319 1936 setupNode.appendChild(commonInterface);
n@319 1937 // Now the Metric Node
n@319 1938 var metrics = document.createElement("div");
n@319 1939 metrics.id = "metrics";
n@319 1940 metrics.className = "SecondLevel";
n@319 1941 var title = document.createElement("h3");
n@319 1942 title.textContent = "Metric Collections";
n@319 1943 metrics.appendChild(title);
n@319 1944 var div = document.createElement("div");
n@319 1945 div.name = "attributes";
n@319 1946 metrics.appendChild(div);
n@319 1947 var supportedMetrics;
n@319 1948 switch(select.value)
n@319 1949 {
n@319 1950 case "APE":
n@319 1951 supportedMetrics = APEInterfaceMetrics;
n@319 1952 break;
n@319 1953 case "MUSHRA":
n@319 1954 supportedMetrics = MUSHRAInterfaceMetrics;
n@319 1955 break;
n@319 1956 }
n@319 1957
n@319 1958 for (var i=0; i<supportedMetrics[0].length; i++)
n@319 1959 {
n@319 1960 var span = document.createElement("span");
n@319 1961 span.textContent = supportedMetrics[1][i];
n@319 1962 var input = document.createElement("input");
n@319 1963 input.type = "checkbox";
n@319 1964 input.id = supportedMetrics[0][i];
n@319 1965 div.appendChild(input);
n@319 1966 div.appendChild(span);
n@319 1967 for (var j=0; j<specificationNode.metrics.length; j++)
n@319 1968 {
n@319 1969 if (specificationNode.metrics[j].enabled == supportedMetrics[0][i])
n@319 1970 {
n@319 1971 input.checked = true;
n@319 1972 }
n@319 1973 }
n@319 1974 }
n@319 1975
n@319 1976 setupNode.appendChild(metrics);
n@319 1977
n@319 1978 // Test Session Pre Test
n@319 1979 var preTest = document.createElement("div");
n@319 1980 preTest.id = "preTest";
n@319 1981 preTest.className = "SecondLevel";
n@319 1982 var title = document.createElement("h3");
n@319 1983 title.textContent = "Pre test Survey";
n@319 1984 preTest.appendChild(title);
n@319 1985 var div = document.createElement("div");
n@319 1986 div.name = "attributes";
n@319 1987 for (var j=0; j<specificationNode.preTest.options.length; j++)
n@319 1988 {
n@319 1989 var node = PPSurveyToHTML(specificationNode.preTest.options[j]);
n@319 1990 node.className = "SecondLevel";
n@319 1991 node.id = preTest.id+"-"+j;
n@319 1992 preTest.appendChild(node);
n@319 1993 }
n@319 1994 setupNode.appendChild(preTest);
n@319 1995
n@319 1996 // Test Session Post Test
n@319 1997 var postTest = document.createElement("div");
n@319 1998 postTest.id = "postTest";
n@319 1999 postTest.className = "SecondLevel";
n@319 2000 var title = document.createElement("h3");
n@319 2001 title.textContent = "Post test Survey";
n@319 2002 postTest.appendChild(title);
n@319 2003 var div = document.createElement("div");
n@319 2004 div.name = "attributes";
n@319 2005
n@319 2006 for (var j=0; j<specificationNode.postTest.options.length; j++)
n@319 2007 {
n@319 2008 var node = PPSurveyToHTML(specificationNode.postTest.options[j]);
n@319 2009 node.className = "SecondLevel";
n@319 2010 node.id = postTest.id+"-"+j;
n@319 2011 postTest.appendChild(node);
n@319 2012 }
n@319 2013
n@319 2014 setupNode.appendChild(postTest);
n@319 2015
n@319 2016 destination.appendChild(setupNode);
n@319 2017
n@319 2018 // Now we step through the AudioHolders
n@319 2019 for (var i=0; i<specificationNode.audioHolders.length; i++)
n@319 2020 {
n@319 2021 var aH = specificationNode.audioHolders[i];
n@319 2022 var aHTML = document.createElement("div");
n@319 2023 aHTML.name = "audioHolder";
n@319 2024 aHTML.id = "audioHolder-"+aH.id;
n@319 2025 aHTML.className = "topLevel";
n@319 2026 destination.appendChild(aHTML);
n@319 2027 var title = document.createElement("h2");
n@319 2028 title.textContent = "Audio Holder "+aH.id;
n@319 2029 aHTML.appendChild(title);
n@319 2030 var attributes = document.createElement("div");
n@319 2031 attributes.name = "attributes";
n@319 2032 aHTML.appendChild(attributes);
n@319 2033 var text = document.createElement("span");
n@319 2034 text.textContent = "ID: ";
n@319 2035 var input = document.createElement("input");
n@319 2036 input.id = aHTML.id+"-id";
n@319 2037 input.value = aH.id;
n@319 2038 input.onchange = function()
n@319 2039 {
n@319 2040 event.currentTarget.parentElement.parentElement.childNodes[0].textContent = "Audio Holder "+event.currentTarget.value;
n@319 2041 };
n@319 2042 text.style.margin = "5px";
n@319 2043 input.style.margin = "5px";
n@319 2044 attributes.appendChild(text);
n@319 2045 attributes.appendChild(input);
n@319 2046 text = document.createElement("span");
n@319 2047 text.textContent = "Host URL: ";
n@319 2048 input = document.createElement("input");
n@319 2049 input.id = aHTML.id+"-hostURL";
n@319 2050 input.value = aH.hostURL;
n@319 2051 text.style.margin = "5px";
n@319 2052 input.style.margin = "5px";
n@319 2053 attributes.appendChild(text);
n@319 2054 attributes.appendChild(input);
n@319 2055 text = document.createElement("span");
n@319 2056 text.textContent = "Loop Fragments: ";
n@319 2057 input = document.createElement("input");
n@319 2058 input.id = aHTML.id+"-loop";
n@319 2059 input.type = "checkbox";
n@319 2060 input.checked = aH.loop;
n@319 2061 text.style.margin = "5px";
n@319 2062 input.style.margin = "5px";
n@319 2063 attributes.appendChild(text);
n@319 2064 attributes.appendChild(input);
n@319 2065 text = document.createElement("span");
n@319 2066 text.textContent = "Randomise Order: ";
n@319 2067 input = document.createElement("input");
n@319 2068 input.id = aHTML.id+"-randomiseOrder";
n@319 2069 input.type = "checkbox";
n@319 2070 input.checked = aH.randomiseOrder;
n@319 2071 text.style.margin = "5px";
n@319 2072 input.style.margin = "5px";
n@319 2073 attributes.appendChild(text);
n@319 2074 attributes.appendChild(input);
n@319 2075 text = document.createElement("span");
n@319 2076 text.textContent = "Show Fragment Comments";
n@319 2077 input = document.createElement("input");
n@319 2078 input.id = aHTML.id+"-elementComments";
n@319 2079 input.type = "checkbox";
n@319 2080 input.checked = aH.elementComments;
n@319 2081 text.style.margin = "5px";
n@319 2082 input.style.margin = "5px";
n@319 2083 attributes.appendChild(text);
n@319 2084 attributes.appendChild(input);
n@311 2085
n@319 2086 // Test Session Pre Test
n@319 2087 var preTest = document.createElement("div");
n@319 2088 preTest.id = aHTML.id+"-pretest";
n@319 2089 preTest.className = "SecondLevel";
n@319 2090 var title = document.createElement("h3");
n@319 2091 title.textContent = "Pre test Survey";
n@319 2092 preTest.appendChild(title);
n@319 2093 var div = document.createElement("div");
n@319 2094 div.name = "attributes";
n@311 2095
n@319 2096 for (var j=0; j<aH.preTest.options.length; j++)
n@319 2097 {
n@319 2098 var node = PPSurveyToHTML(aH.preTest.options[j]);
n@319 2099 node.className = "SecondLevel";
n@319 2100 node.id = preTest.id+"-"+j;
n@319 2101 preTest.appendChild(node);
n@169 2102 }
n@311 2103
n@319 2104 aHTML.appendChild(preTest);
n@319 2105
n@319 2106 // Test Session Post Test
n@319 2107 var postTest = document.createElement("div");
n@319 2108 postTest.id = aHTML.id+"-postTest";
n@319 2109 postTest.className = "SecondLevel";
n@319 2110 var title = document.createElement("h3");
n@319 2111 title.textContent = "Post test Survey";
n@319 2112 postTest.appendChild(title);
n@319 2113 var div = document.createElement("div");
n@319 2114 div.name = "attributes";
n@319 2115
n@319 2116 for (var j=0; j<aH.postTest.options.length; j++)
n@319 2117 {
n@319 2118 var node = PPSurveyToHTML(aH.postTest.options[j]);
n@319 2119 node.className = "SecondLevel";
n@319 2120 node.id = postTest.id+"-"+j;
n@319 2121 postTest.appendChild(node);
n@169 2122 }
n@169 2123
n@319 2124 aHTML.appendChild(postTest);
n@319 2125
n@319 2126 //Audio Elements
n@319 2127 var audioElems = document.createElement("div");
n@319 2128 audioElems.id = aHTML.id+"-audioElements";
n@319 2129 audioElems.className = "SecondLevel";
n@319 2130 var title = document.createElement("h3");
n@319 2131 title.textContent = "Audio Elements";
n@319 2132 audioElems.appendChild(title);
n@319 2133 for (var i=0; i<aH.audioElements.length; i++)
n@319 2134 {
n@319 2135 var entry = document.createElement("div");
n@319 2136 entry.className = "SecondLevel";
n@319 2137 entry.id = audioElems.id+"-"+aH.audioElements[i].id;
n@319 2138 var text = document.createElement("span");
n@319 2139 text.textContent = "ID:";
n@319 2140 var input = document.createElement("input");
n@319 2141 input.id = entry.id+"-id";
n@319 2142 input.value = aH.audioElements[i].id;
n@319 2143 text.style.margin = "5px";
n@319 2144 input.style.margin = "5px";
n@319 2145 entry.appendChild(text);
n@319 2146 entry.appendChild(input);
n@319 2147 text = document.createElement("span");
n@319 2148 text.textContent = "URL:";
n@319 2149 input = document.createElement("input");
n@319 2150 input.id = entry.id+"-URL";
n@319 2151 input.value = aH.audioElements[i].url;
n@319 2152 text.style.margin = "5px";
n@319 2153 input.style.margin = "5px";
n@319 2154 entry.appendChild(text);
n@319 2155 entry.appendChild(input);
n@319 2156 audioElems.appendChild(entry);
n@311 2157 }
n@311 2158
n@319 2159 aHTML.appendChild(audioElems);
n@319 2160 }
n@319 2161
n@319 2162 function PPSurveyToHTML(node)
n@319 2163 {
n@319 2164 var holder = document.createElement("div");
n@319 2165 var title = document.createElement("h4");
n@319 2166 holder.appendChild(title);
n@319 2167 var attributes = document.createElement("div");
n@319 2168 holder.appendChild(attributes);
n@319 2169 switch(node.type)
n@319 2170 {
n@319 2171 case "statement":
n@319 2172 title.textContent = "Statement";
n@319 2173 var tA = document.createElement("textarea");
n@319 2174 attributes.style.height = "150px";
n@319 2175 tA.style.width = "500px";
n@319 2176 tA.style.height = "100px";
n@319 2177 tA.value = node.statement;
n@319 2178 attributes.appendChild(tA);
n@319 2179 break;
n@319 2180 case "question":
n@319 2181 title.textContent = "Question";
n@319 2182 var text = document.createElement("span");
n@319 2183 text.textContent = "ID :";
n@319 2184 var input = document.createElement("input");
n@319 2185 input.name = "id";
n@319 2186 input.value = node.id;
n@319 2187 text.style.margin = "5px";
n@319 2188 input.style.margin = "5px";
n@319 2189 attributes.appendChild(text);
n@319 2190 attributes.appendChild(input);
n@319 2191 text = document.createElement("span");
n@319 2192 text.textContent = "Question";
n@319 2193 input = document.createElement("input");
n@319 2194 input.name = "question";
n@319 2195 input.value = node.question;
n@319 2196 text.style.margin = "5px";
n@319 2197 input.style.margin = "5px";
n@319 2198 attributes.appendChild(text);
n@319 2199 attributes.appendChild(input);
n@319 2200 text = document.createElement("span");
n@319 2201 text.textContent = "Mandatory";
n@319 2202 input = document.createElement("input");
n@319 2203 input.name = "mandatory";
n@319 2204 input.type = "checkbox";
n@319 2205 input.checked = node.mandatory;
n@319 2206 text.style.margin = "5px";
n@319 2207 input.style.margin = "5px";
n@319 2208 attributes.appendChild(text);
n@319 2209 attributes.appendChild(input);
n@319 2210 break;
n@311 2211 }
n@319 2212 return holder;
n@319 2213 }
n@168 2214 }
n@157 2215 </script>
n@157 2216 <style>
n@311 2217 div.popup {
n@311 2218 width: 500px;
n@311 2219 position: absolute;
n@311 2220 height: 400px;
n@311 2221 background-color: #fff;
n@311 2222 border-radius: 10px;
n@311 2223 box-shadow: 0px 0px 50px #000;
n@311 2224 z-index: 2;
n@157 2225 }
n@311 2226
n@311 2227 button.popupButton {
n@311 2228 /* Button for popup window
n@311 2229 */
n@311 2230 min-width: 50px;
n@311 2231 height: 25px;
n@311 2232 position: relative;
n@311 2233 border-radius: 5px;
n@311 2234 border: #444;
n@311 2235 border-width: 1px;
n@311 2236 border-style: solid;
n@311 2237 background-color: #fff;
n@311 2238 }
n@311 2239
n@311 2240 div.dragndrop {
n@311 2241 margin-top: 10px;
n@311 2242 border:#000000;
n@311 2243 border-style: dashed;
n@157 2244 border-width: 2px;
n@157 2245 }
n@311 2246 div.dndheaderelement {
n@311 2247 float: left;
n@311 2248 height: 100%;
n@311 2249 border-right: #DDDDDD;
n@311 2250 border-right-width: 1px;
n@311 2251 border-right-style: solid;
n@157 2252 }
n@311 2253 div.dndheaderelement span{
n@311 2254 padding-left: 5px;
n@168 2255 }
n@319 2256
n@319 2257 div.topLevel {
n@319 2258 border: #000;
n@319 2259 border-style: solid;
n@319 2260 border-width: 5px;
n@319 2261 padding: 10px;
n@319 2262 margin: 10px;
n@319 2263 }
n@319 2264
n@319 2265 div.SecondLevel {
n@319 2266 border: #000;
n@319 2267 border-style: solid;
n@319 2268 border-width: 1px;
n@319 2269 padding: 10px;
n@319 2270 margin: 10px;
n@319 2271 }
n@157 2272 </style>
n@156 2273 </head>
n@156 2274
n@156 2275 <body>
n@311 2276 <div id="content"></div>
n@156 2277 </body>
n@156 2278 </html>