# HG changeset patch # User www-data # Date 1464276056 -3600 # Node ID e7601d5ff17bce4112c3db4d52dff3cfa4f7ac19 # Parent a51a6d810bf490776f008705144dbfb2c7c798cc# Parent 5d7ad658c69950cf2941f4072bf5f007ef6e8c47 Merge branch 'master' of https://github.com/BrechtDeMan/WebAudioEvaluationTool diff -r a51a6d810bf4 -r e7601d5ff17b js/core.js --- a/js/core.js Thu May 26 15:20:55 2016 +0100 +++ b/js/core.js Thu May 26 16:20:56 2016 +0100 @@ -1095,19 +1095,23 @@ { this.currentStateMap = this.stateMap[this.stateIndex]; // Find and extract the outside reference - var elements = [], ref = null; - for (var elem of this.currentStateMap.audioElements) { - if (elem.type == "outside-reference") {ref = elem;} - else {elements.push(elem);} + var elements = [], ref = []; + var elem; + while(elem = this.currentStateMap.audioElements.pop()) + { + if (elem.type == "outside-reference") { + ref.push(elem); + } + else { + elements.push(elem); + } } if (this.currentStateMap.randomiseOrder) { - this.currentStateMap.audioElements = randomiseOrder(elements); + elements = randomiseOrder(elements); } - if (ref != null) - { - this.currentStateMap.audioElements.push(ref); - } + this.currentStateMap.audioElements = elements.concat(ref); + this.currentStore = storage.testPages[this.stateIndex]; if (this.currentStateMap.preTest != null) {