comparison js/core.js @ 3055:95af70fef794

Merge branch 'vnext' into Dev_main # Conflicts: # js/core.js
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 31 Oct 2017 10:00:19 +0000
parents 3f34bb9c4762 aa1ceca04519
children 01ca365f350d
comparison
equal deleted inserted replaced
3053:3f34bb9c4762 3055:95af70fef794
1113 this.buttonProceed.textContent = 'Submit'; 1113 this.buttonProceed.textContent = 'Submit';
1114 } 1114 }
1115 } else { 1115 } else {
1116 this.buttonProceed.textContent = 'Next'; 1116 this.buttonProceed.textContent = 'Next';
1117 } 1117 }
1118 if (this.currentIndex > 0 && this.node.showBackButton) 1118 if (this.currentIndex > 0)
1119 this.buttonPrevious.style.visibility = 'visible'; 1119 this.buttonPrevious.style.visibility = 'visible';
1120 else 1120 else
1121 this.buttonPrevious.style.visibility = 'hidden'; 1121 this.buttonPrevious.style.visibility = 'hidden';
1122 }; 1122 };
1123 1123
2642 } 2642 }
2643 this.holder.style.width = boxwidth + "px"; 2643 this.holder.style.width = boxwidth + "px";
2644 this.textArea.style.width = boxwidth - 6 + "px"; 2644 this.textArea.style.width = boxwidth - 6 + "px";
2645 }; 2645 };
2646 this.resize(); 2646 this.resize();
2647 this.check = function () {
2648 if (this.specification.mandatory && this.textArea.value.length == 0) {
2649 return false;
2650 }
2651 return true;
2652 }
2653 }; 2647 };
2654 2648
2655 this.radioBox = function (commentQuestion) { 2649 this.radioBox = function (commentQuestion) {
2656 this.specification = commentQuestion; 2650 this.specification = commentQuestion;
2657 // Create document objects to hold the comment boxes 2651 // Create document objects to hold the comment boxes
2723 boxwidth = 400; 2717 boxwidth = 400;
2724 } 2718 }
2725 this.holder.style.width = boxwidth + "px"; 2719 this.holder.style.width = boxwidth + "px";
2726 }; 2720 };
2727 this.resize(); 2721 this.resize();
2728 this.check = function () {
2729 if (this.specification.mandatory) {
2730 var selected = this.options.find(function (o) {
2731 return o.checked;
2732 });
2733 if (selected === undefined) {
2734 return false;
2735 }
2736 }
2737 return true;
2738 };
2739 }; 2722 };
2740 2723
2741 this.checkboxBox = function (commentQuestion) { 2724 this.checkboxBox = function (commentQuestion) {
2742 this.specification = commentQuestion; 2725 this.specification = commentQuestion;
2743 // Create document objects to hold the comment boxes 2726 // Create document objects to hold the comment boxes
2800 boxwidth = 400; 2783 boxwidth = 400;
2801 } 2784 }
2802 this.holder.style.width = boxwidth + "px"; 2785 this.holder.style.width = boxwidth + "px";
2803 }; 2786 };
2804 this.resize(); 2787 this.resize();
2805 this.check = function () {
2806 if (this.specification.mandatory) {
2807 var selected = this.options.filter(function (o) {
2808 return o.checked;
2809 });
2810 if (selected.length === 0) {
2811 return false;
2812 }
2813 }
2814 return true;
2815 };
2816 }; 2788 };
2817 2789
2818 this.sliderBox = function (commentQuestion) { 2790 this.sliderBox = function (commentQuestion) {
2819 this.specification = commentQuestion; 2791 this.specification = commentQuestion;
2820 this.holder = document.createElement("div"); 2792 this.holder = document.createElement("div");
2868 } 2840 }
2869 this.holder.style.width = boxwidth + "px"; 2841 this.holder.style.width = boxwidth + "px";
2870 this.slider.style.width = boxwidth - 24 + "px"; 2842 this.slider.style.width = boxwidth - 24 + "px";
2871 }; 2843 };
2872 this.resize(); 2844 this.resize();
2873 this.check = function () {
2874 return true;
2875 };
2876 }; 2845 };
2877 2846
2878 this.createCommentQuestion = function (element) { 2847 this.createCommentQuestion = function (element) {
2879 var node; 2848 var node;
2880 if (element.type == 'question') { 2849 if (element.type == 'question') {
2891 }; 2860 };
2892 2861
2893 this.deleteCommentQuestions = function () { 2862 this.deleteCommentQuestions = function () {
2894 this.commentQuestions = []; 2863 this.commentQuestions = [];
2895 }; 2864 };
2896
2897 this.checkCommentQuestions = function () {
2898 var failed = this.commentQuestions.filter(function (a) {
2899 return a.check() === false;
2900 });
2901 if (failed.length === 0) {
2902 return true;
2903 }
2904 this.lightbox.post("Error", "Please answer the questions on the page.");
2905 return false;
2906 }
2907 2865
2908 this.outsideReferenceDOM = function (audioObject, index, inject) { 2866 this.outsideReferenceDOM = function (audioObject, index, inject) {
2909 this.parent = audioObject; 2867 this.parent = audioObject;
2910 this.outsideReferenceHolder = document.createElement('button'); 2868 this.outsideReferenceHolder = document.createElement('button');
2911 this.outsideReferenceHolder.className = 'outside-reference'; 2869 this.outsideReferenceHolder.className = 'outside-reference';
3064 3022
3065 volume.slider.min = -60; 3023 volume.slider.min = -60;
3066 volume.slider.max = 12; 3024 volume.slider.max = 12;
3067 volume.slider.value = 0; 3025 volume.slider.value = 0;
3068 volume.slider.step = 1; 3026 volume.slider.step = 1;
3069 volume.captured = false;
3070 volume.handleEvent = function (event) { 3027 volume.handleEvent = function (event) {
3071 if (event.type == "mousedown") { 3028 if (event.type == "mousemove" || event.type == "mouseup") {
3072 volume.captured = true;
3073 } else if (event.type == "mousemove" && volume.captured) {
3074 this.valueDB = Number(this.slider.value); 3029 this.valueDB = Number(this.slider.value);
3075 this.valueLin = decibelToLinear(this.valueDB); 3030 this.valueLin = decibelToLinear(this.valueDB);
3076 this.valueText.textContent = this.valueDB + 'dB'; 3031 this.valueText.textContent = this.valueDB + 'dB';
3077 audioEngineContext.outputGain.gain.value = this.valueLin; 3032 audioEngineContext.outputGain.gain.value = this.valueLin;
3078 console.log(this.valueDB); 3033 }
3079 } else if (event.type == "mouseup") { 3034 if (event.type == "mouseup") {
3080 volume.captured = false;
3081 this.onmouseup(); 3035 this.onmouseup();
3082 } 3036 }
3083 //this.slider.value = this.valueDB; 3037 this.slider.value = this.valueDB;
3084 3038
3085 if (event.stopPropagation) { 3039 if (event.stopPropagation) {
3086 event.stopPropagation(); 3040 event.stopPropagation();
3087 } 3041 }
3088 }; 3042 };
3101 node.setAttribute('format', 'dBFS'); 3055 node.setAttribute('format', 'dBFS');
3102 storePoint.appendChild(node); 3056 storePoint.appendChild(node);
3103 }; 3057 };
3104 volume.slider.addEventListener("mousemove", volume); 3058 volume.slider.addEventListener("mousemove", volume);
3105 volume.root.addEventListener("mouseup", volume); 3059 volume.root.addEventListener("mouseup", volume);
3106 volume.root.addEventListener("mousedown", volume);
3107 3060
3108 var title = document.createElement('div'); 3061 var title = document.createElement('div');
3109 title.innerHTML = '<span>Master Volume Control</span>'; 3062 title.innerHTML = '<span>Master Volume Control</span>';
3110 title.style.fontSize = '0.75em'; 3063 title.style.fontSize = '0.75em';
3111 title.style.width = "100%"; 3064 title.style.width = "100%";
3673 if (typeof specification.projectReturn == "string") { 3626 if (typeof specification.projectReturn == "string") {
3674 if (specification.projectReturn.substr(0, 4) == "http") { 3627 if (specification.projectReturn.substr(0, 4) == "http") {
3675 returnURL = specification.projectReturn; 3628 returnURL = specification.projectReturn;
3676 } 3629 }
3677 } 3630 }
3678 xmlhttp.open("POST", returnURL + "php/save.php?key=" + this.key + "&saveFilenamePrefix=" + this.parent.filenamePrefix + "&state=update"); 3631 xmlhttp.open("POST", returnURL + "php/save.php?key=" + this.key + "&saveFilenamePrefix=" + this.parent.filenamePrefix);
3679 xmlhttp.setRequestHeader('Content-Type', 'text/xml'); 3632 xmlhttp.setRequestHeader('Content-Type', 'text/xml');
3680 xmlhttp.onerror = function () { 3633 xmlhttp.onerror = function () {
3681 console.log('Error updating file to server!'); 3634 console.log('Error updating file to server!');
3682 }; 3635 };
3683 var hold = document.createElement("div"); 3636 var hold = document.createElement("div");
3711 if (this.parent.filenamePrefix.length === 0) { 3664 if (this.parent.filenamePrefix.length === 0) {
3712 saveURL += "save"; 3665 saveURL += "save";
3713 } else { 3666 } else {
3714 saveURL += this.parent.filenamePrefix; 3667 saveURL += this.parent.filenamePrefix;
3715 } 3668 }
3716 saveURL += "&state=finish";
3717 return new Promise(function (resolve, reject) { 3669 return new Promise(function (resolve, reject) {
3718 var xmlhttp = new XMLHttpRequest(); 3670 var xmlhttp = new XMLHttpRequest();
3719 xmlhttp.open("POST", saveURL); 3671 xmlhttp.open("POST", saveURL);
3720 xmlhttp.setRequestHeader('Content-Type', 'text/xml'); 3672 xmlhttp.setRequestHeader('Content-Type', 'text/xml');
3721 xmlhttp.onerror = function () { 3673 xmlhttp.onerror = function () {