comparison interfaces/horizontal-sliders.js @ 1096:9820063ea96a

Bug #1652 and Feature #1650 fixes. You can specify the track labels through page attribute 'label' ('default', 'none', 'number', 'letter', 'capital'). Updated examples to match schema
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 10 Mar 2016 16:16:16 +0000
parents c07b9e2312ba
children ba6b9e1aaef5
comparison
equal deleted inserted replaced
1095:6dac24365cfe 1096:9820063ea96a
53 console.log('Stopped at ' + time); // DEBUG/SAFETY 53 console.log('Stopped at ' + time); // DEBUG/SAFETY
54 } 54 }
55 }; 55 };
56 // Create Submit (save) button 56 // Create Submit (save) button
57 var submit = document.createElement("button"); 57 var submit = document.createElement("button");
58 submit.innerHTML = 'Submit'; 58 submit.innerHTML = 'Next';
59 submit.onclick = buttonSubmitClick; 59 submit.onclick = buttonSubmitClick;
60 submit.id = 'submit-button'; 60 submit.id = 'submit-button';
61 submit.style.float = 'left'; 61 submit.style.float = 'left';
62 // Append the interface buttons into the interfaceButtons object. 62 // Append the interface buttons into the interfaceButtons object.
63 interfaceButtons.appendChild(playback); 63 interfaceButtons.appendChild(playback);
183 var node = interfaceContext.createCommentQuestion(element); 183 var node = interfaceContext.createCommentQuestion(element);
184 feedbackHolder.appendChild(node.holder); 184 feedbackHolder.appendChild(node.holder);
185 }); 185 });
186 186
187 // Find all the audioElements from the audioHolder 187 // Find all the audioElements from the audioHolder
188 var label = 0; 188 var index = 0;
189 $(page.audioElements).each(function(index,element){ 189 $(page.audioElements).each(function(index,element){
190 // Find URL of track 190 // Find URL of track
191 // In this jQuery loop, variable 'this' holds the current audioElement. 191 // In this jQuery loop, variable 'this' holds the current audioElement.
192 192
193 var audioObject = audioEngineContext.newTrack(element); 193 var audioObject = audioEngineContext.newTrack(element);
196 // Construct outside reference; 196 // Construct outside reference;
197 var orNode = new outsideReferenceDOM(audioObject,index,document.getElementById('interface-buttons')); 197 var orNode = new outsideReferenceDOM(audioObject,index,document.getElementById('interface-buttons'));
198 audioObject.bindInterface(orNode); 198 audioObject.bindInterface(orNode);
199 } else { 199 } else {
200 // Create a slider per track 200 // Create a slider per track
201 switch(audioObject.specification.parent.label) {
202 case "none":
203 label = "";
204 break;
205 case "letter":
206 label = String.fromCharCode(97 + index);
207 break;
208 case "capital":
209 label = String.fromCharCode(65 + index);
210 break;
211 default:
212 label = ""+index;
213 break;
214 }
201 var sliderObj = new sliderObject(audioObject,label); 215 var sliderObj = new sliderObject(audioObject,label);
202 216
203 if (typeof page.initialPosition === "number") 217 if (typeof page.initialPosition === "number")
204 { 218 {
205 // Set the values 219 // Set the values
209 sliderObj.slider.value = Math.random(); 223 sliderObj.slider.value = Math.random();
210 } 224 }
211 sliderBox.appendChild(sliderObj.holder); 225 sliderBox.appendChild(sliderObj.holder);
212 audioObject.bindInterface(sliderObj); 226 audioObject.bindInterface(sliderObj);
213 interfaceContext.commentBoxes.createCommentBox(audioObject); 227 interfaceContext.commentBoxes.createCommentBox(audioObject);
214 label += 1; 228 index += 1;
215 } 229 }
216 230
217 }); 231 });
218 if (page.showElementComments) 232 if (page.showElementComments)
219 { 233 {