Mercurial > hg > webaudioevaluationtool
comparison interfaces/mushra.js @ 2850:6c41a874fd21
#119 Implementing sort function into MUSHRA
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Wed, 26 Apr 2017 10:33:35 +0100 |
parents | 1076ac62823f |
children | 97a52e326464 |
comparison
equal
deleted
inserted
replaced
2849:050a99108afa | 2850:6c41a874fd21 |
---|---|
48 | 48 |
49 // Create playback start/stop points | 49 // Create playback start/stop points |
50 var playback = document.createElement("button"); | 50 var playback = document.createElement("button"); |
51 playback.innerHTML = 'Stop'; | 51 playback.innerHTML = 'Stop'; |
52 playback.id = 'playback-button'; | 52 playback.id = 'playback-button'; |
53 playback.style.float = 'left'; | 53 playback.style.display = 'inline-block'; |
54 // onclick function. Check if it is playing or not, call the correct function in the | 54 // onclick function. Check if it is playing or not, call the correct function in the |
55 // audioEngine, change the button text to reflect the next state. | 55 // audioEngine, change the button text to reflect the next state. |
56 playback.onclick = function () { | 56 playback.onclick = function () { |
57 if (audioEngineContext.status == 1) { | 57 if (audioEngineContext.status == 1) { |
58 audioEngineContext.stop(); | 58 audioEngineContext.stop(); |
64 // Create Submit (save) button | 64 // Create Submit (save) button |
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.float = 'left'; | 69 submit.style.display = 'inline-block'; |
70 // Append the interface buttons into the interfaceButtons object. | 70 // Append the interface buttons into the interfaceButtons object. |
71 interfaceButtons.appendChild(playback); | 71 interfaceButtons.appendChild(playback); |
72 interfaceButtons.appendChild(submit); | 72 interfaceButtons.appendChild(submit); |
73 | 73 |
74 // Create outside reference holder | 74 // Create outside reference holder |
222 case "page-count": | 222 case "page-count": |
223 var pagecountHolder = document.getElementById('page-count'); | 223 var pagecountHolder = document.getElementById('page-count'); |
224 if (pagecountHolder === null) { | 224 if (pagecountHolder === null) { |
225 pagecountHolder = document.createElement('div'); | 225 pagecountHolder = document.createElement('div'); |
226 pagecountHolder.id = 'page-count'; | 226 pagecountHolder.id = 'page-count'; |
227 pagecountHolder.style.display = 'inline-block'; | |
227 } | 228 } |
228 pagecountHolder.innerHTML = '<span>Page ' + (testState.stateIndex + 1) + ' of ' + testState.stateMap.length + '</span>'; | 229 pagecountHolder.innerHTML = '<span>Page ' + (testState.stateIndex + 1) + ' of ' + testState.stateMap.length + '</span>'; |
229 var inject = document.getElementById('interface-buttons'); | 230 var inject = document.getElementById('interface-buttons'); |
230 inject.appendChild(pagecountHolder); | 231 inject.appendChild(pagecountHolder); |
231 break; | 232 break; |
234 feedbackHolder.appendChild(interfaceContext.volume.object); | 235 feedbackHolder.appendChild(interfaceContext.volume.object); |
235 } | 236 } |
236 break; | 237 break; |
237 case "comments": | 238 case "comments": |
238 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder, true); | 239 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder, true); |
240 break; | |
241 case "fragmentSort": | |
242 (function () { | |
243 var button = document.createElement("button"); | |
244 button.textContent = "Sort"; | |
245 button.style.display = 'inline-block'; | |
246 var container = document.getElementById("interface-buttons"); | |
247 var neighbour = container.lastElementChild; | |
248 while (neighbour.nodeName !== "BUTTON") { | |
249 neighbour = neighbour.previousElementSibling; | |
250 } | |
251 if (neighbour.nextElementSibling) { | |
252 container.insertBefore(button, neighbour.nextElementSibling); | |
253 } else { | |
254 container.appendChild(button); | |
255 } | |
256 button.onclick = function () { | |
257 var sortIndex = interfaceContext.sortFragmentsByScore(); | |
258 var sliderBox = document.getElementById("slider-holder"); | |
259 var nodes = audioEngineContext.audioObjects.filter(function (ao) { | |
260 return ao.specification.type !== "outside-reference"; | |
261 }); | |
262 var i; | |
263 nodes.forEach(function (ao) { | |
264 sliderBox.removeChild(ao.interfaceDOM.holder); | |
265 }); | |
266 for (i = 0; i < nodes.length; i++) { | |
267 var j = sortIndex[i]; | |
268 sliderBox.appendChild(nodes[j].interfaceDOM.holder); | |
269 } | |
270 }; | |
271 })(); | |
239 break; | 272 break; |
240 } | 273 } |
241 } | 274 } |
242 }); | 275 }); |
243 | 276 |