# HG changeset patch # User Nicholas Jillings # Date 1433424683 -3600 # Node ID f938025db0d7d37a9b628d0a4d57ccc820a5fc14 # Parent 68bc26353ada96128a3ca2432d6a534611b8b703 Created Specification object to handle All XML decoding. diff -r 68bc26353ada -r f938025db0d7 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