nickjillings@1341
|
1 /**
|
nickjillings@1341
|
2 * ape.js
|
nickjillings@1341
|
3 * Create the APE interface
|
nickjillings@1341
|
4 */
|
nickjillings@1341
|
5
|
nickjillings@1341
|
6
|
nickjillings@1341
|
7 // Once this is loaded and parsed, begin execution
|
nickjillings@1341
|
8 loadInterface();
|
nickjillings@1341
|
9
|
nickjillings@1341
|
10 function loadInterface() {
|
nickjillings@1341
|
11
|
nickjillings@1341
|
12 // Get the dimensions of the screen available to the page
|
nickjillings@1341
|
13 var width = window.innerWidth;
|
nickjillings@1341
|
14 var height = window.innerHeight;
|
nickjillings@1341
|
15
|
nickjillings@1341
|
16 // The injection point into the HTML page
|
nickjillings@1341
|
17 interfaceContext.insertPoint = document.getElementById("topLevelBody");
|
nickjillings@1341
|
18 var testContent = document.createElement('div');
|
nickjillings@1341
|
19
|
nickjillings@1341
|
20 testContent.id = 'testContent';
|
nickjillings@1341
|
21
|
nickjillings@1341
|
22 // Bindings for interfaceContext
|
nickjillings@1341
|
23 interfaceContext.checkAllPlayed = function()
|
nickjillings@1341
|
24 {
|
nickjillings@1341
|
25 hasBeenPlayed = audioEngineContext.checkAllPlayed();
|
nickjillings@1341
|
26 if (hasBeenPlayed.length > 0) // if a fragment has not been played yet
|
nickjillings@1341
|
27 {
|
nicholas@2313
|
28 var str = "";
|
nickjillings@1341
|
29 if (hasBeenPlayed.length > 1) {
|
nickjillings@1341
|
30 for (var i=0; i<hasBeenPlayed.length; i++) {
|
nicholas@2284
|
31 var ao_id = audioEngineContext.audioObjects[hasBeenPlayed[i]].interfaceDOM.getPresentedId();
|
nicholas@2284
|
32 str = str + ao_id; // start from 1
|
nickjillings@1341
|
33 if (i < hasBeenPlayed.length-2){
|
nickjillings@1341
|
34 str += ", ";
|
nickjillings@1341
|
35 } else if (i == hasBeenPlayed.length-2) {
|
nickjillings@1341
|
36 str += " or ";
|
nickjillings@1341
|
37 }
|
nickjillings@1341
|
38 }
|
nicholas@2313
|
39 str = 'You have not played fragments ' + str + ' yet. Please listen, rate and comment all samples before submitting.';
|
nickjillings@1341
|
40 } else {
|
nicholas@2313
|
41 str = 'You have not played fragment ' + (audioEngineContext.audioObjects[hasBeenPlayed[0]].interfaceDOM.getPresentedId()) + ' yet. Please listen, rate and comment all samples before submitting.';
|
nicholas@2313
|
42 }
|
nicholas@2313
|
43 this.storeErrorNode(str);
|
nicholas@2362
|
44 interfaceContext.lightbox.post("Message",str);
|
nickjillings@1341
|
45 return false;
|
nickjillings@1341
|
46 }
|
nickjillings@1341
|
47 return true;
|
nickjillings@1341
|
48 };
|
nickjillings@1341
|
49
|
nickjillings@1341
|
50 interfaceContext.checkAllMoved = function() {
|
nickjillings@1341
|
51 var state = true;
|
nickjillings@1341
|
52 var str = 'You have not moved the following sliders. ';
|
nickjillings@1341
|
53 for (var i=0; i<this.interfaceSliders.length; i++)
|
nickjillings@1341
|
54 {
|
nickjillings@1341
|
55 var interfaceTID = [];
|
nickjillings@1341
|
56 for (var j=0; j<this.interfaceSliders[i].metrics.length; j++)
|
nickjillings@1341
|
57 {
|
nicholas@2285
|
58 var ao_id = this.interfaceSliders[i].sliders[j].getAttribute("trackIndex");
|
nicholas@2285
|
59 if (this.interfaceSliders[i].metrics[j].wasMoved == false && audioEngineContext.audioObjects[ao_id].interfaceDOM.canMove())
|
nickjillings@1341
|
60 {
|
nickjillings@1341
|
61 state = false;
|
nickjillings@1341
|
62 interfaceTID.push(j);
|
nickjillings@1341
|
63 }
|
nickjillings@1341
|
64 }
|
nickjillings@1341
|
65 if (interfaceTID.length != 0)
|
nickjillings@1341
|
66 {
|
nickjillings@1341
|
67 var interfaceName = this.interfaceSliders[i].interfaceObject.title;
|
nickjillings@1341
|
68 if (interfaceName == undefined) {
|
nickjillings@1341
|
69 str += 'On axis '+String(i+1)+' you must move ';
|
nickjillings@1341
|
70 } else {
|
nickjillings@1341
|
71 str += 'On axis "'+interfaceName+'" you must move ';
|
nickjillings@1341
|
72 }
|
nickjillings@1341
|
73 if (interfaceTID.length == 1)
|
nickjillings@1341
|
74 {
|
nicholas@2284
|
75 str += 'slider '+(audioEngineContext.audioObjects[interfaceTID[0]].interfaceDOM.getPresentedId())+'. '; // start from 1
|
nickjillings@1341
|
76 }
|
nickjillings@1341
|
77 else {
|
nickjillings@1341
|
78 str += 'sliders ';
|
nickjillings@1341
|
79 for (var k=0; k<interfaceTID.length-1; k++)
|
nickjillings@1341
|
80 {
|
nicholas@2284
|
81 str += (audioEngineContext.audioObjects[interfaceTID[k]].interfaceDOM.getPresentedId())+', '; // start from 1
|
nickjillings@1341
|
82 }
|
nicholas@2284
|
83 str += (audioEngineContext.audioObjects[interfaceTID[interfaceTID.length-1]].interfaceDOM.getPresentedId()) +'. ';
|
nickjillings@1341
|
84 }
|
nickjillings@1341
|
85 }
|
nickjillings@1341
|
86 }
|
nickjillings@1341
|
87 if (state != true)
|
nickjillings@1341
|
88 {
|
nicholas@2313
|
89 this.storeErrorNode(str);
|
nicholas@2362
|
90 interfaceContext.lightbox.post("Message",str);
|
nickjillings@1341
|
91 console.log(str);
|
nickjillings@1341
|
92 }
|
nickjillings@1341
|
93 return state;
|
nickjillings@1341
|
94 };
|
nickjillings@1341
|
95
|
nickjillings@1341
|
96 Interface.prototype.checkAllCommented = function() {
|
nickjillings@1341
|
97 var audioObjs = audioEngineContext.audioObjects;
|
nickjillings@1341
|
98 var audioHolder = testState.stateMap[testState.stateIndex];
|
nickjillings@1341
|
99 var state = true;
|
nickjillings@1341
|
100 if (audioHolder.elementComments) {
|
nickjillings@1341
|
101 var strNums = [];
|
nickjillings@1341
|
102 for (var i=0; i<audioObjs.length; i++)
|
nickjillings@1341
|
103 {
|
nickjillings@1341
|
104 if (audioObjs[i].commentDOM.trackCommentBox.value.length == 0) {
|
nickjillings@1341
|
105 state = false;
|
nickjillings@1341
|
106 strNums.push(i);
|
nickjillings@1341
|
107 }
|
nickjillings@1341
|
108 }
|
nickjillings@1341
|
109 if (state == false) {
|
nicholas@2313
|
110 var str = "";
|
nickjillings@1341
|
111 if (strNums.length > 1) {
|
nicholas@2313
|
112
|
nickjillings@1341
|
113 for (var i=0; i<strNums.length; i++) {
|
nicholas@2284
|
114 var ao_id = audioEngineContext.audioObjects[strNums[i]].interfaceDOM.getPresentedId();
|
nicholas@2284
|
115 str = str + (ao_id); // start from 1
|
nickjillings@1341
|
116 if (i < strNums.length-2){
|
nickjillings@1341
|
117 str += ", ";
|
nickjillings@1341
|
118 } else if (i == strNums.length-2) {
|
nickjillings@1341
|
119 str += " or ";
|
nickjillings@1341
|
120 }
|
nickjillings@1341
|
121 }
|
nicholas@2313
|
122 str = 'You have not commented on fragments ' + str + ' yet. Please listen, rate and comment all samples before submitting.';
|
nickjillings@1341
|
123 } else {
|
nicholas@2313
|
124 str = 'You have not commented on fragment ' + (audioEngineContext.audioObjects[strNums[0]].interfaceDOM.getPresentedId()) + ' yet. Please listen, rate and comment all samples before submitting.';
|
nickjillings@1341
|
125 }
|
nicholas@2313
|
126 this.storeErrorNode(str);
|
nicholas@2362
|
127 interfaceContext.lightbox.post("Message",str);
|
nicholas@2313
|
128 console.log(str);
|
nickjillings@1341
|
129 }
|
nickjillings@1341
|
130 }
|
nickjillings@1341
|
131 return state;
|
nickjillings@1341
|
132 };
|
nickjillings@1341
|
133
|
nickjillings@1341
|
134 Interface.prototype.checkScaleRange = function()
|
nickjillings@1341
|
135 {
|
nickjillings@1341
|
136 var audioObjs = audioEngineContext.audioObjects;
|
nickjillings@1341
|
137 var audioHolder = testState.stateMap[testState.stateIndex];
|
nickjillings@1341
|
138 var state = true;
|
nickjillings@1341
|
139 var str = '';
|
nickjillings@1341
|
140 for (var i=0; i<this.interfaceSliders.length; i++)
|
nickjillings@1341
|
141 {
|
nickjillings@1341
|
142 var minScale;
|
nickjillings@1341
|
143 var maxScale;
|
nickjillings@1341
|
144 var interfaceObject = interfaceContext.interfaceSliders[0].interfaceObject;
|
nickjillings@1341
|
145 for (var j=0; j<interfaceObject.options.length; j++)
|
nickjillings@1341
|
146 {
|
nickjillings@1341
|
147 if (interfaceObject.options[j].check == "scalerange") {
|
nickjillings@1341
|
148 minScale = interfaceObject.options[j].min;
|
nickjillings@1341
|
149 maxScale = interfaceObject.options[j].max;
|
nickjillings@1341
|
150 break;
|
nickjillings@1341
|
151 }
|
nickjillings@1341
|
152 }
|
nickjillings@1341
|
153 var minRanking = convSliderPosToRate(this.interfaceSliders[i].sliders[0]);
|
nickjillings@1341
|
154 var maxRanking = minRanking;
|
nickjillings@1341
|
155 for (var j=1; j<this.interfaceSliders[i].sliders.length; j++)
|
nickjillings@1341
|
156 {
|
nickjillings@1341
|
157 var ranking = convSliderPosToRate(this.interfaceSliders[i].sliders[j]);
|
nickjillings@1341
|
158 if (ranking < minRanking)
|
nickjillings@1341
|
159 {
|
nickjillings@1341
|
160 minRanking = ranking;
|
nickjillings@1341
|
161 } else if (ranking > maxRanking)
|
nickjillings@1341
|
162 {
|
nickjillings@1341
|
163 maxRanking = ranking;
|
nickjillings@1341
|
164 }
|
nickjillings@1341
|
165 }
|
nickjillings@1341
|
166 if (minRanking > minScale || maxRanking < maxScale)
|
nickjillings@1341
|
167 {
|
nickjillings@1341
|
168 state = false;
|
nickjillings@1341
|
169 str += 'On axis "'+this.interfaceSliders[i].interfaceObject.title+'" you have not used the full width of the scale. ';
|
nickjillings@1341
|
170 }
|
nickjillings@1341
|
171 }
|
nickjillings@1341
|
172 if (state != true)
|
nickjillings@1341
|
173 {
|
nicholas@2313
|
174 this.storeErrorNode(str);
|
nicholas@2362
|
175 interfaceContext.lightbox.post("Message",str);
|
nickjillings@1341
|
176 console.log(str);
|
nickjillings@1341
|
177 }
|
nickjillings@1341
|
178 return state;
|
nickjillings@1341
|
179 };
|
nickjillings@1341
|
180
|
nickjillings@1341
|
181 Interface.prototype.objectSelected = null;
|
nickjillings@1341
|
182 Interface.prototype.objectMoved = false;
|
nickjillings@1341
|
183 Interface.prototype.selectObject = function(object)
|
nickjillings@1341
|
184 {
|
nickjillings@1341
|
185 if (this.objectSelected == null)
|
nickjillings@1341
|
186 {
|
nickjillings@1341
|
187 this.objectSelected = object;
|
nickjillings@1341
|
188 this.objectMoved = false;
|
nickjillings@1341
|
189 }
|
nickjillings@1341
|
190 };
|
nickjillings@1341
|
191 Interface.prototype.moveObject = function()
|
nickjillings@1341
|
192 {
|
nickjillings@1341
|
193 if (this.objectMoved == false)
|
nickjillings@1341
|
194 {
|
nickjillings@1341
|
195 this.objectMoved = true;
|
nickjillings@1341
|
196 }
|
nickjillings@1341
|
197 };
|
nickjillings@1341
|
198 Interface.prototype.releaseObject = function()
|
nickjillings@1341
|
199 {
|
nickjillings@1341
|
200 this.objectSelected = null;
|
nickjillings@1341
|
201 this.objectMoved = false;
|
nickjillings@1341
|
202 };
|
nickjillings@1341
|
203 Interface.prototype.getSelectedObject = function()
|
nickjillings@1341
|
204 {
|
nickjillings@1341
|
205 return this.objectSelected;
|
nickjillings@1341
|
206 };
|
nickjillings@1341
|
207 Interface.prototype.hasSelectedObjectMoved = function()
|
nickjillings@1341
|
208 {
|
nickjillings@1341
|
209 return this.objectMoved;
|
nickjillings@1341
|
210 };
|
nickjillings@1341
|
211
|
nickjillings@1341
|
212 // Bindings for slider interfaces
|
nickjillings@1341
|
213 Interface.prototype.interfaceSliders = [];
|
nickjillings@1341
|
214
|
nickjillings@1341
|
215 // Bindings for audioObjects
|
nickjillings@1341
|
216
|
nickjillings@1341
|
217 // Create the top div for the Title element
|
nickjillings@1341
|
218 var titleAttr = specification.title;
|
nickjillings@1341
|
219 var title = document.createElement('div');
|
nickjillings@1341
|
220 title.className = "title";
|
nickjillings@1341
|
221 title.align = "center";
|
nickjillings@1341
|
222 var titleSpan = document.createElement('span');
|
nickjillings@1341
|
223
|
nickjillings@1341
|
224 // Set title to that defined in XML, else set to default
|
nickjillings@1341
|
225 if (titleAttr != undefined) {
|
nickjillings@1341
|
226 titleSpan.textContent = titleAttr;
|
nickjillings@1341
|
227 } else {
|
nickjillings@1341
|
228 titleSpan.textContent = 'Listening test';
|
nickjillings@1341
|
229 }
|
nickjillings@1341
|
230 // Insert the titleSpan element into the title div element.
|
nickjillings@1341
|
231 title.appendChild(titleSpan);
|
nickjillings@1341
|
232
|
nickjillings@1341
|
233 // Create Interface buttons!
|
nickjillings@1341
|
234 var interfaceButtons = document.createElement('div');
|
nickjillings@1341
|
235 interfaceButtons.id = 'interface-buttons';
|
nickjillings@1341
|
236
|
nickjillings@1341
|
237 // Create playback start/stop points
|
nickjillings@1341
|
238 var playback = document.createElement("button");
|
nickjillings@1341
|
239 playback.innerHTML = 'Stop';
|
nickjillings@1341
|
240 playback.id = 'playback-button';
|
nickjillings@1341
|
241 // onclick function. Check if it is playing or not, call the correct function in the
|
nickjillings@1341
|
242 // audioEngine, change the button text to reflect the next state.
|
nickjillings@1341
|
243 playback.onclick = function() {
|
nickjillings@1341
|
244 if (audioEngineContext.status == 1) {
|
nickjillings@1341
|
245 audioEngineContext.stop();
|
nickjillings@1341
|
246 this.innerHTML = 'Stop';
|
nickjillings@1341
|
247 var time = audioEngineContext.timer.getTestTime();
|
nickjillings@1341
|
248 console.log('Stopped at ' + time); // DEBUG/SAFETY
|
nickjillings@1341
|
249 }
|
nickjillings@1341
|
250 };
|
nickjillings@1341
|
251 // Create Submit (save) button
|
nickjillings@1341
|
252 var submit = document.createElement("button");
|
nickjillings@1295
|
253 submit.innerHTML = 'Next';
|
nickjillings@1341
|
254 submit.onclick = buttonSubmitClick;
|
nickjillings@1341
|
255 submit.id = 'submit-button';
|
nickjillings@1341
|
256 // Append the interface buttons into the interfaceButtons object.
|
nickjillings@1341
|
257 interfaceButtons.appendChild(playback);
|
nickjillings@1341
|
258 interfaceButtons.appendChild(submit);
|
nickjillings@1341
|
259
|
nickjillings@1341
|
260 var sliderHolder = document.createElement("div");
|
nickjillings@1341
|
261 sliderHolder.id = "slider-holder";
|
nickjillings@1341
|
262
|
nicholas@2396
|
263 // Create outside reference holder
|
nicholas@2396
|
264 var outsideRef = document.createElement("div");
|
nicholas@2396
|
265 outsideRef.id = "outside-reference-holder";
|
nickjillings@1341
|
266
|
nickjillings@1341
|
267 // Global parent for the comment boxes on the page
|
nickjillings@1341
|
268 var feedbackHolder = document.createElement('div');
|
nickjillings@1341
|
269 feedbackHolder.id = 'feedbackHolder';
|
nickjillings@1341
|
270
|
nickjillings@1341
|
271 testContent.style.zIndex = 1;
|
nicholas@2381
|
272 interfaceContext.insertPoint.innerHTML = ""; // Clear the current schema
|
nickjillings@1341
|
273
|
nickjillings@1341
|
274 // Inject into HTML
|
nickjillings@1341
|
275 testContent.appendChild(title); // Insert the title
|
nickjillings@1341
|
276 testContent.appendChild(interfaceButtons);
|
nicholas@2396
|
277 testContent.appendChild(outsideRef);
|
nickjillings@1341
|
278 testContent.appendChild(sliderHolder);
|
nickjillings@1341
|
279 testContent.appendChild(feedbackHolder);
|
nickjillings@1341
|
280 interfaceContext.insertPoint.appendChild(testContent);
|
nickjillings@1341
|
281
|
nickjillings@1341
|
282 // Load the full interface
|
nickjillings@1341
|
283 testState.initialise();
|
nickjillings@1341
|
284 testState.advanceState();
|
nickjillings@1341
|
285
|
nickjillings@1341
|
286 }
|
nickjillings@1341
|
287
|
nickjillings@1341
|
288 function loadTest(audioHolderObject)
|
nickjillings@1341
|
289 {
|
nickjillings@1341
|
290 var width = window.innerWidth;
|
nickjillings@1341
|
291 var height = window.innerHeight;
|
nickjillings@1341
|
292 var id = audioHolderObject.id;
|
nickjillings@1341
|
293
|
nickjillings@1341
|
294 interfaceContext.interfaceSliders = [];
|
nickjillings@1341
|
295
|
nickjillings@1341
|
296 var feedbackHolder = document.getElementById('feedbackHolder');
|
nickjillings@1341
|
297 var sliderHolder = document.getElementById('slider-holder');
|
nicholas@2381
|
298 feedbackHolder.innerHTML = "";
|
nicholas@2381
|
299 sliderHolder.innerHTML = "";
|
nickjillings@1341
|
300
|
nickjillings@1341
|
301 // Delete outside reference
|
nicholas@2396
|
302 document.getElementById("outside-reference-holder").innerHTML = "";
|
nickjillings@1341
|
303
|
nickjillings@1341
|
304 var interfaceObj = audioHolderObject.interfaces;
|
nickjillings@1341
|
305 for (var k=0; k<interfaceObj.length; k++) {
|
nickjillings@1341
|
306 // Create the div box to center align
|
nickjillings@1341
|
307 interfaceContext.interfaceSliders.push(new interfaceSliderHolder(interfaceObj[k]));
|
nickjillings@1341
|
308 }
|
nickjillings@1356
|
309
|
nickjillings@1356
|
310 var interfaceList = audioHolderObject.interfaces.concat(specification.interfaces);
|
nickjillings@1356
|
311 for (var k=0; k<interfaceList.length; k++)
|
nickjillings@1356
|
312 {
|
nickjillings@1356
|
313 for (var i=0; i<interfaceList[k].options.length; i++)
|
nickjillings@1356
|
314 {
|
nickjillings@1356
|
315 if (interfaceList[k].options[i].type == 'show' && interfaceList[k].options[i].name == 'playhead')
|
nickjillings@1356
|
316 {
|
nickjillings@1356
|
317 var playbackHolder = document.getElementById('playback-holder');
|
nickjillings@1356
|
318 if (playbackHolder == null)
|
nickjillings@1356
|
319 {
|
nickjillings@1356
|
320 playbackHolder = document.createElement('div');
|
nickjillings@1356
|
321 playbackHolder.style.width = "100%";
|
nickjillings@1356
|
322 playbackHolder.align = 'center';
|
nickjillings@1356
|
323 playbackHolder.appendChild(interfaceContext.playhead.object);
|
nickjillings@1356
|
324 feedbackHolder.appendChild(playbackHolder);
|
nickjillings@1356
|
325 }
|
nickjillings@1356
|
326 } else if (interfaceList[k].options[i].type == 'show' && interfaceList[k].options[i].name == 'page-count')
|
nickjillings@1356
|
327 {
|
nickjillings@1356
|
328 var pagecountHolder = document.getElementById('page-count');
|
nickjillings@1356
|
329 if (pagecountHolder == null)
|
nickjillings@1356
|
330 {
|
nickjillings@1356
|
331 pagecountHolder = document.createElement('div');
|
nickjillings@1356
|
332 pagecountHolder.id = 'page-count';
|
nickjillings@1356
|
333 }
|
nickjillings@2125
|
334 pagecountHolder.innerHTML = '<span>Page '+(testState.stateIndex+1)+' of '+testState.stateMap.length+'</span>';
|
nickjillings@1356
|
335 var inject = document.getElementById('interface-buttons');
|
nickjillings@1356
|
336 inject.appendChild(pagecountHolder);
|
nickjillings@1356
|
337 } else if (interfaceList[k].options[i].type == 'show' && interfaceList[k].options[i].name == 'volume') {
|
nickjillings@1356
|
338 if (document.getElementById('master-volume-holder') == null)
|
nickjillings@1356
|
339 {
|
nickjillings@1356
|
340 feedbackHolder.appendChild(interfaceContext.volume.object);
|
nickjillings@1356
|
341 }
|
n@2407
|
342 } else if (interfaceList[k].options[i].type == 'show' && interfaceList[k].options[i].name == 'comments') {
|
n@2407
|
343 var commentHolder = document.createElement('div');
|
n@2407
|
344 commentHolder.id = 'commentHolder';
|
n@2407
|
345 document.getElementById('testContent').appendChild(commentHolder);
|
n@2407
|
346 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder,true);
|
n@2407
|
347 break;
|
nickjillings@1356
|
348 }
|
nickjillings@1356
|
349 }
|
nickjillings@1356
|
350 }
|
nickjillings@1341
|
351
|
nickjillings@1341
|
352 var commentBoxPrefix = "Comment on fragment";
|
nickjillings@1341
|
353
|
nickjillings@1341
|
354 var commentShow = audioHolderObject.elementComments;
|
nickjillings@1341
|
355
|
nickjillings@1341
|
356 var loopPlayback = audioHolderObject.loop;
|
nickjillings@1341
|
357
|
nickjillings@1341
|
358 currentTestHolder = document.createElement('audioHolder');
|
nickjillings@1341
|
359 currentTestHolder.id = audioHolderObject.id;
|
nickjillings@1341
|
360 currentTestHolder.repeatCount = audioHolderObject.repeatCount;
|
nicholas@2349
|
361
|
nickjillings@1341
|
362 // Find all the audioElements from the audioHolder
|
nickjillings@1341
|
363 $(audioHolderObject.audioElements).each(function(index,element){
|
nickjillings@1341
|
364 // Find URL of track
|
nickjillings@1341
|
365 // In this jQuery loop, variable 'this' holds the current audioElement.
|
nickjillings@1341
|
366 var audioObject = audioEngineContext.newTrack(element);
|
nickjillings@1341
|
367 // Check if an outside reference
|
nickjillings@1341
|
368 if (element.type == 'outside-reference')
|
nickjillings@1341
|
369 {
|
nickjillings@1341
|
370 // Construct outside reference;
|
nicholas@2396
|
371 var orNode = new outsideReferenceDOM(audioObject,index,document.getElementById("outside-reference-holder"));
|
nickjillings@1341
|
372 audioObject.bindInterface(orNode);
|
nickjillings@1341
|
373 } else {
|
nickjillings@1341
|
374 // Create a slider per track
|
nickjillings@2168
|
375 var sliderNode = new sliderObject(audioObject,interfaceObj,index);
|
nickjillings@1341
|
376 audioObject.bindInterface(sliderNode);
|
nickjillings@2117
|
377 interfaceContext.commentBoxes.createCommentBox(audioObject);
|
nickjillings@1341
|
378 }
|
nickjillings@1341
|
379 });
|
nickjillings@1341
|
380
|
nickjillings@1341
|
381 // Initialse the interfaceSlider object metrics
|
nickjillings@1341
|
382
|
nickjillings@1341
|
383 $('.track-slider').mousedown(function(event) {
|
nickjillings@1341
|
384 interfaceContext.selectObject($(this)[0]);
|
nickjillings@1341
|
385 });
|
nickjillings@1341
|
386 $('.track-slider').on('touchstart',null,function(event) {
|
nickjillings@1341
|
387 interfaceContext.selectObject($(this)[0]);
|
nickjillings@1341
|
388 });
|
nickjillings@1341
|
389
|
nickjillings@1341
|
390 $('.track-slider').mousemove(function(event) {
|
nickjillings@1341
|
391 event.preventDefault();
|
nickjillings@1341
|
392 });
|
nickjillings@1341
|
393
|
nickjillings@1341
|
394 $('.slider').mousemove(function(event) {
|
nickjillings@1341
|
395 event.preventDefault();
|
nickjillings@1341
|
396 var obj = interfaceContext.getSelectedObject();
|
nickjillings@1341
|
397 if (obj == null) {return;}
|
nicholas@2459
|
398 var move = event.clientX-6;
|
nicholas@2459
|
399 var w = $(event.currentTarget).width();
|
nicholas@2459
|
400 move = Math.max(50,move);
|
nicholas@2459
|
401 move = Math.min(w+50,move);
|
nicholas@2459
|
402 $(obj).css("left",move + "px");
|
nickjillings@1341
|
403 interfaceContext.moveObject();
|
nickjillings@1341
|
404 });
|
nickjillings@1341
|
405
|
nickjillings@1341
|
406 $('.slider').on('touchmove',null,function(event) {
|
nickjillings@1341
|
407 event.preventDefault();
|
nickjillings@1341
|
408 var obj = interfaceContext.getSelectedObject();
|
nickjillings@1341
|
409 if (obj == null) {return;}
|
nickjillings@1341
|
410 var move = event.originalEvent.targetTouches[0].clientX - 6;
|
nicholas@2459
|
411 var w = $(event.currentTarget).width();
|
nicholas@2459
|
412 move = Math.max(50,move);
|
nicholas@2459
|
413 move = Math.min(w+50,move);
|
nickjillings@1341
|
414 $(obj).css("left",move + "px");
|
nickjillings@1341
|
415 interfaceContext.moveObject();
|
nickjillings@1341
|
416 });
|
nickjillings@1341
|
417
|
nickjillings@1341
|
418 $(document).mouseup(function(event){
|
nickjillings@1341
|
419 event.preventDefault();
|
nickjillings@1341
|
420 var obj = interfaceContext.getSelectedObject();
|
nickjillings@1341
|
421 if (obj == null) {return;}
|
nickjillings@1341
|
422 var interfaceID = obj.parentElement.getAttribute("interfaceid");
|
nickjillings@1341
|
423 var trackID = obj.getAttribute("trackindex");
|
nickjillings@1341
|
424 if (interfaceContext.hasSelectedObjectMoved() == true)
|
nickjillings@1341
|
425 {
|
nickjillings@1341
|
426 var l = $(obj).css("left");
|
nickjillings@1341
|
427 var id = obj.getAttribute('trackIndex');
|
nickjillings@1341
|
428 var time = audioEngineContext.timer.getTestTime();
|
nickjillings@1341
|
429 var rate = convSliderPosToRate(obj);
|
nickjillings@1341
|
430 audioEngineContext.audioObjects[id].metric.moved(time,rate);
|
nickjillings@1341
|
431 interfaceContext.interfaceSliders[interfaceID].metrics[trackID].moved(time,rate);
|
nickjillings@1341
|
432 console.log("slider "+id+" moved to "+rate+' ('+time+')');
|
nicholas@2391
|
433 obj.setAttribute("slider-value",convSliderPosToRate(obj));
|
nickjillings@1341
|
434 } else {
|
nickjillings@1341
|
435 var id = Number(obj.attributes['trackIndex'].value);
|
nickjillings@1341
|
436 //audioEngineContext.metric.sliderPlayed(id);
|
nickjillings@1341
|
437 audioEngineContext.play(id);
|
nickjillings@1341
|
438 }
|
nickjillings@1341
|
439 interfaceContext.releaseObject();
|
nickjillings@1341
|
440 });
|
nickjillings@1341
|
441
|
nickjillings@1341
|
442 $('.slider').on('touchend',null,function(event){
|
nickjillings@1341
|
443 var obj = interfaceContext.getSelectedObject();
|
nickjillings@1341
|
444 if (obj == null) {return;}
|
nickjillings@1341
|
445 var interfaceID = obj.parentElement.getAttribute("interfaceid");
|
nickjillings@1341
|
446 var trackID = obj.getAttribute("trackindex");
|
nickjillings@1341
|
447 if (interfaceContext.hasSelectedObjectMoved() == true)
|
nickjillings@1341
|
448 {
|
nickjillings@1341
|
449 var l = $(obj).css("left");
|
nickjillings@1341
|
450 var id = obj.getAttribute('trackIndex');
|
nickjillings@1341
|
451 var time = audioEngineContext.timer.getTestTime();
|
nickjillings@1341
|
452 var rate = convSliderPosToRate(obj);
|
nickjillings@1341
|
453 audioEngineContext.audioObjects[id].metric.moved(time,rate);
|
nickjillings@1341
|
454 interfaceContext.interfaceSliders[interfaceID].metrics[trackID].moved(time,rate);
|
nickjillings@1341
|
455 console.log("slider "+id+" moved to "+rate+' ('+time+')');
|
nickjillings@1341
|
456 }
|
nickjillings@1341
|
457 interfaceContext.releaseObject();
|
nickjillings@1341
|
458 });
|
nickjillings@1341
|
459
|
n@2407
|
460 var interfaceList = audioHolderObject.interfaces.concat(specification.interfaces);
|
n@2407
|
461 for (var k=0; k<interfaceList.length; k++)
|
n@2407
|
462 {
|
n@2407
|
463 for (var i=0; i<interfaceList[k].options.length; i++)
|
n@2407
|
464 {
|
n@2407
|
465 if (interfaceList[k].options[i].type == 'show' && interfaceList[k].options[i].name == 'playhead')
|
n@2407
|
466 {
|
n@2407
|
467 var playbackHolder = document.getElementById('playback-holder');
|
n@2407
|
468 if (playbackHolder == null)
|
n@2407
|
469 {
|
n@2407
|
470 playbackHolder = document.createElement('div');
|
n@2407
|
471 playbackHolder.id = "playback-holder";
|
n@2407
|
472 playbackHolder.style.width = "100%";
|
n@2407
|
473 playbackHolder.align = 'center';
|
n@2407
|
474 playbackHolder.appendChild(interfaceContext.playhead.object);
|
n@2407
|
475 feedbackHolder.appendChild(playbackHolder);
|
n@2407
|
476 }
|
n@2407
|
477 } else if (interfaceList[k].options[i].type == 'show' && interfaceList[k].options[i].name == 'page-count')
|
n@2407
|
478 {
|
n@2407
|
479 var pagecountHolder = document.getElementById('page-count');
|
n@2407
|
480 if (pagecountHolder == null)
|
n@2407
|
481 {
|
n@2407
|
482 pagecountHolder = document.createElement('div');
|
n@2407
|
483 pagecountHolder.id = 'page-count';
|
n@2407
|
484 }
|
n@2407
|
485 pagecountHolder.innerHTML = '<span>Page '+(testState.stateIndex+1)+' of '+testState.stateMap.length+'</span>';
|
n@2407
|
486 var inject = document.getElementById('interface-buttons');
|
n@2407
|
487 inject.appendChild(pagecountHolder);
|
n@2407
|
488 } else if (interfaceList[k].options[i].type == 'show' && interfaceList[k].options[i].name == 'volume') {
|
n@2407
|
489 if (document.getElementById('master-volume-holder') == null)
|
n@2407
|
490 {
|
n@2407
|
491 feedbackHolder.appendChild(interfaceContext.volume.object);
|
n@2407
|
492 }
|
n@2407
|
493 } else if (interfaceList[k].options[i].type == 'show' && interfaceList[k].options[i].name == 'comments') {
|
n@2407
|
494 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder,true);
|
n@2407
|
495 break;
|
n@2407
|
496 }
|
n@2407
|
497 }
|
n@2407
|
498 }
|
n@2407
|
499
|
n@2407
|
500 $(audioHolderObject.commentQuestions).each(function(index,element) {
|
nickjillings@1341
|
501 var node = interfaceContext.createCommentQuestion(element);
|
nickjillings@1341
|
502 feedbackHolder.appendChild(node.holder);
|
nickjillings@1341
|
503 });
|
nickjillings@1341
|
504
|
nickjillings@1341
|
505 //testWaitIndicator();
|
nickjillings@1341
|
506 }
|
nickjillings@1341
|
507
|
nickjillings@1341
|
508 function interfaceSliderHolder(interfaceObject)
|
nickjillings@1341
|
509 {
|
nickjillings@1341
|
510 this.sliders = [];
|
nickjillings@1341
|
511 this.metrics = [];
|
nickjillings@1341
|
512 this.id = document.getElementsByClassName("sliderCanvasDiv").length;
|
nickjillings@1341
|
513 this.name = interfaceObject.name;
|
nickjillings@1341
|
514 this.interfaceObject = interfaceObject;
|
nickjillings@1341
|
515 this.sliderDOM = document.createElement('div');
|
nickjillings@1341
|
516 this.sliderDOM.className = 'sliderCanvasDiv';
|
nickjillings@1341
|
517 this.sliderDOM.id = 'sliderCanvasHolder-'+this.id;
|
nickjillings@1341
|
518
|
nickjillings@1341
|
519 var pagetitle = document.createElement('div');
|
nickjillings@1341
|
520 pagetitle.className = "pageTitle";
|
nickjillings@1341
|
521 pagetitle.align = "center";
|
nickjillings@1341
|
522 var titleSpan = document.createElement('span');
|
nickjillings@1341
|
523 titleSpan.id = "pageTitle-"+this.id;
|
nickjillings@1341
|
524 if (interfaceObject.title != undefined && typeof interfaceObject.title == "string")
|
nickjillings@1341
|
525 {
|
nickjillings@1341
|
526 titleSpan.textContent = interfaceObject.title;
|
nickjillings@1341
|
527 } else {
|
nickjillings@1341
|
528 titleSpan.textContent = "Axis "+String(this.id+1);
|
nickjillings@1341
|
529 }
|
nickjillings@1341
|
530 pagetitle.appendChild(titleSpan);
|
nickjillings@1341
|
531 this.sliderDOM.appendChild(pagetitle);
|
nickjillings@1341
|
532
|
nickjillings@1341
|
533 // Create the slider box to hold the slider elements
|
nickjillings@1341
|
534 this.canvas = document.createElement('div');
|
nickjillings@1341
|
535 if (this.name != undefined)
|
nickjillings@1341
|
536 this.canvas.id = 'slider-'+this.name;
|
nickjillings@1341
|
537 else
|
nickjillings@1341
|
538 this.canvas.id = 'slider-'+this.id;
|
nickjillings@1341
|
539 this.canvas.setAttribute("interfaceid",this.id);
|
nickjillings@1341
|
540 this.canvas.className = 'slider';
|
nickjillings@1341
|
541 this.canvas.align = "left";
|
nickjillings@1341
|
542 this.canvas.addEventListener('dragover',function(event){
|
nickjillings@1341
|
543 event.preventDefault();
|
nickjillings@1341
|
544 event.dataTransfer.effectAllowed = 'none';
|
nickjillings@1341
|
545 event.dataTransfer.dropEffect = 'copy';
|
nickjillings@1341
|
546 return false;
|
nickjillings@1341
|
547 },false);
|
nickjillings@1341
|
548 this.sliderDOM.appendChild(this.canvas);
|
nickjillings@1341
|
549
|
nickjillings@1341
|
550 // Create the div to hold any scale objects
|
nickjillings@1341
|
551 this.scale = document.createElement('div');
|
nickjillings@1341
|
552 this.scale.className = 'sliderScale';
|
nickjillings@1341
|
553 this.scale.id = 'sliderScaleHolder-'+this.id;
|
nickjillings@1341
|
554 this.scale.align = 'left';
|
nickjillings@1341
|
555 this.sliderDOM.appendChild(this.scale);
|
nickjillings@1341
|
556 var positionScale = this.canvas.style.width.substr(0,this.canvas.style.width.length-2);
|
nicholas@2391
|
557 var offset = 50;
|
nickjillings@1317
|
558 var dest = document.getElementById("slider-holder").appendChild(this.sliderDOM);
|
nickjillings@1341
|
559 for (var scaleObj of interfaceObject.scales)
|
nickjillings@1341
|
560 {
|
nickjillings@1341
|
561 var position = Number(scaleObj.position)*0.01;
|
nickjillings@1317
|
562 var pixelPosition = (position*$(this.canvas).width())+offset;
|
nickjillings@1341
|
563 var scaleDOM = document.createElement('span');
|
nicholas@2391
|
564 scaleDOM.className = "ape-marker-text";
|
nickjillings@1341
|
565 scaleDOM.textContent = scaleObj.text;
|
nickjillings@1317
|
566 scaleDOM.setAttribute('value',position)
|
nickjillings@1341
|
567 this.scale.appendChild(scaleDOM);
|
nickjillings@1341
|
568 scaleDOM.style.left = Math.floor((pixelPosition-($(scaleDOM).width()/2)))+'px';
|
nickjillings@1341
|
569 }
|
nickjillings@1341
|
570
|
nickjillings@2168
|
571 this.createSliderObject = function(audioObject,label)
|
nickjillings@1341
|
572 {
|
nickjillings@1341
|
573 var trackObj = document.createElement('div');
|
nickjillings@1317
|
574 trackObj.align = "center";
|
nickjillings@1341
|
575 trackObj.className = 'track-slider track-slider-disabled track-slider-'+audioObject.id;
|
nickjillings@1341
|
576 trackObj.id = 'track-slider-'+this.id+'-'+audioObject.id;
|
nickjillings@1341
|
577 trackObj.setAttribute('trackIndex',audioObject.id);
|
nickjillings@1341
|
578 if (this.name != undefined) {
|
nickjillings@1341
|
579 trackObj.setAttribute('interface-name',this.name);
|
nickjillings@1341
|
580 } else {
|
nickjillings@1341
|
581 trackObj.setAttribute('interface-name',this.id);
|
nickjillings@1341
|
582 }
|
nicholas@2391
|
583 var offset = 50;
|
nickjillings@1341
|
584 // Distribute it randomnly
|
nickjillings@1341
|
585 var w = window.innerWidth - (offset+8)*2;
|
nickjillings@1341
|
586 w = Math.random()*w;
|
nickjillings@1341
|
587 w = Math.floor(w+(offset+8));
|
nickjillings@1341
|
588 trackObj.style.left = w+'px';
|
nickjillings@1341
|
589 this.canvas.appendChild(trackObj);
|
nickjillings@1341
|
590 this.sliders.push(trackObj);
|
nickjillings@1341
|
591 this.metrics.push(new metricTracker(this));
|
nickjillings@2168
|
592 var labelHolder = document.createElement("span");
|
nickjillings@2168
|
593 labelHolder.textContent = label;
|
nickjillings@2168
|
594 trackObj.appendChild(labelHolder);
|
nicholas@2391
|
595 var rate = convSliderPosToRate(trackObj);
|
nicholas@2391
|
596 this.metrics[this.metrics.length-1].initialise(rate);
|
nicholas@2391
|
597 trackObj.setAttribute("slider-value",rate);
|
nickjillings@1341
|
598 return trackObj;
|
nickjillings@1341
|
599 };
|
nickjillings@1341
|
600
|
nickjillings@1341
|
601 this.resize = function(event)
|
nickjillings@1341
|
602 {
|
nicholas@2391
|
603 var width = window.innerWidth;
|
nickjillings@1341
|
604 var sliderDiv = this.canvas;
|
nickjillings@1341
|
605 var sliderScaleDiv = this.scale;
|
nicholas@2391
|
606 var width = $(sliderDiv).width();
|
nicholas@2391
|
607 var marginsize = 50;
|
nickjillings@1341
|
608 // Move sliders into new position
|
nickjillings@1341
|
609 for (var index = 0; index < this.sliders.length; index++)
|
nickjillings@1341
|
610 {
|
nicholas@2391
|
611 var pix = Number(this.sliders[index].getAttribute("slider-value")) * width;
|
nicholas@2391
|
612 this.sliders[index].style.left = (pix+marginsize)+'px';
|
nickjillings@1341
|
613 }
|
nickjillings@1341
|
614
|
nickjillings@1341
|
615 // Move scale labels
|
nickjillings@1341
|
616 for (var index = 0; index < this.scale.children.length; index++)
|
nickjillings@1341
|
617 {
|
nickjillings@1341
|
618 var scaleObj = this.scale.children[index];
|
nickjillings@1341
|
619 var position = Number(scaleObj.attributes['value'].value);
|
nickjillings@1341
|
620 var pixelPosition = (position*width)+marginsize;
|
nickjillings@1341
|
621 scaleObj.style.left = Math.floor((pixelPosition-($(scaleObj).width()/2)))+'px';
|
nickjillings@1341
|
622 }
|
nickjillings@1341
|
623 };
|
nickjillings@1341
|
624 }
|
nickjillings@1341
|
625
|
nickjillings@2168
|
626 function sliderObject(audioObject,interfaceObjects,index) {
|
nickjillings@1341
|
627 // Create a new slider object;
|
nickjillings@1341
|
628 this.parent = audioObject;
|
nickjillings@1341
|
629 this.trackSliderObjects = [];
|
nickjillings@2168
|
630 this.label = null;
|
n@2428
|
631 this.playing = false;
|
nickjillings@2168
|
632 switch(audioObject.specification.parent.label) {
|
nickjillings@2168
|
633 case "letter":
|
nickjillings@2168
|
634 this.label = String.fromCharCode(97 + index);
|
nickjillings@2168
|
635 break;
|
nickjillings@2168
|
636 case "capital":
|
nickjillings@2168
|
637 this.label = String.fromCharCode(65 + index);
|
nickjillings@2168
|
638 break;
|
nickjillings@2168
|
639 case "none":
|
nickjillings@2168
|
640 this.label = "";
|
nickjillings@2168
|
641 break;
|
nickjillings@2168
|
642 default:
|
nickjillings@2168
|
643 this.label = ""+(index+1);
|
nickjillings@2168
|
644 break;
|
nickjillings@2168
|
645 }
|
nickjillings@1341
|
646 for (var i=0; i<interfaceContext.interfaceSliders.length; i++)
|
nickjillings@1341
|
647 {
|
nickjillings@2168
|
648 var trackObj = interfaceContext.interfaceSliders[i].createSliderObject(audioObject,this.label);
|
nickjillings@1341
|
649 this.trackSliderObjects.push(trackObj);
|
nickjillings@1341
|
650 }
|
nickjillings@1341
|
651
|
nickjillings@1341
|
652 // Onclick, switch playback to that track
|
nickjillings@1341
|
653
|
nickjillings@1341
|
654 this.enable = function() {
|
nickjillings@1341
|
655 if (this.parent.state == 1)
|
nickjillings@1341
|
656 {
|
nickjillings@1341
|
657 $(this.trackSliderObjects).each(function(i,trackObj){
|
nickjillings@1341
|
658 $(trackObj).removeClass('track-slider-disabled');
|
nickjillings@1341
|
659 });
|
nickjillings@1341
|
660 }
|
nickjillings@1341
|
661 };
|
nickjillings@1341
|
662 this.updateLoading = function(progress)
|
nickjillings@1341
|
663 {
|
nickjillings@1341
|
664 if (progress != 100)
|
nickjillings@1341
|
665 {
|
nickjillings@1341
|
666 progress = String(progress);
|
nickjillings@1341
|
667 progress = progress.split('.')[0];
|
nickjillings@1341
|
668 this.trackSliderObjects[0].children[0].textContent = progress+'%';
|
nickjillings@1341
|
669 } else {
|
nickjillings@2171
|
670 this.trackSliderObjects[0].children[0].textContent = this.label;
|
nickjillings@1341
|
671 }
|
nickjillings@1341
|
672 };
|
nickjillings@1360
|
673 this.startPlayback = function()
|
nickjillings@1360
|
674 {
|
nickjillings@1360
|
675 $('.track-slider').removeClass('track-slider-playing');
|
nickjillings@1360
|
676 var name = ".track-slider-"+this.parent.id;
|
nickjillings@1360
|
677 $(name).addClass('track-slider-playing');
|
nickjillings@1360
|
678 $('.comment-div').removeClass('comment-box-playing');
|
nickjillings@1360
|
679 $('#comment-div-'+this.parent.id).addClass('comment-box-playing');
|
n@2428
|
680 $('.outside-reference').removeClass('track-slider-playing');
|
n@2428
|
681 this.playing = true;
|
n@2428
|
682
|
n@2428
|
683 if (this.parent.specification.parent.playOne || specification.playOne) {
|
n@2428
|
684 $('.track-slider').addClass('track-slider-disabled');
|
n@2428
|
685 $('.outside-reference').addClass('track-slider-disabled');
|
n@2428
|
686 }
|
nickjillings@1360
|
687 };
|
nickjillings@1360
|
688 this.stopPlayback = function()
|
nickjillings@1360
|
689 {
|
n@2428
|
690 if (this.playing) {
|
n@2428
|
691 this.playing = false;
|
n@2428
|
692 var name = ".track-slider-"+this.parent.id;
|
n@2428
|
693 $(name).removeClass('track-slider-playing');
|
n@2428
|
694 $('#comment-div-'+this.parent.id).removeClass('comment-box-playing');
|
n@2428
|
695 $('.track-slider').removeClass('track-slider-disabled');
|
n@2428
|
696 $('.outside-reference').removeClass('track-slider-disabled');
|
n@2428
|
697 }
|
nickjillings@1360
|
698 };
|
nickjillings@1341
|
699 this.exportXMLDOM = function(audioObject) {
|
nickjillings@1341
|
700 // Called by the audioObject holding this element. Must be present
|
nickjillings@1341
|
701 var obj = [];
|
nickjillings@1341
|
702 $(this.trackSliderObjects).each(function(i,trackObj){
|
nickjillings@1341
|
703 var node = storage.document.createElement('value');
|
nickjillings@1341
|
704 node.setAttribute("interface-name",trackObj.getAttribute("interface-name"));
|
nickjillings@1341
|
705 node.textContent = convSliderPosToRate(trackObj);
|
nickjillings@1341
|
706 obj.push(node);
|
nickjillings@1341
|
707 });
|
nickjillings@1341
|
708
|
nickjillings@1341
|
709 return obj;
|
nickjillings@1341
|
710 };
|
nickjillings@1341
|
711 this.getValue = function() {
|
nickjillings@1341
|
712 return convSliderPosToRate(this.trackSliderObjects[0]);
|
nickjillings@1341
|
713 };
|
nickjillings@1341
|
714 this.getPresentedId = function()
|
nickjillings@1341
|
715 {
|
nickjillings@2168
|
716 return this.label;
|
nickjillings@1341
|
717 };
|
nickjillings@1341
|
718 this.canMove = function()
|
nickjillings@1341
|
719 {
|
nickjillings@1341
|
720 return true;
|
nickjillings@1341
|
721 };
|
nickjillings@2113
|
722 this.error = function() {
|
nickjillings@2113
|
723 // audioObject has an error!!
|
nickjillings@2113
|
724 this.playback.textContent = "Error";
|
nickjillings@2113
|
725 $(this.playback).addClass("error-colour");
|
nickjillings@2113
|
726 }
|
nickjillings@1341
|
727 }
|
nickjillings@1341
|
728
|
nickjillings@1341
|
729 function outsideReferenceDOM(audioObject,index,inject)
|
nickjillings@1341
|
730 {
|
nickjillings@1341
|
731 this.parent = audioObject;
|
nickjillings@1341
|
732 this.outsideReferenceHolder = document.createElement('div');
|
nickjillings@1341
|
733 this.outsideReferenceHolder.id = 'outside-reference';
|
nickjillings@1341
|
734 this.outsideReferenceHolder.className = 'outside-reference track-slider-disabled';
|
nickjillings@1341
|
735 var outsideReferenceHolderspan = document.createElement('span');
|
nickjillings@1341
|
736 outsideReferenceHolderspan.textContent = 'Reference';
|
nickjillings@1341
|
737 this.outsideReferenceHolder.appendChild(outsideReferenceHolderspan);
|
nickjillings@1341
|
738 this.outsideReferenceHolder.setAttribute('track-id',index);
|
nickjillings@1341
|
739
|
nickjillings@1341
|
740 this.outsideReferenceHolder.onclick = function(event)
|
nickjillings@1341
|
741 {
|
nickjillings@1341
|
742 audioEngineContext.play(event.currentTarget.getAttribute('track-id'));
|
nickjillings@1341
|
743 $('.track-slider').removeClass('track-slider-playing');
|
nickjillings@1341
|
744 $('.comment-div').removeClass('comment-box-playing');
|
nickjillings@1341
|
745 if (event.currentTarget.nodeName == 'DIV') {
|
nickjillings@1341
|
746 $(event.currentTarget).addClass('track-slider-playing');
|
nickjillings@1341
|
747 } else {
|
nickjillings@1341
|
748 $(event.currentTarget.parentElement).addClass('track-slider-playing');
|
nickjillings@1341
|
749 }
|
nickjillings@1341
|
750 };
|
nickjillings@1341
|
751 inject.appendChild(this.outsideReferenceHolder);
|
nickjillings@1341
|
752 this.enable = function()
|
nickjillings@1341
|
753 {
|
nickjillings@1341
|
754 if (this.parent.state == 1)
|
nickjillings@1341
|
755 {
|
nickjillings@1341
|
756 $(this.outsideReferenceHolder).removeClass('track-slider-disabled');
|
nickjillings@1341
|
757 }
|
nickjillings@1341
|
758 };
|
nickjillings@1341
|
759 this.updateLoading = function(progress)
|
nickjillings@1341
|
760 {
|
nickjillings@1341
|
761 if (progress != 100)
|
nickjillings@1341
|
762 {
|
nickjillings@1341
|
763 progress = String(progress);
|
nickjillings@1341
|
764 progress = progress.split('.')[0];
|
nicholas@2396
|
765 this.outsideReferenceHolder.firstChild.textContent = progress+'%';
|
nickjillings@1341
|
766 } else {
|
nicholas@2396
|
767 this.outsideReferenceHolder.firstChild.textContent = "Play Reference";
|
nickjillings@1341
|
768 }
|
nickjillings@1341
|
769 };
|
nickjillings@1360
|
770 this.startPlayback = function()
|
nickjillings@1360
|
771 {
|
nickjillings@1360
|
772 $('.track-slider').removeClass('track-slider-playing');
|
nickjillings@1360
|
773 $(this.outsideReferenceHolder).addClass('track-slider-playing');
|
nickjillings@1360
|
774 $('.comment-div').removeClass('comment-box-playing');
|
nickjillings@1360
|
775 };
|
nickjillings@1360
|
776 this.stopPlayback = function()
|
nickjillings@1360
|
777 {
|
nickjillings@1360
|
778 $(this.outsideReferenceHolder).removeClass('track-slider-playing');
|
nickjillings@1360
|
779 };
|
nickjillings@1341
|
780 this.exportXMLDOM = function(audioObject)
|
nickjillings@1341
|
781 {
|
nickjillings@1341
|
782 return null;
|
nickjillings@1341
|
783 };
|
nickjillings@1341
|
784 this.getValue = function()
|
nickjillings@1341
|
785 {
|
nickjillings@1341
|
786 return 0;
|
nickjillings@1341
|
787 };
|
nickjillings@1341
|
788 this.getPresentedId = function()
|
nickjillings@1341
|
789 {
|
nickjillings@1341
|
790 return 'reference';
|
nickjillings@1341
|
791 };
|
nickjillings@1341
|
792 this.canMove = function()
|
nickjillings@1341
|
793 {
|
nickjillings@1341
|
794 return false;
|
nickjillings@1341
|
795 };
|
nickjillings@2113
|
796 this.error = function() {
|
nickjillings@2113
|
797 // audioObject has an error!!
|
nickjillings@2113
|
798 this.outsideReferenceHolder.textContent = "Error";
|
nickjillings@2113
|
799 $(this.outsideReferenceHolder).addClass("error-colour");
|
nickjillings@2113
|
800 }
|
nickjillings@1341
|
801 }
|
nickjillings@1341
|
802
|
nickjillings@1341
|
803 function buttonSubmitClick()
|
nickjillings@1341
|
804 {
|
nickjillings@1341
|
805 var checks = [];
|
nickjillings@1341
|
806 checks = checks.concat(testState.currentStateMap.interfaces[0].options);
|
nickjillings@1341
|
807 checks = checks.concat(specification.interfaces.options);
|
nickjillings@1341
|
808 var canContinue = true;
|
nickjillings@1341
|
809
|
nickjillings@1341
|
810 // Check that the anchor and reference objects are correctly placed
|
nickjillings@1341
|
811 if (interfaceContext.checkHiddenAnchor() == false) {return;}
|
nickjillings@1341
|
812 if (interfaceContext.checkHiddenReference() == false) {return;}
|
nickjillings@1341
|
813
|
nickjillings@1341
|
814 for (var i=0; i<checks.length; i++) {
|
nickjillings@1341
|
815 if (checks[i].type == 'check')
|
nickjillings@1341
|
816 {
|
nickjillings@1341
|
817 switch(checks[i].name) {
|
nickjillings@1341
|
818 case 'fragmentPlayed':
|
nickjillings@1341
|
819 // Check if all fragments have been played
|
nickjillings@1341
|
820 var checkState = interfaceContext.checkAllPlayed();
|
nickjillings@1341
|
821 if (checkState == false) {canContinue = false;}
|
nickjillings@1341
|
822 break;
|
nickjillings@1341
|
823 case 'fragmentFullPlayback':
|
nickjillings@1341
|
824 // Check all fragments have been played to their full length
|
nickjillings@1341
|
825 var checkState = interfaceContext.checkFragmentsFullyPlayed();
|
nickjillings@1341
|
826 if (checkState == false) {canContinue = false;}
|
nickjillings@1341
|
827 break;
|
nickjillings@1341
|
828 case 'fragmentMoved':
|
nickjillings@1341
|
829 // Check all fragment sliders have been moved.
|
nickjillings@1341
|
830 var checkState = interfaceContext.checkAllMoved();
|
nickjillings@1341
|
831 if (checkState == false) {canContinue = false;}
|
nickjillings@1341
|
832 break;
|
nickjillings@1341
|
833 case 'fragmentComments':
|
nickjillings@1341
|
834 // Check all fragment sliders have been moved.
|
nickjillings@1341
|
835 var checkState = interfaceContext.checkAllCommented();
|
nickjillings@1341
|
836 if (checkState == false) {canContinue = false;}
|
nickjillings@1341
|
837 break;
|
nickjillings@1341
|
838 case 'scalerange':
|
nickjillings@1341
|
839 // Check the scale is used to its full width outlined by the node
|
nickjillings@1341
|
840 var checkState = interfaceContext.checkScaleRange();
|
nickjillings@1341
|
841 if (checkState == false) {canContinue = false;}
|
nickjillings@1341
|
842 break;
|
nickjillings@1341
|
843 default:
|
nickjillings@1341
|
844 console.log("WARNING - Check option "+checks[i].name+" is not supported on this interface");
|
nickjillings@1341
|
845 break;
|
nickjillings@1341
|
846 }
|
nickjillings@1341
|
847
|
nickjillings@1341
|
848 }
|
nickjillings@1341
|
849 if (!canContinue) {break;}
|
nickjillings@1341
|
850 }
|
nickjillings@1341
|
851
|
nickjillings@1341
|
852 if (canContinue) {
|
nickjillings@1341
|
853 if (audioEngineContext.status == 1) {
|
nickjillings@1341
|
854 var playback = document.getElementById('playback-button');
|
nickjillings@1341
|
855 playback.click();
|
nickjillings@1341
|
856 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
|
nickjillings@1341
|
857 } else
|
nickjillings@1341
|
858 {
|
nickjillings@1341
|
859 if (audioEngineContext.timer.testStarted == false)
|
nickjillings@1341
|
860 {
|
nicholas@2362
|
861 interfaceContext.lightbox.post("Warning",'You have not started the test! Please click a fragment to begin the test!');
|
nickjillings@1341
|
862 return;
|
nickjillings@1341
|
863 }
|
nickjillings@1341
|
864 }
|
nickjillings@1341
|
865 testState.advanceState();
|
nickjillings@1341
|
866 }
|
nickjillings@1341
|
867 }
|
nickjillings@1341
|
868
|
nickjillings@1341
|
869 function convSliderPosToRate(trackSlider)
|
nickjillings@1341
|
870 {
|
nickjillings@1341
|
871 var slider = trackSlider.parentElement;
|
nicholas@2391
|
872 var maxPix = $(slider).width();
|
nicholas@2391
|
873 var marginsize = 50;
|
nickjillings@1341
|
874 var pix = trackSlider.style.left;
|
nickjillings@1341
|
875 pix = pix.substr(0,pix.length-2);
|
nickjillings@1341
|
876 var rate = (pix-marginsize)/maxPix;
|
nickjillings@1341
|
877 return rate;
|
nickjillings@1341
|
878 }
|
nickjillings@1341
|
879
|
nickjillings@1341
|
880 function resizeWindow(event){
|
nickjillings@1341
|
881 // Function called when the window has been resized.
|
nickjillings@1341
|
882 // MANDATORY FUNCTION
|
nickjillings@1341
|
883
|
nickjillings@1341
|
884 // Resize the slider objects
|
nickjillings@1341
|
885 for (var i=0; i<interfaceContext.interfaceSliders.length; i++)
|
nickjillings@1341
|
886 {
|
nickjillings@1341
|
887 interfaceContext.interfaceSliders[i].resize(event);
|
nickjillings@1341
|
888 }
|
nickjillings@1341
|
889 }
|
nickjillings@1341
|
890
|
nickjillings@1341
|
891 function pageXMLSave(store, pageSpecification)
|
nickjillings@1341
|
892 {
|
nickjillings@1341
|
893 // MANDATORY
|
nickjillings@1341
|
894 // Saves a specific test page
|
nickjillings@1341
|
895 // You can use this space to add any extra nodes to your XML <audioHolder> saves
|
nickjillings@1341
|
896 // Get the current <page> information in store (remember to appendChild your data to it)
|
nickjillings@1341
|
897 // pageSpecification is the current page node configuration
|
nickjillings@1341
|
898 // To create new XML nodes, use storage.document.createElement();
|
nickjillings@1341
|
899
|
nickjillings@1341
|
900 if (interfaceContext.interfaceSliders.length == 1)
|
nickjillings@1341
|
901 {
|
nickjillings@1341
|
902 // If there is only one axis, there only needs to be one metric return
|
nickjillings@1341
|
903 return;
|
nickjillings@1341
|
904 }
|
nickjillings@1341
|
905 var audioelements = store.getElementsByTagName("audioelement");
|
nickjillings@1341
|
906 for (var i=0; i<audioelements.length; i++)
|
nickjillings@1341
|
907 {
|
nickjillings@1341
|
908 // Have to append the metric specific nodes
|
nickjillings@1341
|
909 if (pageSpecification.outsideReference == null || pageSpecification.outsideReference.id != audioelements[i].id)
|
nickjillings@1341
|
910 {
|
nickjillings@1341
|
911 var inject = audioelements[i].getElementsByTagName("metric");
|
nickjillings@1341
|
912 if (inject.length == 0)
|
nickjillings@1341
|
913 {
|
nickjillings@1341
|
914 inject = storage.document.createElement("metric");
|
nickjillings@1341
|
915 } else {
|
nickjillings@1341
|
916 inject = inject[0];
|
nickjillings@1341
|
917 }
|
nickjillings@1341
|
918 for (var k=0; k<interfaceContext.interfaceSliders.length; k++)
|
nickjillings@1341
|
919 {
|
nickjillings@1341
|
920 var mrnodes = interfaceContext.interfaceSliders[k].metrics[i].exportXMLDOM(inject);
|
nickjillings@1341
|
921 for (var j=0; j<mrnodes.length; j++)
|
nickjillings@1341
|
922 {
|
nickjillings@1341
|
923 var name = mrnodes[j].getAttribute("name");
|
nickjillings@1341
|
924 if (name == "elementTracker" || name == "elementTrackerFull" || name == "elementInitialPosition" || name == "elementFlagMoved")
|
nickjillings@1341
|
925 {
|
nickjillings@1341
|
926 mrnodes[j].setAttribute("interface-name",interfaceContext.interfaceSliders[k].name);
|
nickjillings@1341
|
927 mrnodes[j].setAttribute("interface-id",k);
|
nickjillings@1341
|
928 inject.appendChild(mrnodes[j]);
|
nickjillings@1341
|
929 }
|
nickjillings@1341
|
930 }
|
nickjillings@1341
|
931 }
|
nickjillings@1341
|
932 }
|
nickjillings@1341
|
933 }
|
nickjillings@1341
|
934 } |