# HG changeset patch # User Nicholas Jillings # Date 1461084854 -3600 # Node ID fba85e745b0eadfa1b1f6d0cf59fcbb18e1a9c1b # Parent 2424a77a7c5680c7bf51728f3ab5e3c27131db06 Potential fix for erroneus. Included empty node detection diff -r 2424a77a7c56 -r fba85e745b0e js/specification.js --- 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');