# HG changeset patch # User Nicholas Jillings # Date 1433424683 -3600 # Node ID b6c808cac38c62fbfa034e8ef88979ccc174cfa8 # Parent 4ffbccf448c23f4643f7d7bf323544af346c5ea6 Created Specification object to handle All XML decoding. diff -r 4ffbccf448c2 -r b6c808cac38c core.js --- a/core.js Thu Jun 04 11:21:47 2015 +0100 +++ b/core.js Thu Jun 04 14:31:23 2015 +0100 @@ -321,8 +321,11 @@ function loadProjectSpecCallback(response) { // Function called after asynchronous download of XML project specification - var decode = $.parseXML(response); - projectXML = $(decode); + //var decode = $.parseXML(response); + //projectXML = $(decode); + + var parse = new DOMParser(); + projectXML = parse.parseFromString(response,'text/xml'); // Now extract the setup tag var xmlSetup = projectXML.find('setup'); @@ -973,3 +976,152 @@ } var testWaitTimerIntervalHolder = null; + +function Specification() { + // Handles the decoding of the project specification XML into a simple JavaScript Object. + + this.interfaceType; + this.projectReturn; + this.randomiseOrder; + this.collectMetrics; + this.preTest; + this.postTest; + this.metrics =[]; + + this.audioHolders = []; + + this.decode = function() { + // projectXML - DOM Parsed document + var setupNode = projectXML.getElementsByTagName('setup')[0]; + this.interfaceType = setupNode.getAttribute('interface'); + this.projectReturn = setupNode.getAttribute('projectReturn'); + if (setupNode.getAttribute('randomiseOrder') == "true") { + this.randomiseOrder = true; + } else {this.setup.randomiseOrder = false;} + if (setupNode.getAttribute('collectMetrics') == "true") { + this.collectMetrics = true; + } else {this.setup.collectMetrics = false;} + var metricCollection = setupNode.getElementsByTagName('Metric'); + + this.preTest = new this.prepostNode('pre',setupNode.getElementsByTagName('PreTest')); + this.postTest = new this.prepostNode('post',setupNode.getElementsByTagName('PostTest')); + + if (metricCollection.length > 0) { + metricCollection = metricCollection[0].getElementsByTagName('metricEnable'); + for (var i=0; i