changeset 2378:737e3f18e32b

#90 Specification.js follows strict js.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Fri, 20 May 2016 10:15:07 +0100
parents e04f0f8b6f8f
children 1e7d98ca83be
files js/specification.js
diffstat 1 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/js/specification.js	Fri May 20 09:51:35 2016 +0100
+++ b/js/specification.js	Fri May 20 10:15:07 2016 +0100
@@ -1,15 +1,25 @@
 function Specification() {
 	// Handles the decoding of the project specification XML into a simple JavaScript Object.
 	
+    // <setup> attributes
 	this.interface = null;
 	this.projectReturn = null;
     this.returnURL = null;
 	this.randomiseOrder = null;
-	this.testPages = null;
+	this.poolSize = null;
+    this.loudness = null;
+    this.sampleRate = null;
+    this.calibration = null;
+    this.crossFade = null;
+    this.preSilence = null;
+    this.postSilence = null;
+    
+    // nodes
+    this.metrics = null;
+    this.preTest = undefined;
+    this.postTest = undefined;
 	this.pages = [];
-	this.metrics = null;
 	this.interfaces = null;
-	this.loudness = null;
 	this.errors = [];
 	this.schema = null;
     this.exitText = "Thank you.";
@@ -75,9 +85,8 @@
 		var schemaSetup = this.schema.getAllElementsByName('setup')[0];
 		// First decode the attributes
 		var attributes = schemaSetup.getAllElementsByTagName('xs:attribute');
-		for (var i in attributes)
+		for (var i=0; i<attributes.length; i++)
 		{
-			if (isNaN(Number(i)) == true){break;}
 			var attributeName = attributes[i].getAttribute('name') || attributes[i].getAttribute('ref');
 			var projectAttr = setupNode.getAttribute(attributeName);
 			projectAttr = this.processAttribute(projectAttr,attributes[i],this.schema);
@@ -105,8 +114,7 @@
 		
 		// Now process the survey node options
 		var survey = setupNode.getElementsByTagName('survey');
-		for (var i in survey) {
-			if (isNaN(Number(i)) == true){break;}
+		for (var i=0; i<survey.length; i++){
 			var location = survey[i].getAttribute('location');
             switch(location)
             {
@@ -488,8 +496,7 @@
 			// Now process the survey node options
 			var survey = xml.getElementsByTagName('survey');
 			var surveySchema = parent.schema.getAllElementsByName('survey')[0];
-			for (var i in survey) {
-				if (isNaN(Number(i)) == true){break;}
+			for (var i=0; i<survey.length; i++){
 				var location = survey[i].getAttribute('location');
 				if (location == 'pre' || location == 'before')
 				{