Mercurial > hg > webaudioevaluationtool
comparison js/core.js @ 3013:5acdaf4c14c3
Merge branch 'vnext' into Dev_main
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Wed, 06 Sep 2017 14:50:13 +0100 |
parents | a10cbbccc4f3 3342bc1f3256 |
children | 664065577426 |
comparison
equal
deleted
inserted
replaced
3011:03b9e845f730 | 3013:5acdaf4c14c3 |
---|---|
675 node.response = []; | 675 node.response = []; |
676 } | 676 } |
677 var table = document.createElement("table"); | 677 var table = document.createElement("table"); |
678 table.className = "popup-option-list"; | 678 table.className = "popup-option-list"; |
679 table.border = "0"; | 679 table.border = "0"; |
680 var nodelist = []; | |
680 node.specification.options.forEach(function (option, index) { | 681 node.specification.options.forEach(function (option, index) { |
681 var tr = document.createElement("tr"); | 682 var tr = document.createElement("tr"); |
682 table.appendChild(tr); | 683 nodelist.push(tr); |
683 var td = document.createElement("td"); | 684 var td = document.createElement("td"); |
684 tr.appendChild(td); | 685 tr.appendChild(td); |
685 var input = document.createElement('input'); | 686 var input = document.createElement('input'); |
686 input.id = option.name; | 687 input.id = option.name; |
687 input.type = 'checkbox'; | 688 input.type = 'checkbox'; |
693 span.textContent = option.text; | 694 span.textContent = option.text; |
694 td.appendChild(span); | 695 td.appendChild(span); |
695 tr = document.createElement('div'); | 696 tr = document.createElement('div'); |
696 tr.setAttribute('name', 'option'); | 697 tr.setAttribute('name', 'option'); |
697 tr.className = "popup-option-checbox"; | 698 tr.className = "popup-option-checbox"; |
698 if (node.response[index] !== undefined) { | 699 var resp = undefined; |
699 if (node.response[index].checked === true) { | 700 if (node.response.length > 0) { |
701 resp = node.response.find(function (a) { | |
702 return a.name == option.name; | |
703 }); | |
704 } | |
705 if (resp !== undefined) { | |
706 if (resp.checked === true) { | |
700 input.checked = "true"; | 707 input.checked = "true"; |
701 } | 708 } |
709 } else { | |
710 node.response.push({ | |
711 "name": option.name, | |
712 "text": option.text, | |
713 "checked": false | |
714 }); | |
702 } | 715 } |
703 index++; | 716 index++; |
717 }); | |
718 if (node.specification.randomise) { | |
719 nodelist = randomiseOrder(nodelist); | |
720 } | |
721 nodelist.forEach(function (e) { | |
722 table.appendChild(e); | |
704 }); | 723 }); |
705 this.popupResponse.appendChild(table); | 724 this.popupResponse.appendChild(table); |
706 } | 725 } |
707 | 726 |
708 function processCheckbox(node) { | 727 function processCheckbox(node) { |
709 console.log("Checkbox: " + node.specification.statement); | 728 console.log("Checkbox: " + node.specification.statement); |
710 var inputs = this.popupResponse.getElementsByTagName('input'); | 729 var inputs = this.popupResponse.getElementsByTagName('input'); |
711 node.response = []; | |
712 var numChecked = 0, | 730 var numChecked = 0, |
713 i; | 731 i; |
714 for (i = 0; i < node.specification.options.length; i++) { | 732 for (i = 0; i < node.specification.options.length; i++) { |
715 if (inputs[i].checked) { | 733 if (inputs[i].checked) { |
716 numChecked++; | 734 numChecked++; |
736 return false; | 754 return false; |
737 } | 755 } |
738 } | 756 } |
739 } | 757 } |
740 for (i = 0; i < node.specification.options.length; i++) { | 758 for (i = 0; i < node.specification.options.length; i++) { |
741 node.response.push({ | 759 node.response.forEach(function (a) { |
742 name: node.specification.options[i].name, | 760 var input = this.popupResponse.querySelector("#" + a.name); |
743 text: node.specification.options[i].text, | 761 a.checked = input.checked; |
744 checked: inputs[i].checked | |
745 }); | 762 }); |
746 console.log(node.specification.options[i].name + ": " + inputs[i].checked); | 763 console.log(node.specification.options[i].name + ": " + inputs[i].checked); |
747 } | 764 } |
748 processConditional.call(this, node, node.response); | 765 processConditional.call(this, node, node.response); |
749 return true; | 766 return true; |
779 }; | 796 }; |
780 } | 797 } |
781 var table = document.createElement("table"); | 798 var table = document.createElement("table"); |
782 table.className = "popup-option-list"; | 799 table.className = "popup-option-list"; |
783 table.border = "0"; | 800 table.border = "0"; |
784 if (node.response === null || node.response.length === 0) { | 801 var nodelist = []; |
785 node.response = []; | |
786 } | |
787 node.specification.options.forEach(function (option, index) { | 802 node.specification.options.forEach(function (option, index) { |
788 var tr = document.createElement("tr"); | 803 var tr = document.createElement("tr"); |
789 table.appendChild(tr); | 804 nodelist.push(tr); |
790 var td = document.createElement("td"); | 805 var td = document.createElement("td"); |
791 tr.appendChild(td); | 806 tr.appendChild(td); |
792 var input = document.createElement('input'); | 807 var input = document.createElement('input'); |
793 input.id = option.name; | 808 input.id = option.name; |
794 input.type = 'radio'; | 809 input.type = 'radio'; |
800 var span = document.createElement('span'); | 815 var span = document.createElement('span'); |
801 span.textContent = option.text; | 816 span.textContent = option.text; |
802 td.appendChild(span); | 817 td.appendChild(span); |
803 tr = document.createElement('div'); | 818 tr = document.createElement('div'); |
804 tr.setAttribute('name', 'option'); | 819 tr.setAttribute('name', 'option'); |
805 tr.className = "popup-option-checbox"; | 820 tr.className = "popup-option-checkbox"; |
806 table.appendChild(tr); | 821 if (node.response.name === option.name) { |
822 input.checked = true; | |
823 } | |
824 }); | |
825 if (node.specification.randomise) { | |
826 nodelist = randomiseOrder(nodelist); | |
827 } | |
828 nodelist.forEach(function (e) { | |
829 table.appendChild(e); | |
807 }); | 830 }); |
808 this.popupResponse.appendChild(table); | 831 this.popupResponse.appendChild(table); |
809 } | 832 } |
810 | 833 |
811 function processRadio(node) { | 834 function processRadio(node) { |
1966 this.bufferNode.loop = audioEngineContext.loopPlayback; | 1989 this.bufferNode.loop = audioEngineContext.loopPlayback; |
1967 this.bufferNode.onended = function (event) { | 1990 this.bufferNode.onended = function (event) { |
1968 // Safari does not like using 'this' to reference the calling object! | 1991 // Safari does not like using 'this' to reference the calling object! |
1969 //event.currentTarget.owner.metric.stopListening(audioEngineContext.timer.getTestTime(),event.currentTarget.owner.getCurrentPosition()); | 1992 //event.currentTarget.owner.metric.stopListening(audioEngineContext.timer.getTestTime(),event.currentTarget.owner.getCurrentPosition()); |
1970 if (event.currentTarget !== null) { | 1993 if (event.currentTarget !== null) { |
1971 event.currentTarget.owner.stop(audioContext.currentTime + 1); | 1994 event.currentTarget.owner.stop(audioContext.currentTime + 0.1); |
1972 } | 1995 } |
1973 }; | 1996 }; |
1974 this.outputGain.gain.cancelScheduledValues(audioContext.currentTime); | 1997 this.outputGain.gain.cancelScheduledValues(audioContext.currentTime); |
1975 if (!audioEngineContext.loopPlayback || !audioEngineContext.synchPlayback) { | 1998 if (!audioEngineContext.loopPlayback || !audioEngineContext.synchPlayback) { |
1976 this.metric.startListening(audioEngineContext.timer.getTestTime()); | 1999 this.metric.startListening(audioEngineContext.timer.getTestTime()); |
1977 this.outputGain.gain.linearRampToValueAtTime(this.onplayGain, startTime + specification.crossFade); | 2000 if (this.outputGain.gain.value !== this.onplayGain) { |
2001 this.outputGain.gain.linearRampToValueAtTime(this.onplayGain, startTime + Number(specification.crossFade)); | |
2002 } | |
1978 this.interfaceDOM.startPlayback(); | 2003 this.interfaceDOM.startPlayback(); |
1979 } else { | 2004 } else { |
1980 this.outputGain.gain.linearRampToValueAtTime(0.0, startTime); | 2005 this.outputGain.gain.linearRampToValueAtTime(0.0, startTime); |
1981 } | 2006 } |
1982 if (audioEngineContext.loopPlayback) { | 2007 if (audioEngineContext.loopPlayback) { |