annotate test_create/test_create.html @ 352:4ec19035710e Dev_main

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