comparison test_create/test_create.html @ 817:bc6c35b0a49d

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