comparison js/core.js @ 2399:5d7ad658c699

Hotfix: Multiple audioElements with type="outside-reference" may be duplicated / incorrectly sent through randomisation. Fixed.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 26 May 2016 16:06:42 +0100
parents dde1f3254762
children 5e1fb07919e7 2f6a1f510ade
comparison
equal deleted inserted replaced
2397:c970a531228c 2399:5d7ad658c699
1093 popup.hidePopup(); 1093 popup.hidePopup();
1094 if (this.currentStateMap == null) 1094 if (this.currentStateMap == null)
1095 { 1095 {
1096 this.currentStateMap = this.stateMap[this.stateIndex]; 1096 this.currentStateMap = this.stateMap[this.stateIndex];
1097 // Find and extract the outside reference 1097 // Find and extract the outside reference
1098 var elements = [], ref = null; 1098 var elements = [], ref = [];
1099 for (var elem of this.currentStateMap.audioElements) { 1099 var elem;
1100 if (elem.type == "outside-reference") {ref = elem;} 1100 while(elem = this.currentStateMap.audioElements.pop())
1101 else {elements.push(elem);} 1101 {
1102 if (elem.type == "outside-reference") {
1103 ref.push(elem);
1104 }
1105 else {
1106 elements.push(elem);
1107 }
1102 } 1108 }
1103 if (this.currentStateMap.randomiseOrder) 1109 if (this.currentStateMap.randomiseOrder)
1104 { 1110 {
1105 this.currentStateMap.audioElements = randomiseOrder(elements); 1111 elements = randomiseOrder(elements);
1106 } 1112 }
1107 if (ref != null) 1113 this.currentStateMap.audioElements = elements.concat(ref);
1108 { 1114
1109 this.currentStateMap.audioElements.push(ref);
1110 }
1111 this.currentStore = storage.testPages[this.stateIndex]; 1115 this.currentStore = storage.testPages[this.stateIndex];
1112 if (this.currentStateMap.preTest != null) 1116 if (this.currentStateMap.preTest != null)
1113 { 1117 {
1114 this.currentStatePosition = 'pre'; 1118 this.currentStatePosition = 'pre';
1115 popup.initState(this.currentStateMap.preTest,storage.testPages[this.stateIndex].preTest); 1119 popup.initState(this.currentStateMap.preTest,storage.testPages[this.stateIndex].preTest);