Mercurial > hg > webaudioevaluationtool
comparison js/core.js @ 2361:c6c214cea795
Core.js no longer uses alert.
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Mon, 16 May 2016 16:10:24 +0100 |
parents | c296a817dff8 |
children | a6670226df24 |
comparison
equal
deleted
inserted
replaced
2360:c296a817dff8 | 2361:c6c214cea795 |
---|---|
320 } | 320 } |
321 /// CHECK FOR SAMPLE RATE COMPATIBILITY | 321 /// CHECK FOR SAMPLE RATE COMPATIBILITY |
322 if (specification.sampleRate != undefined) { | 322 if (specification.sampleRate != undefined) { |
323 if (Number(specification.sampleRate) != audioContext.sampleRate) { | 323 if (Number(specification.sampleRate) != audioContext.sampleRate) { |
324 var errStr = 'Sample rates do not match! Requested '+Number(specification.sampleRate)+', got '+audioContext.sampleRate+'. Please set the sample rate to match before completing this test.'; | 324 var errStr = 'Sample rates do not match! Requested '+Number(specification.sampleRate)+', got '+audioContext.sampleRate+'. Please set the sample rate to match before completing this test.'; |
325 alert(errStr); | 325 interfaceContext.lightbox.post("Error",errStr); |
326 return; | 326 return; |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 // Detect the interface to use and load the relevant javascripts. | 330 // Detect the interface to use and load the relevant javascripts. |
834 if (node.specification.type == 'question') { | 834 if (node.specification.type == 'question') { |
835 // Must extract the question data | 835 // Must extract the question data |
836 var textArea = $(popup.popupContent).find('textarea')[0]; | 836 var textArea = $(popup.popupContent).find('textarea')[0]; |
837 if (node.specification.mandatory == true && textArea.value.length == 0) { | 837 if (node.specification.mandatory == true && textArea.value.length == 0) { |
838 interfaceContext.lightbox.post("Error","This Question is mandatory"); | 838 interfaceContext.lightbox.post("Error","This Question is mandatory"); |
839 //alert('This question is mandatory'); | |
840 return; | 839 return; |
841 } else { | 840 } else { |
842 // Save the text content | 841 // Save the text content |
843 console.log("Question: "+ node.specification.statement); | 842 console.log("Question: "+ node.specification.statement); |
844 console.log("Question Response: "+ textArea.value); | 843 console.log("Question Response: "+ textArea.value); |
866 while(node.response == null) { | 865 while(node.response == null) { |
867 if (i == inputs.length) | 866 if (i == inputs.length) |
868 { | 867 { |
869 if (node.specification.mandatory == true) | 868 if (node.specification.mandatory == true) |
870 { | 869 { |
871 alert("This radio is mandatory"); | 870 interfaceContext.lightbox.post("Error","Please select one option"); |
872 return; | 871 return; |
873 } | 872 } |
874 break; | 873 break; |
875 } | 874 } |
876 if (inputs[i].checked == true) { | 875 if (inputs[i].checked == true) { |
880 i++; | 879 i++; |
881 } | 880 } |
882 } else if (node.specification.type == "number") { | 881 } else if (node.specification.type == "number") { |
883 var input = this.popupContent.getElementsByTagName('input')[0]; | 882 var input = this.popupContent.getElementsByTagName('input')[0]; |
884 if (node.mandatory == true && input.value.length == 0) { | 883 if (node.mandatory == true && input.value.length == 0) { |
885 alert('This question is mandatory. Please enter a number'); | 884 interfaceContext.lightbox.post("Error",'This question is mandatory. Please enter a number'); |
886 return; | 885 return; |
887 } | 886 } |
888 var enteredNumber = Number(input.value); | 887 var enteredNumber = Number(input.value); |
889 if (isNaN(enteredNumber)) { | 888 if (isNaN(enteredNumber)) { |
890 alert('Please enter a valid number'); | 889 interfaceContext.lightbox.post("Error",'Please enter a valid number'); |
891 return; | 890 return; |
892 } | 891 } |
893 if (enteredNumber < node.min && node.min != null) { | 892 if (enteredNumber < node.min && node.min != null) { |
894 alert('Number is below the minimum value of '+node.min); | 893 interfaceContext.lightbox.post("Error",'Number is below the minimum value of '+node.min); |
895 return; | 894 return; |
896 } | 895 } |
897 if (enteredNumber > node.max && node.max != null) { | 896 if (enteredNumber > node.max && node.max != null) { |
898 alert('Number is above the maximum value of '+node.max); | 897 interfaceContext.lightbox.post("Error",'Number is above the maximum value of '+node.max); |
899 return; | 898 return; |
900 } | 899 } |
901 node.response = input.value; | 900 node.response = input.value; |
902 } | 901 } |
903 this.currentIndex++; | 902 this.currentIndex++; |
2799 if (ao.specification.type == "anchor") | 2798 if (ao.specification.type == "anchor") |
2800 { | 2799 { |
2801 if (ao.interfaceDOM.getValue() > (ao.specification.marker/100) && ao.specification.marker > 0) { | 2800 if (ao.interfaceDOM.getValue() > (ao.specification.marker/100) && ao.specification.marker > 0) { |
2802 // Anchor is not set below | 2801 // Anchor is not set below |
2803 console.log('Anchor node not below marker value'); | 2802 console.log('Anchor node not below marker value'); |
2804 alert('Please keep listening'); | 2803 interfaceContext.lightbox.post("Message",'Please keep listening'); |
2805 this.storeErrorNode('Anchor node not below marker value'); | 2804 this.storeErrorNode('Anchor node not below marker value'); |
2806 return false; | 2805 return false; |
2807 } | 2806 } |
2808 } | 2807 } |
2809 } | 2808 } |
2818 { | 2817 { |
2819 if (ao.interfaceDOM.getValue() < (ao.specification.marker/100) && ao.specification.marker > 0) { | 2818 if (ao.interfaceDOM.getValue() < (ao.specification.marker/100) && ao.specification.marker > 0) { |
2820 // Anchor is not set below | 2819 // Anchor is not set below |
2821 console.log('Reference node not above marker value'); | 2820 console.log('Reference node not above marker value'); |
2822 this.storeErrorNode('Reference node not above marker value'); | 2821 this.storeErrorNode('Reference node not above marker value'); |
2823 alert('Please keep listening'); | 2822 interfaceContext.lightbox.post("Message",'Please keep listening'); |
2824 return false; | 2823 return false; |
2825 } | 2824 } |
2826 } | 2825 } |
2827 } | 2826 } |
2828 return true; | 2827 return true; |
2876 } | 2875 } |
2877 } | 2876 } |
2878 str_start += ". Please keep listening"; | 2877 str_start += ". Please keep listening"; |
2879 console.log("[ALERT]: "+str_start); | 2878 console.log("[ALERT]: "+str_start); |
2880 this.storeErrorNode("[ALERT]: "+str_start); | 2879 this.storeErrorNode("[ALERT]: "+str_start); |
2881 alert(str_start); | 2880 interfaceContext.lightbox.post("Error",str_start); |
2882 } | 2881 } |
2883 }; | 2882 }; |
2884 this.checkAllMoved = function() | 2883 this.checkAllMoved = function() |
2885 { | 2884 { |
2886 var str = "You have not moved "; | 2885 var str = "You have not moved "; |
2905 str += failed[i]+', '; | 2904 str += failed[i]+', '; |
2906 } | 2905 } |
2907 str += 'and '+failed[i]; | 2906 str += 'and '+failed[i]; |
2908 } | 2907 } |
2909 str +='.'; | 2908 str +='.'; |
2910 alert(str); | 2909 interfaceContext.lightbox.post("Error",str); |
2911 console.log(str); | 2910 console.log(str); |
2912 this.storeErrorNode(str); | 2911 this.storeErrorNode(str); |
2913 return false; | 2912 return false; |
2914 }; | 2913 }; |
2915 this.checkAllPlayed = function() | 2914 this.checkAllPlayed = function() |
2936 str += failed[i]+', '; | 2935 str += failed[i]+', '; |
2937 } | 2936 } |
2938 str += 'and '+failed[i]; | 2937 str += 'and '+failed[i]; |
2939 } | 2938 } |
2940 str +='.'; | 2939 str +='.'; |
2941 alert(str); | 2940 interfaceContext.lightbox.post("Error",str); |
2942 console.log(str); | 2941 console.log(str); |
2943 this.storeErrorNode(str); | 2942 this.storeErrorNode(str); |
2944 return false; | 2943 return false; |
2945 }; | 2944 }; |
2946 this.checkScaleRange = function(min, max) { | 2945 this.checkScaleRange = function(min, max) { |
2964 state = false; | 2963 state = false; |
2965 } | 2964 } |
2966 if (!state) { | 2965 if (!state) { |
2967 console.log(str); | 2966 console.log(str); |
2968 this.storeErrorNode(str); | 2967 this.storeErrorNode(str); |
2969 alert(str); | 2968 interfaceContext.lightbox.post("Error",str); |
2970 } | 2969 } |
2971 return state; | 2970 return state; |
2972 } | 2971 } |
2973 | 2972 |
2974 this.storeErrorNode = function(errorMessage) | 2973 this.storeErrorNode = function(errorMessage) |