changeset 2257:fba85e745b0e

Potential fix for erroneus. Included empty node detection
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 19 Apr 2016 17:54:14 +0100
parents 2424a77a7c56
children 90fd43dee199
files js/specification.js
diffstat 1 files changed, 23 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/js/specification.js	Tue Apr 19 18:09:30 2016 +0200
+++ b/js/specification.js	Tue Apr 19 17:54:14 2016 +0100
@@ -107,20 +107,25 @@
 		for (var i in survey) {
 			if (isNaN(Number(i)) == true){break;}
 			var location = survey[i].getAttribute('location');
-			if (location == 'pre' || location == 'before')
-			{
-				if (this.preTest != null){this.errors.push("Already a pre/before test survey defined! Ignoring second!!");}
-				else {
-					this.preTest = new this.surveyNode(this);
-					this.preTest.decode(this,survey[i]);
-				}
-			} else if (location == 'post' || location == 'after') {
-				if (this.postTest != null){this.errors.push("Already a post/after test survey defined! Ignoring second!!");}
-				else {
-					this.postTest = new this.surveyNode(this);
-					this.postTest.decode(this,survey[i]);
-				}
-			}
+            switch(location)
+            {
+                case 'pre':
+                case 'before':
+                    if (this.preTest != null){console.log("Already a pre/before test survey defined! Ignoring second!!");}
+                    else {
+                        this.preTest = new this.surveyNode(this);
+                        this.preTest.decode(this,survey[i]);
+                    }
+                    break;
+                case 'post':
+                case 'after':
+                    if (this.postTest != null){console.log("Already a post/after test survey defined! Ignoring second!!");}
+                    else {
+                        this.postTest = new this.surveyNode(this);
+                        this.postTest.decode(this,survey[i]);
+                    }
+                    break;
+            }
 		}
 		
 		var interfaceNode = setupNode.getElementsByTagName('interface');
@@ -294,6 +299,10 @@
 				node.decode(parent,xml.children[i]);
 				this.options.push(node);
 			}
+            if (this.options.length == 0) {
+                console.log("Empty survey node");
+                console.log(this);
+            }
 		};
 		this.encode = function(doc) {
 			var node = doc.createElement('survey');