comparison js/core.js @ 2689:f4a146282ef5

Several compatability fixes
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Sat, 11 Mar 2017 11:00:45 +0000
parents 66a24a6a0358
children 9eb3ff794d63
comparison
equal deleted inserted replaced
2688:78717148d815 2689:f4a146282ef5
326 specification.decode(projectXML); 326 specification.decode(projectXML);
327 // Use the original 327 // Use the original
328 storage.initialise(responseDocument); 328 storage.initialise(responseDocument);
329 } 329 }
330 /// CHECK FOR SAMPLE RATE COMPATIBILITY 330 /// CHECK FOR SAMPLE RATE COMPATIBILITY
331 if (specification.sampleRate !== null) { 331 if (isFinite(specification.sampleRate)) {
332 if (Number(specification.sampleRate) != audioContext.sampleRate) { 332 if (Number(specification.sampleRate) != audioContext.sampleRate) {
333 var errStr = 'Sample rates do not match! Requested ' + Number(specification.sampleRate) + ', got ' + audioContext.sampleRate + '. Please set the sample rate to match before completing this test.'; 333 var errStr = 'Sample rates do not match! Requested ' + Number(specification.sampleRate) + ', got ' + audioContext.sampleRate + '. Please set the sample rate to match before completing this test.';
334 interfaceContext.lightbox.post("Error", errStr); 334 interfaceContext.lightbox.post("Error", errStr);
335 return; 335 return;
336 } 336 }
607 conditionFunction = processQuestionConditional; 607 conditionFunction = processQuestionConditional;
608 } else if (node.specification.type === "checkbox") { 608 } else if (node.specification.type === "checkbox") {
609 conditionFunction = processCheckboxConditional; 609 conditionFunction = processCheckboxConditional;
610 } else if (node.specification.type === "radio") { 610 } else if (node.specification.type === "radio") {
611 conditionFunction = processRadioConditional; 611 conditionFunction = processRadioConditional;
612 } else if (node.specifiication.type === "number") { 612 } else if (node.specification.type === "number") {
613 conditionFunction = processNumberConditional; 613 conditionFunction = processNumberConditional;
614 } else if (node.specification.type === "slider") { 614 } else if (node.specification.type === "slider") {
615 conditionFunction = processSliderConditional; 615 conditionFunction = processSliderConditional;
616 } else { 616 } else {
617 return; 617 return;
799 } 799 }
800 return false; 800 return false;
801 } 801 }
802 802
803 function postRadio(node) { 803 function postRadio(node) {
804 if (node.response === undefined) { 804 if (node.response === null) {
805 node.response = { 805 node.response = {
806 name: "", 806 name: "",
807 text: "" 807 text: ""
808 }; 808 };
809 } 809 }
810 var index = 0;
811 var table = document.createElement("table"); 810 var table = document.createElement("table");
812 table.className = "popup-option-list"; 811 table.className = "popup-option-list";
813 table.border = "0"; 812 table.border = "0";
814 node.specification.options.forEach(function (option) { 813 if (node.response === null || node.response.length === 0) {
814 node.response = [];
815 }
816 node.specification.options.forEach(function (option, index) {
815 var tr = document.createElement("tr"); 817 var tr = document.createElement("tr");
816 table.appendChild(tr); 818 table.appendChild(tr);
817 var td = document.createElement("td"); 819 var td = document.createElement("td");
818 tr.appendChild(td); 820 tr.appendChild(td);
819 var input = document.createElement('input'); 821 var input = document.createElement('input');
828 span.textContent = option.text; 830 span.textContent = option.text;
829 td.appendChild(span); 831 td.appendChild(span);
830 tr = document.createElement('div'); 832 tr = document.createElement('div');
831 tr.setAttribute('name', 'option'); 833 tr.setAttribute('name', 'option');
832 tr.className = "popup-option-checbox"; 834 tr.className = "popup-option-checbox";
833 if (node.response[index] !== undefined) { 835 table.appendChild(tr);
834 if (node.response[index].checked === true) {
835 input.checked = "true";
836 }
837 }
838 index++;
839 }); 836 });
840 this.popupResponse.appendChild(table); 837 this.popupResponse.appendChild(table);
841 } 838 }
842 839
843 function processRadio(node) { 840 function processRadio(node) {
2205 function exportElementTimer(parentElement) { 2202 function exportElementTimer(parentElement) {
2206 var mElementTimer = storage.document.createElement('metricresult'); 2203 var mElementTimer = storage.document.createElement('metricresult');
2207 mElementTimer.setAttribute('name', 'enableElementTimer'); 2204 mElementTimer.setAttribute('name', 'enableElementTimer');
2208 mElementTimer.textContent = this.listenedTimer; 2205 mElementTimer.textContent = this.listenedTimer;
2209 parentElement.appendChild(mElementTimer); 2206 parentElement.appendChild(mElementTimer);
2207 return mElementTimer;
2210 } 2208 }
2211 2209
2212 function exportElementTrack(parentElement) { 2210 function exportElementTrack(parentElement) {
2213 var elementTrackerFull = storage.document.createElement('metricresult'); 2211 var elementTrackerFull = storage.document.createElement('metricresult');
2214 elementTrackerFull.setAttribute('name', 'elementTrackerFull'); 2212 elementTrackerFull.setAttribute('name', 'elementTrackerFull');
2217 timePos.setAttribute("time", this.movementTracker[k][0]); 2215 timePos.setAttribute("time", this.movementTracker[k][0]);
2218 timePos.setAttribute("value", this.movementTracker[k][1]); 2216 timePos.setAttribute("value", this.movementTracker[k][1]);
2219 elementTrackerFull.appendChild(timePos); 2217 elementTrackerFull.appendChild(timePos);
2220 } 2218 }
2221 parentElement.appendChild(elementTrackerFull); 2219 parentElement.appendChild(elementTrackerFull);
2220 return elementTrackerFull;
2222 } 2221 }
2223 2222
2224 function exportElementListenTracker(parentElement) { 2223 function exportElementListenTracker(parentElement) {
2225 var elementListenTracker = storage.document.createElement('metricresult'); 2224 var elementListenTracker = storage.document.createElement('metricresult');
2226 elementListenTracker.setAttribute('name', 'elementListenTracker'); 2225 elementListenTracker.setAttribute('name', 'elementListenTracker');
2227 for (var k = 0; k < this.listenTracker.length; k++) { 2226 for (var k = 0; k < this.listenTracker.length; k++) {
2228 elementListenTracker.appendChild(this.listenTracker[k]); 2227 elementListenTracker.appendChild(this.listenTracker[k]);
2229 } 2228 }
2230 parentElement.appendChild(elementListenTracker); 2229 parentElement.appendChild(elementListenTracker);
2230 return elementListenTracker;
2231 } 2231 }
2232 2232
2233 function exportElementInitialPosition(parentElement) { 2233 function exportElementInitialPosition(parentElement) {
2234 var elementInitial = storage.document.createElement('metricresult'); 2234 var elementInitial = storage.document.createElement('metricresult');
2235 elementInitial.setAttribute('name', 'elementInitialPosition'); 2235 elementInitial.setAttribute('name', 'elementInitialPosition');
2236 elementInitial.textContent = this.initialPosition; 2236 elementInitial.textContent = this.initialPosition;
2237 parentElement.appendChild(elementInitial); 2237 parentElement.appendChild(elementInitial);
2238 return elementInitial;
2238 } 2239 }
2239 2240
2240 function exportFlagListenedTo(parentElement) { 2241 function exportFlagListenedTo(parentElement) {
2241 var flagListenedTo = storage.document.createElement('metricresult'); 2242 var flagListenedTo = storage.document.createElement('metricresult');
2242 flagListenedTo.setAttribute('name', 'elementFlagListenedTo'); 2243 flagListenedTo.setAttribute('name', 'elementFlagListenedTo');
2243 flagListenedTo.textContent = this.wasListenedTo; 2244 flagListenedTo.textContent = this.wasListenedTo;
2244 parentElement.appendChild(flagListenedTo); 2245 parentElement.appendChild(flagListenedTo);
2246 return flagListenedTo;
2245 } 2247 }
2246 2248
2247 function exportFlagMoved(parentElement) { 2249 function exportFlagMoved(parentElement) {
2248 var flagMoved = storage.document.createElement('metricresult'); 2250 var flagMoved = storage.document.createElement('metricresult');
2249 flagMoved.setAttribute('name', 'elementFlagMoved'); 2251 flagMoved.setAttribute('name', 'elementFlagMoved');
2250 flagMoved.textContent = this.wasMoved; 2252 flagMoved.textContent = this.wasMoved;
2251 parentElement.appendChild(flagMoved); 2253 parentElement.appendChild(flagMoved);
2254 return flagMoved;
2252 } 2255 }
2253 2256
2254 function exportFlagComments(parentElement) { 2257 function exportFlagComments(parentElement) {
2255 var flagComments = storage.document.createElement('metricresult'); 2258 var flagComments = storage.document.createElement('metricresult');
2256 flagComments.setAttribute('name', 'elementFlagComments'); 2259 flagComments.setAttribute('name', 'elementFlagComments');
2260 flagComments.textContent = 'false'; 2263 flagComments.textContent = 'false';
2261 } else { 2264 } else {
2262 flagComments.textContet = 'true'; 2265 flagComments.textContet = 'true';
2263 } 2266 }
2264 parentElement.appendChild(flagComments); 2267 parentElement.appendChild(flagComments);
2268 return flagComments;
2265 } 2269 }
2266 2270
2267 this.exportXMLDOM = function (parentElement) { 2271 this.exportXMLDOM = function (parentElement) {
2272 var elems = []
2268 if (audioEngineContext.metric.enableElementTimer) { 2273 if (audioEngineContext.metric.enableElementTimer) {
2269 exportElementTimer.call(this, parentElement); 2274 elems.push(exportElementTimer.call(this, parentElement));
2270 } 2275 }
2271 if (audioEngineContext.metric.enableElementTracker) { 2276 if (audioEngineContext.metric.enableElementTracker) {
2272 exportElementTrack.call(this, parentElement); 2277 elems.push(exportElementTrack.call(this, parentElement));
2273 } 2278 }
2274 if (audioEngineContext.metric.enableElementListenTracker) { 2279 if (audioEngineContext.metric.enableElementListenTracker) {
2275 exportElementListenTracker.call(this, parentElement); 2280 elems.push(exportElementListenTracker.call(this, parentElement));
2276 } 2281 }
2277 if (audioEngineContext.metric.enableElementInitialPosition) { 2282 if (audioEngineContext.metric.enableElementInitialPosition) {
2278 exportElementInitialPosition.call(this, parentElement); 2283 elems.push(exportElementInitialPosition.call(this, parentElement));
2279 } 2284 }
2280 if (audioEngineContext.metric.enableFlagListenedTo) { 2285 if (audioEngineContext.metric.enableFlagListenedTo) {
2281 exportFlagListenedTo.call(this, parentElement); 2286 elems.push(exportFlagListenedTo.call(this, parentElement));
2282 } 2287 }
2283 if (audioEngineContext.metric.enableFlagMoved) { 2288 if (audioEngineContext.metric.enableFlagMoved) {
2284 exportFlagMoved.call(this, parentElement); 2289 elems.push(exportFlagMoved.call(this, parentElement));
2285 } 2290 }
2286 if (audioEngineContext.metric.enableFlagComments) { 2291 if (audioEngineContext.metric.enableFlagComments) {
2287 exportFlagComments.call(this, parentElement); 2292 elems.push(exportFlagComments.call(this, parentElement));
2288 } 2293 }
2294 return elems;
2289 }; 2295 };
2290 } 2296 }
2291 2297
2292 function Interface(specificationObject) { 2298 function Interface(specificationObject) {
2293 // This handles the bindings between the interface and the audioEngineContext; 2299 // This handles the bindings between the interface and the audioEngineContext;
2649 text = text.firstChild; 2655 text = text.firstChild;
2650 options.style.marginRight = spanMargin; 2656 options.style.marginRight = spanMargin;
2651 options.style.marginLeft = spanMargin; 2657 options.style.marginLeft = spanMargin;
2652 text.style.marginRight = spanMargin; 2658 text.style.marginRight = spanMargin;
2653 text.style.marginLeft = spanMargin; 2659 text.style.marginLeft = spanMargin;
2654 while (options.nextSibling !== undefined) { 2660 while (options = options.nextSibling) {
2655 options = options.nextSibling;
2656 text = text.nextSibling; 2661 text = text.nextSibling;
2657 options.style.marginRight = spanMargin; 2662 options.style.marginRight = spanMargin;
2658 options.style.marginLeft = spanMargin; 2663 options.style.marginLeft = spanMargin;
2659 text.style.marginRight = spanMargin; 2664 text.style.marginRight = spanMargin;
2660 text.style.marginLeft = spanMargin; 2665 text.style.marginLeft = spanMargin;
2748 text = text.firstChild; 2753 text = text.firstChild;
2749 options.style.marginRight = spanMargin; 2754 options.style.marginRight = spanMargin;
2750 options.style.marginLeft = spanMargin; 2755 options.style.marginLeft = spanMargin;
2751 text.style.marginRight = spanMargin; 2756 text.style.marginRight = spanMargin;
2752 text.style.marginLeft = spanMargin; 2757 text.style.marginLeft = spanMargin;
2753 while (options.nextSibling !== undefined) { 2758 while (options = options.nextSibling) {
2754 options = options.nextSibling;
2755 text = text.nextSibling; 2759 text = text.nextSibling;
2756 options.style.marginRight = spanMargin; 2760 options.style.marginRight = spanMargin;
2757 options.style.marginLeft = spanMargin; 2761 options.style.marginLeft = spanMargin;
2758 text.style.marginRight = spanMargin; 2762 text.style.marginRight = spanMargin;
2759 text.style.marginLeft = spanMargin; 2763 text.style.marginLeft = spanMargin;