Mercurial > hg > webaudioevaluationtool
comparison ape.js @ 671:9ea50bbcaf9a
Added customised scale - NEED TO ENTER INTO DOCUMENTATION!
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Fri, 10 Apr 2015 19:09:21 +0100 |
parents | 77c974fd7e60 |
children | d4e55184f776 |
comparison
equal
deleted
inserted
replaced
670:77c974fd7e60 | 671:9ea50bbcaf9a |
---|---|
77 titleSpan.innerHTML = 'APE Tool'; | 77 titleSpan.innerHTML = 'APE Tool'; |
78 } | 78 } |
79 // Insert the titleSpan element into the title div element. | 79 // Insert the titleSpan element into the title div element. |
80 title.appendChild(titleSpan); | 80 title.appendChild(titleSpan); |
81 | 81 |
82 var pagetitle = document.createElement('div'); | |
83 pagetitle.className = "pageTitle"; | |
84 pagetitle.align = "center"; | |
85 var titleSpan = document.createElement('span'); | |
86 titleSpan.id = "pageTitle"; | |
87 pagetitle.appendChild(titleSpan); | |
88 | |
82 // Store the return URL path in global projectReturn | 89 // Store the return URL path in global projectReturn |
83 projectReturn = xmlSetup[0].attributes['projectReturn'].value; | 90 projectReturn = xmlSetup[0].attributes['projectReturn'].value; |
84 | 91 |
85 // Create Interface buttons! | 92 // Create Interface buttons! |
86 var interfaceButtons = document.createElement('div'); | 93 var interfaceButtons = document.createElement('div'); |
128 // Must have a known EXACT width, as this is used later to determine the ratings | 135 // Must have a known EXACT width, as this is used later to determine the ratings |
129 canvas.style.width = width - 100 +"px"; | 136 canvas.style.width = width - 100 +"px"; |
130 canvas.align = "left"; | 137 canvas.align = "left"; |
131 sliderBox.appendChild(canvas); | 138 sliderBox.appendChild(canvas); |
132 | 139 |
140 // Create the div to hold any scale objects | |
141 var scale = document.createElement('div'); | |
142 scale.className = 'sliderScale'; | |
143 scale.id = 'sliderScaleHolder'; | |
144 scale.align = 'left'; | |
145 sliderBox.appendChild(scale); | |
146 | |
133 // Global parent for the comment boxes on the page | 147 // Global parent for the comment boxes on the page |
134 var feedbackHolder = document.createElement('div'); | 148 var feedbackHolder = document.createElement('div'); |
135 feedbackHolder.id = 'feedbackHolder'; | 149 feedbackHolder.id = 'feedbackHolder'; |
136 | 150 |
137 testContent.style.zIndex = 1; | 151 testContent.style.zIndex = 1; |
165 preTestPopupStart(preTest); | 179 preTestPopupStart(preTest); |
166 } | 180 } |
167 | 181 |
168 // Inject into HTML | 182 // Inject into HTML |
169 testContent.appendChild(title); // Insert the title | 183 testContent.appendChild(title); // Insert the title |
184 testContent.appendChild(pagetitle); | |
170 testContent.appendChild(interfaceButtons); | 185 testContent.appendChild(interfaceButtons); |
171 testContent.appendChild(sliderBox); | 186 testContent.appendChild(sliderBox); |
172 testContent.appendChild(feedbackHolder); | 187 testContent.appendChild(feedbackHolder); |
173 insertPoint.appendChild(testContent); | 188 insertPoint.appendChild(testContent); |
174 | 189 |
183 | 198 |
184 var feedbackHolder = document.getElementById('feedbackHolder'); | 199 var feedbackHolder = document.getElementById('feedbackHolder'); |
185 var canvas = document.getElementById('slider'); | 200 var canvas = document.getElementById('slider'); |
186 feedbackHolder.innerHTML = null; | 201 feedbackHolder.innerHTML = null; |
187 canvas.innerHTML = null; | 202 canvas.innerHTML = null; |
203 | |
204 // Setup question title | |
205 var interfaceObj = $(textXML).find('interface'); | |
206 var titleNode = interfaceObj.find('title'); | |
207 if (titleNode[0] != undefined) | |
208 { | |
209 document.getElementById('pageTitle').textContent = titleNode[0].textContent; | |
210 } | |
211 var positionScale = canvas.style.width.substr(0,canvas.style.width.length-2); | |
212 var offset = 50-8; // Half the offset of the slider (window width -100) minus the body padding of 8 | |
213 // TODO: AUTOMATE ABOVE!! | |
214 var scale = document.getElementById('sliderScaleHolder'); | |
215 scale.innerHTML = null; | |
216 interfaceObj.find('scale').each(function(index,scaleObj){ | |
217 var position = Number(scaleObj.attributes['position'].value)*0.01; | |
218 var pixelPosition = (position*positionScale)+offset; | |
219 var scaleDOM = document.createElement('span'); | |
220 scaleDOM.textContent = scaleObj.textContent; | |
221 scale.appendChild(scaleDOM); | |
222 scaleDOM.style.left = Math.floor((pixelPosition-($(scaleDOM).width()/2)))+'px'; | |
223 }); | |
188 | 224 |
189 // Extract the hostURL attribute. If not set, create an empty string. | 225 // Extract the hostURL attribute. If not set, create an empty string. |
190 var hostURL = textXML.attributes['hostURL']; | 226 var hostURL = textXML.attributes['hostURL']; |
191 if (hostURL == undefined) { | 227 if (hostURL == undefined) { |
192 hostURL = ""; | 228 hostURL = ""; |