Mercurial > hg > webaudioevaluationtool
comparison interfaces/discrete.js @ 3007:37923d45f298
Add sort to discrete #119
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Thu, 03 Aug 2017 15:06:29 +0200 |
parents | 64a5603831e2 |
children | 1620cbee9111 |
comparison
equal
deleted
inserted
replaced
3006:50f5e11a38b7 | 3007:37923d45f298 |
---|---|
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.float = 'left'; |
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); | |
73 | 83 |
74 // Create a slider box | 84 // Create a slider box |
75 var sliderBox = document.createElement('div'); | 85 var sliderBox = document.createElement('div'); |
76 sliderBox.style.width = "100%"; | 86 sliderBox.style.width = "100%"; |
77 sliderBox.style.height = window.innerHeight - 200 + 12 + 'px'; | 87 sliderBox.style.height = window.innerHeight - 200 + 12 + 'px'; |
185 } | 195 } |
186 break; | 196 break; |
187 case "comments": | 197 case "comments": |
188 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder, true); | 198 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder, true); |
189 break; | 199 break; |
200 case "fragmentSort": | |
201 var button = document.getElementById('sort-fragments'); | |
202 button.style.visibility = "visible"; | |
203 break; | |
190 } | 204 } |
191 } | 205 } |
192 }); | 206 }); |
193 | 207 |
194 // Find all the audioElements from the audioHolder | 208 // Find all the audioElements from the audioHolder |
537 } | 551 } |
538 testState.advanceState(); | 552 testState.advanceState(); |
539 } | 553 } |
540 } | 554 } |
541 | 555 |
556 function buttonSortFragmentClick() { | |
557 var sortIndex = interfaceContext.sortFragmentsByScore(); | |
558 var sliderBox = document.getElementById("slider-holder"); | |
559 var nodes = audioEngineContext.audioObjects.filter(function (ao) { | |
560 return ao.specification.type !== "outside-reference"; | |
561 }); | |
562 var i; | |
563 nodes.forEach(function (ao) { | |
564 sliderBox.removeChild(ao.interfaceDOM.holder); | |
565 }); | |
566 for (i = 0; i < nodes.length; i++) { | |
567 var j = sortIndex[i]; | |
568 sliderBox.appendChild(nodes[j].interfaceDOM.holder); | |
569 } | |
570 } | |
571 | |
542 function pageXMLSave(store, pageSpecification) { | 572 function pageXMLSave(store, pageSpecification) { |
543 // MANDATORY | 573 // MANDATORY |
544 // Saves a specific test page | 574 // Saves a specific test page |
545 // You can use this space to add any extra nodes to your XML <audioHolder> saves | 575 // You can use this space to add any extra nodes to your XML <audioHolder> saves |
546 // Get the current <page> information in store (remember to appendChild your data to it) | 576 // Get the current <page> information in store (remember to appendChild your data to it) |