Mercurial > hg > webaudioevaluationtool
comparison js/specification.js @ 3100:998e05c5769a
#171 Completed specification changes
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Wed, 17 Jan 2018 12:30:28 +0000 |
parents | e441e3d5c7e7 |
children | d79b9939b19e |
comparison
equal
deleted
inserted
replaced
3099:fc9718756d55 | 3100:998e05c5769a |
---|---|
10 this.returnURL = undefined; | 10 this.returnURL = undefined; |
11 this.randomiseOrder = undefined; | 11 this.randomiseOrder = undefined; |
12 this.poolSize = undefined; | 12 this.poolSize = undefined; |
13 this.loudness = undefined; | 13 this.loudness = undefined; |
14 this.sampleRate = undefined; | 14 this.sampleRate = undefined; |
15 this.calibration = undefined; | |
16 this.crossFade = undefined; | 15 this.crossFade = undefined; |
17 this.preSilence = undefined; | 16 this.preSilence = undefined; |
18 this.postSilence = undefined; | 17 this.postSilence = undefined; |
19 this.playOne = undefined; | 18 this.playOne = undefined; |
20 this.minNumberPlays = undefined; | 19 this.minNumberPlays = undefined; |
129 var projectAttr = setupNode.getAttribute(attributeName); | 128 var projectAttr = setupNode.getAttribute(attributeName); |
130 projectAttr = processAttribute(projectAttr, attributes[i]); | 129 projectAttr = processAttribute(projectAttr, attributes[i]); |
131 if (projectAttr !== null) { | 130 if (projectAttr !== null) { |
132 this[attributeName] = projectAttr; | 131 this[attributeName] = projectAttr; |
133 } | 132 } |
134 | 133 } |
135 } | 134 |
135 this.calibration.decode(this, projectXML.getElementsByTagName('calibration')[0]); | |
136 | 136 |
137 var exitTextNode = setupNode.getElementsByTagName('exitText'); | 137 var exitTextNode = setupNode.getElementsByTagName('exitText'); |
138 if (exitTextNode.length == 1) { | 138 if (exitTextNode.length == 1) { |
139 this.exitText = exitTextNode[0].textContent; | 139 this.exitText = exitTextNode[0].textContent; |
140 } | 140 } |
207 if (this.exitText !== null) { | 207 if (this.exitText !== null) { |
208 var exitTextNode = RootDocument.createElement('exitText'); | 208 var exitTextNode = RootDocument.createElement('exitText'); |
209 exitTextNode.textContent = this.exitText; | 209 exitTextNode.textContent = this.exitText; |
210 setup.appendChild(exitTextNode); | 210 setup.appendChild(exitTextNode); |
211 } | 211 } |
212 setup.appendChild(this.calibration.encode(RootDocument)); | |
212 setup.appendChild(this.preTest.encode(RootDocument)); | 213 setup.appendChild(this.preTest.encode(RootDocument)); |
213 setup.appendChild(this.postTest.encode(RootDocument)); | 214 setup.appendChild(this.postTest.encode(RootDocument)); |
214 setup.appendChild(this.metrics.encode(RootDocument)); | 215 setup.appendChild(this.metrics.encode(RootDocument)); |
215 setup.appendChild(this.interfaces.encode(RootDocument)); | 216 setup.appendChild(this.interfaces.encode(RootDocument)); |
216 this.pages.forEach(function (page) { | 217 this.pages.forEach(function (page) { |
217 root.appendChild(page.encode(RootDocument)); | 218 root.appendChild(page.encode(RootDocument)); |
218 }); | 219 }); |
219 return RootDocument; | 220 return RootDocument; |
220 }; | 221 }; |
222 | |
223 this.calibration = (function () { | |
224 var frequencies = false, | |
225 levels = false, | |
226 channels = false, | |
227 schema = undefined; | |
228 var Calibration = {}; | |
229 Object.defineProperties(Calibration, { | |
230 "parent": { | |
231 "value": this | |
232 }, | |
233 "schema": { | |
234 "get": function () { | |
235 return schema; | |
236 }, | |
237 "set": function (t) { | |
238 if (schema === undefined) { | |
239 schema = t; | |
240 } else { | |
241 throw ("Cannot set readonly"); | |
242 } | |
243 } | |
244 }, | |
245 "checkFrequencies": { | |
246 "get": function () { | |
247 return frequencies; | |
248 }, | |
249 "set": function (t) { | |
250 frequencies = (t === true); | |
251 } | |
252 }, | |
253 "checkLevels": { | |
254 "get": function () { | |
255 return levels; | |
256 }, | |
257 "set": function (t) { | |
258 levels = (t === true); | |
259 } | |
260 }, | |
261 "checkChannels": { | |
262 "get": function () { | |
263 return channels; | |
264 }, | |
265 "set": function (t) { | |
266 channels = (t === true); | |
267 } | |
268 }, | |
269 "encode": { | |
270 "value": function (doc) { | |
271 var node = doc.createElement("calibration"); | |
272 node.setAttribute("checkFrequencies", frequencies); | |
273 node.setAttribute("checkLevels", levels); | |
274 node.setAttribute("checkChannels", channels); | |
275 return node; | |
276 } | |
277 }, | |
278 "decode": { | |
279 "value": function (parent, xml) { | |
280 this.schema = schemaRoot.querySelector("[name=calibration]"); | |
281 var attributeMap = this.schema.querySelectorAll('attribute'), | |
282 i; | |
283 for (i in attributeMap) { | |
284 if (isNaN(Number(i)) === true) { | |
285 break; | |
286 } | |
287 var attributeName = attributeMap[i].getAttribute('name') || attributeMap[i].getAttribute('ref'); | |
288 var projectAttr = xml.getAttribute(attributeName); | |
289 projectAttr = processAttribute(projectAttr, attributeMap[i]); | |
290 if (projectAttr !== null) { | |
291 this[attributeName] = projectAttr; | |
292 } | |
293 } | |
294 } | |
295 } | |
296 }); | |
297 return Calibration; | |
298 })(); | |
221 | 299 |
222 function surveyNode(specification) { | 300 function surveyNode(specification) { |
223 this.location = undefined; | 301 this.location = undefined; |
224 this.options = []; | 302 this.options = []; |
225 this.parent = undefined; | 303 this.parent = undefined; |