Mercurial > hg > webaudioevaluationtool
comparison js/core.js @ 2360:c296a817dff8
New lightbox for #55
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Mon, 16 May 2016 16:06:42 +0100 |
parents | c812d5cc2dc6 |
children | c6c214cea795 |
comparison
equal
deleted
inserted
replaced
2359:971acb7e3fab | 2360:c296a817dff8 |
---|---|
169 loadProjectSpec(url); | 169 loadProjectSpec(url); |
170 window.onbeforeunload = function() { | 170 window.onbeforeunload = function() { |
171 return "Please only leave this page once you have completed the tests. Are you sure you have completed all testing?"; | 171 return "Please only leave this page once you have completed the tests. Are you sure you have completed all testing?"; |
172 }; | 172 }; |
173 } | 173 } |
174 interfaceContext.lightbox.resize(); | |
174 }; | 175 }; |
175 | 176 |
176 function loadProjectSpec(url) { | 177 function loadProjectSpec(url) { |
177 // Load the project document from the given URL, decode the XML and instruct audioEngine to get audio data | 178 // Load the project document from the given URL, decode the XML and instruct audioEngine to get audio data |
178 // If url is null, request client to upload project XML document | 179 // If url is null, request client to upload project XML document |
832 var node = this.popupOptions[this.currentIndex]; | 833 var node = this.popupOptions[this.currentIndex]; |
833 if (node.specification.type == 'question') { | 834 if (node.specification.type == 'question') { |
834 // Must extract the question data | 835 // Must extract the question data |
835 var textArea = $(popup.popupContent).find('textarea')[0]; | 836 var textArea = $(popup.popupContent).find('textarea')[0]; |
836 if (node.specification.mandatory == true && textArea.value.length == 0) { | 837 if (node.specification.mandatory == true && textArea.value.length == 0) { |
837 alert('This question is mandatory'); | 838 interfaceContext.lightbox.post("Error","This Question is mandatory"); |
839 //alert('This question is mandatory'); | |
838 return; | 840 return; |
839 } else { | 841 } else { |
840 // Save the text content | 842 // Save the text content |
841 console.log("Question: "+ node.specification.statement); | 843 console.log("Question: "+ node.specification.statement); |
842 console.log("Question Response: "+ textArea.value); | 844 console.log("Question Response: "+ textArea.value); |
1983 | 1985 |
1984 this.resizeWindow = function(event) | 1986 this.resizeWindow = function(event) |
1985 { | 1987 { |
1986 popup.resize(event); | 1988 popup.resize(event); |
1987 this.volume.resize(); | 1989 this.volume.resize(); |
1990 this.lightbox.resize(); | |
1988 for(var i=0; i<this.commentBoxes.length; i++) | 1991 for(var i=0; i<this.commentBoxes.length; i++) |
1989 {this.commentBoxes[i].resize();} | 1992 {this.commentBoxes[i].resize();} |
1990 for(var i=0; i<this.commentQuestions.length; i++) | 1993 for(var i=0; i<this.commentQuestions.length; i++) |
1991 {this.commentQuestions[i].resize();} | 1994 {this.commentQuestions[i].resize();} |
1992 try | 1995 try |
2041 hold.appendChild(date); | 2044 hold.appendChild(date); |
2042 hold.appendChild(time); | 2045 hold.appendChild(time); |
2043 return hold; | 2046 return hold; |
2044 | 2047 |
2045 } | 2048 } |
2049 | |
2050 this.lightbox = { | |
2051 parent: this, | |
2052 root: document.createElement("div"), | |
2053 content: document.createElement("div"), | |
2054 accept: document.createElement("button"), | |
2055 blanker: document.createElement("div"), | |
2056 post: function(type,message) { | |
2057 switch(type) { | |
2058 case "Error": | |
2059 this.content.className = "lightbox-error"; | |
2060 break; | |
2061 case "Warning": | |
2062 this.content.className = "lightbox-warning"; | |
2063 break; | |
2064 default: | |
2065 this.content.className = "lightbox-message"; | |
2066 break; | |
2067 } | |
2068 var msg = document.createElement("p"); | |
2069 msg.textContent = message; | |
2070 this.content.appendChild(msg); | |
2071 this.show(); | |
2072 }, | |
2073 show: function() { | |
2074 this.root.style.visibility = "visible"; | |
2075 this.blanker.style.visibility = "visible"; | |
2076 }, | |
2077 clear: function() { | |
2078 this.root.style.visibility = ""; | |
2079 this.blanker.style.visibility = ""; | |
2080 this.content.textContent = ""; | |
2081 }, | |
2082 handleEvent: function(event) { | |
2083 if (event.currentTarget == this.accept) { | |
2084 this.clear(); | |
2085 } | |
2086 }, | |
2087 resize: function(event) { | |
2088 this.root.style.left = (window.innerWidth/2)-250 + 'px'; | |
2089 } | |
2090 } | |
2091 | |
2092 this.lightbox.root.appendChild(this.lightbox.content); | |
2093 this.lightbox.root.appendChild(this.lightbox.accept); | |
2094 this.lightbox.root.className = "popupHolder"; | |
2095 this.lightbox.root.id = "lightbox-root"; | |
2096 this.lightbox.accept.className = "popupButton"; | |
2097 this.lightbox.accept.style.bottom = "10px"; | |
2098 this.lightbox.accept.textContent = "OK"; | |
2099 this.lightbox.accept.style.left = "237.5px"; | |
2100 this.lightbox.accept.addEventListener("click",this.lightbox); | |
2101 this.lightbox.blanker.className = "testHalt"; | |
2102 this.lightbox.blanker.id = "lightbox-blanker"; | |
2103 document.getElementsByTagName("body")[0].appendChild(this.lightbox.root); | |
2104 document.getElementsByTagName("body")[0].appendChild(this.lightbox.blanker); | |
2046 | 2105 |
2047 this.commentBoxes = new function() { | 2106 this.commentBoxes = new function() { |
2048 this.boxes = []; | 2107 this.boxes = []; |
2049 this.injectPoint = null; | 2108 this.injectPoint = null; |
2050 this.elementCommentBox = function(audioObject) { | 2109 this.elementCommentBox = function(audioObject) { |