changeset 2410:2f6a1f510ade

Merge branch 'master' into Dev_main
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 26 May 2016 16:07:00 +0100
parents f595f5f5a7b9 (current diff) 5d7ad658c699 (diff)
children c31f73252af5
files js/core.js js/specification.js
diffstat 2 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/js/core.js	Thu May 26 15:55:00 2016 +0100
+++ b/js/core.js	Thu May 26 16:07:00 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)
 				{
--- a/js/specification.js	Thu May 26 15:55:00 2016 +0100
+++ b/js/specification.js	Thu May 26 16:07:00 2016 +0100
@@ -163,7 +163,7 @@
 	this.encode = function()
 	{
 		var RootDocument = document.implementation.createDocument(null,"waet");
-		var root = RootDocument.children[0];
+		var root = RootDocument.firstChild;
         root.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
         root.setAttribute("xsi:noNamespaceSchemaLocation","test-schema.xsd");
 		// Build setup node