annotate test_create/test_create.html @ 817:bc6c35b0a49d

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