Mercurial > hg > webaudioevaluationtool
comparison interfaces/mushra.js @ 3006:50f5e11a38b7
Generalised #119 in mushra.js
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Thu, 03 Aug 2017 15:01:52 +0200 |
parents | b08ccdb5cb8f |
children | 1620cbee9111 |
comparison
equal
deleted
inserted
replaced
3005:cf4bf84c3e7b | 3006:50f5e11a38b7 |
---|---|
65 var submit = document.createElement("button"); | 65 var submit = document.createElement("button"); |
66 submit.innerHTML = 'Next'; | 66 submit.innerHTML = 'Next'; |
67 submit.onclick = buttonSubmitClick; | 67 submit.onclick = buttonSubmitClick; |
68 submit.id = 'submit-button'; | 68 submit.id = 'submit-button'; |
69 submit.style.display = 'inline-block'; | 69 submit.style.display = 'inline-block'; |
70 | |
71 // Create the sort button | |
72 var sort = document.createElement("button"); | |
73 sort.id = "sort-fragments"; | |
74 sort.textContent = "Sort"; | |
75 sort.style.display = "inline-block"; | |
76 sort.style.visibility = "hidden"; | |
77 sort.onclick = buttonSortFragmentClick; | |
78 | |
70 // Append the interface buttons into the interfaceButtons object. | 79 // Append the interface buttons into the interfaceButtons object. |
71 interfaceButtons.appendChild(playback); | 80 interfaceButtons.appendChild(playback); |
72 interfaceButtons.appendChild(submit); | 81 interfaceButtons.appendChild(submit); |
82 interfaceButtons.appendChild(sort); | |
83 | |
73 | 84 |
74 // Create outside reference holder | 85 // Create outside reference holder |
75 var outsideRef = document.createElement("div"); | 86 var outsideRef = document.createElement("div"); |
76 outsideRef.id = "outside-reference-holder"; | 87 outsideRef.id = "outside-reference-holder"; |
77 | 88 |
204 }); | 215 }); |
205 } | 216 } |
206 | 217 |
207 | 218 |
208 var interfaceOptions = interfaceObj.options; | 219 var interfaceOptions = interfaceObj.options; |
220 var sortButton = document.getElementById("sort-fragments"); | |
221 sortButton.style.visibility = "hidden"; | |
209 interfaceOptions.forEach(function (option) { | 222 interfaceOptions.forEach(function (option) { |
210 if (option.type == "show") { | 223 if (option.type == "show") { |
211 switch (option.name) { | 224 switch (option.name) { |
212 case "playhead": | 225 case "playhead": |
213 var playbackHolder = document.getElementById('playback-holder'); | 226 var playbackHolder = document.getElementById('playback-holder'); |
237 break; | 250 break; |
238 case "comments": | 251 case "comments": |
239 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder, true); | 252 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder, true); |
240 break; | 253 break; |
241 case "fragmentSort": | 254 case "fragmentSort": |
242 var button = document.getElementById('sort'); | 255 var button = document.getElementById('sort-fragments'); |
243 if (button === null) { | 256 button.style.visibility = "visible"; |
244 button = document.createElement("button"); | |
245 button.id = 'sort'; | |
246 button.textContent = "Sort"; | |
247 button.style.display = 'inline-block'; | |
248 var container = document.getElementById("interface-buttons"); | |
249 var neighbour = container.lastElementChild; | |
250 container.appendChild(button); | |
251 button.onclick = function () { | |
252 var sortIndex = interfaceContext.sortFragmentsByScore(); | |
253 var sliderBox = document.getElementById("slider-holder"); | |
254 var nodes = audioEngineContext.audioObjects.filter(function (ao) { | |
255 return ao.specification.type !== "outside-reference"; | |
256 }); | |
257 var i; | |
258 nodes.forEach(function (ao) { | |
259 sliderBox.removeChild(ao.interfaceDOM.holder); | |
260 }); | |
261 for (i = 0; i < nodes.length; i++) { | |
262 var j = sortIndex[i]; | |
263 sliderBox.appendChild(nodes[j].interfaceDOM.holder); | |
264 } | |
265 }; | |
266 } | |
267 break; | 257 break; |
268 } | 258 } |
269 } | 259 } |
270 }); | 260 }); |
271 | 261 |
511 text.style.left = 100 - ($(text).width() + 3) + 'px'; | 501 text.style.left = 100 - ($(text).width() + 3) + 'px'; |
512 lastHeight = posPix; | 502 lastHeight = posPix; |
513 }); | 503 }); |
514 } | 504 } |
515 | 505 |
506 function buttonSortFragmentClick() { | |
507 var sortIndex = interfaceContext.sortFragmentsByScore(); | |
508 var sliderBox = document.getElementById("slider-holder"); | |
509 var nodes = audioEngineContext.audioObjects.filter(function (ao) { | |
510 return ao.specification.type !== "outside-reference"; | |
511 }); | |
512 var i; | |
513 nodes.forEach(function (ao) { | |
514 sliderBox.removeChild(ao.interfaceDOM.holder); | |
515 }); | |
516 for (i = 0; i < nodes.length; i++) { | |
517 var j = sortIndex[i]; | |
518 sliderBox.appendChild(nodes[j].interfaceDOM.holder); | |
519 } | |
520 } | |
521 | |
516 function buttonSubmitClick() // TODO: Only when all songs have been played! | 522 function buttonSubmitClick() // TODO: Only when all songs have been played! |
517 { | 523 { |
518 var checks = testState.currentStateMap.interfaces[0].options, | 524 var checks = testState.currentStateMap.interfaces[0].options, |
519 canContinue = true; | 525 canContinue = true; |
520 | 526 |