Mercurial > hg > webaudioevaluationtool
comparison test_create/test_create.html @ 1284:6c819878ac85
Major updates. Specification Nodes now own file (specification.js). Updating Analysis to allow filtering based on survey responses.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Thu, 31 Mar 2016 13:31:42 +0100 |
parents | 2dd5f7071e3f |
children |
comparison
equal
deleted
inserted
replaced
1283:b24d861c96b3 | 1284:6c819878ac85 |
---|---|
4 <link rel='stylesheet' type="text/css" href="style.css"/> | 4 <link rel='stylesheet' type="text/css" href="style.css"/> |
5 <link rel='stylesheet' type="text/css" href="custom.css"/> | 5 <link rel='stylesheet' type="text/css" href="custom.css"/> |
6 <script type="text/javascript"> | 6 <script type="text/javascript"> |
7 window.onbeforeunload = function (e) {var message = 'If you leave the page now, any unsaved changes will be lost', e = e || window.event; if (e) { e.returnValue = message;}return message;}; | 7 window.onbeforeunload = function (e) {var message = 'If you leave the page now, any unsaved changes will be lost', e = e || window.event; if (e) { e.returnValue = message;}return message;}; |
8 // Copy of Specifiation node from Core.js | 8 // Copy of Specifiation node from Core.js |
9 function Specification() { | |
10 // Handles the decoding of the project specification XML into a simple JavaScript Object. | |
11 | |
12 this.interface = null; | |
13 this.projectReturn = "null"; | |
14 this.randomiseOrder = null; | |
15 this.testPages = null; | |
16 this.pages = []; | |
17 this.metrics = null; | |
18 this.interfaces = null; | |
19 this.loudness = null; | |
20 this.errors = []; | |
21 this.schema = null; | |
22 this.exitText = "Thank you."; | |
23 | |
24 this.processAttribute = function(attribute,schema,schemaRoot) | |
25 { | |
26 // attribute is the string returned from getAttribute on the XML | |
27 // schema is the <xs:attribute> node | |
28 if (schema.getAttribute('name') == undefined && schema.getAttribute('ref') != undefined) | |
29 { | |
30 schema = schemaRoot.getAllElementsByName(schema.getAttribute('ref'))[0]; | |
31 } | |
32 var defaultOpt = schema.getAttribute('default'); | |
33 if (attribute == null) { | |
34 attribute = defaultOpt; | |
35 } | |
36 var dataType = schema.getAttribute('type'); | |
37 if (typeof dataType == "string") { dataType = dataType.substr(3);} | |
38 else {dataType = "string";} | |
39 if (attribute == null) | |
40 { | |
41 return attribute; | |
42 } | |
43 switch(dataType) | |
44 { | |
45 case "boolean": | |
46 if (attribute == 'true'){attribute = true;}else{attribute=false;} | |
47 break; | |
48 case "negativeInteger": | |
49 case "positiveInteger": | |
50 case "nonNegativeInteger": | |
51 case "nonPositiveInteger": | |
52 case "integer": | |
53 case "decimal": | |
54 case "short": | |
55 attribute = Number(attribute); | |
56 break; | |
57 case "string": | |
58 default: | |
59 attribute = String(attribute); | |
60 break; | |
61 } | |
62 return attribute; | |
63 }; | |
64 | |
65 this.decode = function(projectXML) { | |
66 this.errors = []; | |
67 // projectXML - DOM Parsed document | |
68 this.projectXML = projectXML.childNodes[0]; | |
69 var setupNode = projectXML.getElementsByTagName('setup')[0]; | |
70 var schemaSetup = this.schema.getAllElementsByName('setup')[0]; | |
71 // First decode the attributes | |
72 var attributes = schemaSetup.getAllElementsByTagName('xs:attribute'); | |
73 for (var i in attributes) | |
74 { | |
75 if (isNaN(Number(i)) == true){break;} | |
76 var attributeName = attributes[i].getAttribute('name') || attributes[i].getAttribute('ref'); | |
77 var projectAttr = setupNode.getAttribute(attributeName); | |
78 projectAttr = this.processAttribute(projectAttr,attributes[i],this.schema); | |
79 switch(typeof projectAttr) | |
80 { | |
81 case "number": | |
82 case "boolean": | |
83 eval('this.'+attributeName+' = '+projectAttr); | |
84 break; | |
85 case "string": | |
86 eval('this.'+attributeName+' = "'+projectAttr+'"'); | |
87 break; | |
88 } | |
89 | |
90 } | |
91 | |
92 var exitTextNode = setupNode.getElementsByTagName('exitText'); | |
93 if (exitTextNode.length == 1) { | |
94 this.exitText = exitTextNode[0].textContent; | |
95 } | |
96 | |
97 this.metrics = new this.metricNode(); | |
98 | |
99 this.metrics.decode(this,setupNode.getElementsByTagName('metric')[0]); | |
100 | |
101 // Now process the survey node options | |
102 var survey = setupNode.getElementsByTagName('survey'); | |
103 for (var i in survey) { | |
104 if (isNaN(Number(i)) == true){break;} | |
105 var location = survey[i].getAttribute('location'); | |
106 if (location == 'pre' || location == 'before') | |
107 { | |
108 if (this.preTest != null){this.errors.push("Already a pre/before test survey defined! Ignoring second!!");} | |
109 else { | |
110 this.preTest = new this.surveyNode(); | |
111 this.preTest.decode(this,survey[i]); | |
112 } | |
113 } else if (location == 'post' || location == 'after') { | |
114 if (this.postTest != null){this.errors.push("Already a post/after test survey defined! Ignoring second!!");} | |
115 else { | |
116 this.postTest = new this.surveyNode(); | |
117 this.postTest.decode(this,survey[i]); | |
118 } | |
119 } | |
120 } | |
121 | |
122 var interfaceNode = setupNode.getElementsByTagName('interface'); | |
123 if (interfaceNode.length > 1) | |
124 { | |
125 this.errors.push("Only one <interface> node in the <setup> node allowed! Others except first ingnored!"); | |
126 } | |
127 this.interfaces = new this.interfaceNode(); | |
128 if (interfaceNode.length != 0) | |
129 { | |
130 interfaceNode = interfaceNode[0]; | |
131 this.interfaces.decode(this,interfaceNode,this.schema.getAllElementsByName('interface')[1]); | |
132 } | |
133 | |
134 // Page tags | |
135 var pageTags = projectXML.getElementsByTagName('page'); | |
136 var pageSchema = this.schema.getAllElementsByName('page')[0]; | |
137 for (var i=0; i<pageTags.length; i++) | |
138 { | |
139 var node = new this.page(); | |
140 node.decode(this,pageTags[i],pageSchema); | |
141 this.pages.push(node); | |
142 } | |
143 }; | |
144 | |
145 this.encode = function() | |
146 { | |
147 var RootDocument = document.implementation.createDocument(null,"waet"); | |
148 var root = RootDocument.children[0]; | |
149 root.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"); | |
150 root.setAttribute("xsi:noNamespaceSchemaLocation","test-schema.xsd"); | |
151 // Build setup node | |
152 var setup = RootDocument.createElement("setup"); | |
153 var schemaSetup = this.schema.getAllElementsByName('setup')[0]; | |
154 // First decode the attributes | |
155 var attributes = schemaSetup.getAllElementsByTagName('xs:attribute'); | |
156 for (var i=0; i<attributes.length; i++) | |
157 { | |
158 var name = attributes[i].getAttribute("name"); | |
159 if (name == undefined) { | |
160 name = attributes[i].getAttribute("ref"); | |
161 } | |
162 if(eval("this."+name+" != undefined") || attributes[i].getAttribute("use") == "required") | |
163 { | |
164 eval("setup.setAttribute('"+name+"',this."+name+")"); | |
165 } | |
166 } | |
167 root.appendChild(setup); | |
168 // Survey node | |
169 if (this.exitText != null) { | |
170 var exitTextNode = RootDocument.createElement('exitText'); | |
171 exitTextNode.textContent = this.exitText; | |
172 setup.appendChild(exitTextNode); | |
173 } | |
174 setup.appendChild(this.preTest.encode(RootDocument)); | |
175 setup.appendChild(this.postTest.encode(RootDocument)); | |
176 setup.appendChild(this.metrics.encode(RootDocument)); | |
177 setup.appendChild(this.interfaces.encode(RootDocument)); | |
178 for (var page of this.pages) | |
179 { | |
180 root.appendChild(page.encode(RootDocument)); | |
181 } | |
182 return RootDocument; | |
183 }; | |
184 | |
185 this.surveyNode = function() { | |
186 this.location = null; | |
187 this.options = []; | |
188 this.parent = null; | |
189 this.schema = specification.schema.getAllElementsByName('survey')[0]; | |
190 | |
191 this.OptionNode = function() { | |
192 this.type = undefined; | |
193 this.schema = specification.schema.getAllElementsByName('surveyentry')[0]; | |
194 this.id = undefined; | |
195 this.name = undefined; | |
196 this.mandatory = undefined; | |
197 this.statement = undefined; | |
198 this.boxsize = undefined; | |
199 this.options = []; | |
200 this.min = undefined; | |
201 this.max = undefined; | |
202 this.step = undefined; | |
203 | |
204 this.decode = function(parent,child) | |
205 { | |
206 var attributeMap = this.schema.getAllElementsByTagName('xs:attribute'); | |
207 for (var i in attributeMap){ | |
208 if(isNaN(Number(i)) == true){break;} | |
209 var attributeName = attributeMap[i].getAttribute('name') || attributeMap[i].getAttribute('ref'); | |
210 var projectAttr = child.getAttribute(attributeName); | |
211 projectAttr = parent.processAttribute(projectAttr,attributeMap[i],parent.schema); | |
212 switch(typeof projectAttr) | |
213 { | |
214 case "number": | |
215 case "boolean": | |
216 eval('this.'+attributeName+' = '+projectAttr); | |
217 break; | |
218 case "string": | |
219 eval('this.'+attributeName+' = "'+projectAttr+'"'); | |
220 break; | |
221 } | |
222 } | |
223 this.statement = child.getElementsByTagName('statement')[0].textContent; | |
224 if (this.type == "checkbox" || this.type == "radio") { | |
225 var children = child.getElementsByTagName('option'); | |
226 if (children.length == null) { | |
227 console.log('Malformed' +child.nodeName+ 'entry'); | |
228 this.statement = 'Malformed' +child.nodeName+ 'entry'; | |
229 this.type = 'statement'; | |
230 } else { | |
231 this.options = []; | |
232 for (var i in children) | |
233 { | |
234 if (isNaN(Number(i))==true){break;} | |
235 this.options.push({ | |
236 name: children[i].getAttribute('name'), | |
237 text: children[i].textContent | |
238 }); | |
239 } | |
240 } | |
241 } | |
242 }; | |
243 | |
244 this.exportXML = function(doc) | |
245 { | |
246 var node = doc.createElement('surveyentry'); | |
247 node.setAttribute('type',this.type); | |
248 var statement = doc.createElement('statement'); | |
249 statement.textContent = this.statement; | |
250 node.appendChild(statement); | |
251 node.id = this.id; | |
252 if (this.name != undefined) { node.setAttribute("name",this.name);} | |
253 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);} | |
254 node.id = this.id; | |
255 if (this.name != undefined) {node.setAttribute("name",this.name);} | |
256 switch(this.type) | |
257 { | |
258 case "checkbox": | |
259 case "radio": | |
260 for (var i=0; i<this.options.length; i++) | |
261 { | |
262 var option = this.options[i]; | |
263 var optionNode = doc.createElement("option"); | |
264 optionNode.setAttribute("name",option.name); | |
265 optionNode.textContent = option.text; | |
266 node.appendChild(optionNode); | |
267 } | |
268 case "number": | |
269 if (this.min != undefined) {node.setAttribute("min", this.min);} | |
270 if (this.max != undefined) {node.setAttribute("max", this.max);} | |
271 case "question": | |
272 if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);} | |
273 if (this.mandatory != undefined) {node.setAttribute("mandatory",this.mandatory);} | |
274 default: | |
275 break; | |
276 } | |
277 return node; | |
278 }; | |
279 }; | |
280 this.decode = function(parent,xml) { | |
281 this.parent = parent; | |
282 this.location = xml.getAttribute('location'); | |
283 if (this.location == 'before'){this.location = 'pre';} | |
284 else if (this.location == 'after'){this.location = 'post';} | |
285 for (var i in xml.children) | |
286 { | |
287 if(isNaN(Number(i))==true){break;} | |
288 var node = new this.OptionNode(); | |
289 node.decode(parent,xml.children[i]); | |
290 this.options.push(node); | |
291 } | |
292 }; | |
293 this.encode = function(doc) { | |
294 var node = doc.createElement('survey'); | |
295 node.setAttribute('location',this.location); | |
296 for (var i=0; i<this.options.length; i++) | |
297 { | |
298 node.appendChild(this.options[i].exportXML(doc)); | |
299 } | |
300 return node; | |
301 }; | |
302 }; | |
303 | |
304 this.interfaceNode = function() | |
305 { | |
306 this.title = null; | |
307 this.name = null; | |
308 this.options = []; | |
309 this.scales = []; | |
310 this.schema = specification.schema.getAllElementsByName('interface')[1]; | |
311 | |
312 this.decode = function(parent,xml) { | |
313 this.name = xml.getAttribute('name'); | |
314 var titleNode = xml.getElementsByTagName('title'); | |
315 if (titleNode.length == 1) | |
316 { | |
317 this.title = titleNode[0].textContent; | |
318 } | |
319 var interfaceOptionNodes = xml.getElementsByTagName('interfaceoption'); | |
320 // Extract interfaceoption node schema | |
321 var interfaceOptionNodeSchema = this.schema.getAllElementsByName('interfaceoption')[0]; | |
322 var attributeMap = interfaceOptionNodeSchema.getAllElementsByTagName('xs:attribute'); | |
323 for (var i=0; i<interfaceOptionNodes.length; i++) | |
324 { | |
325 var ioNode = interfaceOptionNodes[i]; | |
326 var option = {}; | |
327 for (var j=0; j<attributeMap.length; j++) | |
328 { | |
329 var attributeName = attributeMap[j].getAttribute('name') || attributeMap[j].getAttribute('ref'); | |
330 var projectAttr = ioNode.getAttribute(attributeName); | |
331 if(parent.processAttribute) { | |
332 parent.processAttribute(projectAttr, attributeMap[j], parent.schema) | |
333 } else { | |
334 parent.parent.processAttribute(projectAttr, attributeMap[j], parent.parent.schema) | |
335 } | |
336 switch(typeof projectAttr) | |
337 { | |
338 case "number": | |
339 case "boolean": | |
340 eval('option.'+attributeName+' = '+projectAttr); | |
341 break; | |
342 case "string": | |
343 eval('option.'+attributeName+' = "'+projectAttr+'"'); | |
344 break; | |
345 } | |
346 } | |
347 this.options.push(option); | |
348 } | |
349 | |
350 // Now the scales nodes | |
351 var scaleParent = xml.getElementsByTagName('scales'); | |
352 if (scaleParent.length == 1) { | |
353 scaleParent = scaleParent[0]; | |
354 for (var i=0; i<scaleParent.children.length; i++) { | |
355 var child = scaleParent.children[i]; | |
356 this.scales.push({ | |
357 text: child.textContent, | |
358 position: Number(child.getAttribute('position')) | |
359 }); | |
360 } | |
361 } | |
362 }; | |
363 | |
364 this.encode = function(doc) { | |
365 var node = doc.createElement("interface"); | |
366 if (typeof name == "string") | |
367 node.setAttribute("name",this.name); | |
368 for (var option of this.options) | |
369 { | |
370 var child = doc.createElement("interfaceoption"); | |
371 child.setAttribute("type",option.type); | |
372 child.setAttribute("name",option.name); | |
373 node.appendChild(child); | |
374 } | |
375 if (this.scales.length != 0) { | |
376 var scales = doc.createElement("scales"); | |
377 for (var scale of this.scales) | |
378 { | |
379 var child = doc.createElement("scalelabel"); | |
380 child.setAttribute("position",scale.position); | |
381 child.textContent = scale.text; | |
382 scales.appendChild(child); | |
383 } | |
384 node.appendChild(scales); | |
385 } | |
386 return node; | |
387 }; | |
388 }; | |
389 | |
390 this.metricNode = function() { | |
391 this.enabled = []; | |
392 this.decode = function(parent, xml) { | |
393 var children = xml.getElementsByTagName('metricenable'); | |
394 for (var i in children) { | |
395 if (isNaN(Number(i)) == true){break;} | |
396 this.enabled.push(children[i].textContent); | |
397 } | |
398 } | |
399 this.encode = function(doc) { | |
400 var node = doc.createElement('metric'); | |
401 for (var i in this.enabled) | |
402 { | |
403 if (isNaN(Number(i)) == true){break;} | |
404 var child = doc.createElement('metricenable'); | |
405 child.textContent = this.enabled[i]; | |
406 node.appendChild(child); | |
407 } | |
408 return node; | |
409 } | |
410 } | |
411 | |
412 this.page = function() { | |
413 this.presentedId = undefined; | |
414 this.id = undefined; | |
415 this.hostURL = undefined; | |
416 this.randomiseOrder = undefined; | |
417 this.loop = undefined; | |
418 this.showElementComments = undefined; | |
419 this.outsideReference = null; | |
420 this.loudness = null; | |
421 this.label = null; | |
422 this.preTest = null; | |
423 this.postTest = null; | |
424 this.interfaces = []; | |
425 this.commentBoxPrefix = "Comment on track"; | |
426 this.audioElements = []; | |
427 this.commentQuestions = []; | |
428 this.schema = specification.schema.getAllElementsByName("page")[0]; | |
429 this.parent = null; | |
430 | |
431 this.decode = function(parent,xml) | |
432 { | |
433 this.parent = parent; | |
434 var attributeMap = this.schema.getAllElementsByTagName('xs:attribute'); | |
435 for (var i=0; i<attributeMap.length; i++) | |
436 { | |
437 var attributeName = attributeMap[i].getAttribute('name') || attributeMap[i].getAttribute('ref'); | |
438 var projectAttr = xml.getAttribute(attributeName); | |
439 projectAttr = parent.processAttribute(projectAttr,attributeMap[i],parent.schema); | |
440 switch(typeof projectAttr) | |
441 { | |
442 case "number": | |
443 case "boolean": | |
444 eval('this.'+attributeName+' = '+projectAttr); | |
445 break; | |
446 case "string": | |
447 eval('this.'+attributeName+' = "'+projectAttr+'"'); | |
448 break; | |
449 } | |
450 } | |
451 | |
452 // Get the Comment Box Prefix | |
453 var CBP = xml.getElementsByTagName('commentboxprefix'); | |
454 if (CBP.length != 0) { | |
455 this.commentBoxPrefix = CBP[0].textContent; | |
456 } | |
457 | |
458 // Now decode the interfaces | |
459 var interfaceNode = xml.getElementsByTagName('interface'); | |
460 for (var i=0; i<interfaceNode.length; i++) | |
461 { | |
462 var node = new parent.interfaceNode(); | |
463 node.decode(this,interfaceNode[i],parent.schema.getAllElementsByName('interface')[1]); | |
464 this.interfaces.push(node); | |
465 } | |
466 | |
467 // Now process the survey node options | |
468 var survey = xml.getElementsByTagName('survey'); | |
469 var surveySchema = parent.schema.getAllElementsByName('survey')[0]; | |
470 for (var i in survey) { | |
471 if (isNaN(Number(i)) == true){break;} | |
472 var location = survey[i].getAttribute('location'); | |
473 if (location == 'pre' || location == 'before') | |
474 { | |
475 if (this.preTest != null){this.errors.push("Already a pre/before test survey defined! Ignoring second!!");} | |
476 else { | |
477 this.preTest = new parent.surveyNode(); | |
478 this.preTest.decode(parent,survey[i],surveySchema); | |
479 } | |
480 } else if (location == 'post' || location == 'after') { | |
481 if (this.postTest != null){this.errors.push("Already a post/after test survey defined! Ignoring second!!");} | |
482 else { | |
483 this.postTest = new parent.surveyNode(); | |
484 this.postTest.decode(parent,survey[i],surveySchema); | |
485 } | |
486 } | |
487 } | |
488 | |
489 // Now process the audioelement tags | |
490 var audioElements = xml.getElementsByTagName('audioelement'); | |
491 for (var i=0; i<audioElements.length; i++) | |
492 { | |
493 var node = new this.audioElementNode(); | |
494 node.decode(this,audioElements[i]); | |
495 this.audioElements.push(node); | |
496 } | |
497 | |
498 // Now decode the commentquestions | |
499 var commentQuestions = xml.getElementsByTagName('commentquestion'); | |
500 for (var i=0; i<commentQuestions.length; i++) | |
501 { | |
502 var node = new this.commentQuestionNode(); | |
503 node.decode(parent,commentQuestions[i]); | |
504 this.commentQuestions.push(node); | |
505 } | |
506 }; | |
507 | |
508 this.encode = function(root) | |
509 { | |
510 var AHNode = root.createElement("page"); | |
511 // First decode the attributes | |
512 var attributes = this.schema.getAllElementsByTagName('xs:attribute'); | |
513 for (var i=0; i<attributes.length; i++) | |
514 { | |
515 var name = attributes[i].getAttribute("name"); | |
516 if (name == undefined) { | |
517 name = attributes[i].getAttribute("ref"); | |
518 } | |
519 if(eval("this."+name+" != undefined") || attributes[i].getAttribute("use") == "required") | |
520 { | |
521 eval("AHNode.setAttribute('"+name+"',this."+name+")"); | |
522 } | |
523 } | |
524 if(this.loudness != null) {AHNode.setAttribute("loudness",this.loudness);} | |
525 // <commentboxprefix> | |
526 var commentboxprefix = root.createElement("commentboxprefix"); | |
527 commentboxprefix.textContent = this.commentBoxPrefix; | |
528 AHNode.appendChild(commentboxprefix); | |
529 | |
530 for (var i=0; i<this.interfaces.length; i++) | |
531 { | |
532 AHNode.appendChild(this.interfaces[i].encode(root)); | |
533 } | |
534 | |
535 for (var i=0; i<this.audioElements.length; i++) { | |
536 AHNode.appendChild(this.audioElements[i].encode(root)); | |
537 } | |
538 // Create <CommentQuestion> | |
539 for (var i=0; i<this.commentQuestions.length; i++) | |
540 { | |
541 AHNode.appendChild(this.commentQuestions[i].encode(root)); | |
542 } | |
543 | |
544 AHNode.appendChild(this.preTest.encode(root)); | |
545 AHNode.appendChild(this.postTest.encode(root)); | |
546 return AHNode; | |
547 }; | |
548 | |
549 this.commentQuestionNode = function() { | |
550 this.id = null; | |
551 this.name = undefined; | |
552 this.type = undefined; | |
553 this.options = []; | |
554 this.statement = undefined; | |
555 this.schema = specification.schema.getAllElementsByName('commentquestion')[0]; | |
556 this.decode = function(parent,xml) | |
557 { | |
558 this.id = xml.id; | |
559 this.name = xml.getAttribute('name'); | |
560 this.type = xml.getAttribute('type'); | |
561 this.statement = xml.getElementsByTagName('statement')[0].textContent; | |
562 var optNodes = xml.getElementsByTagName('option'); | |
563 for (var i=0; i<optNodes.length; i++) | |
564 { | |
565 var optNode = optNodes[i]; | |
566 this.options.push({ | |
567 name: optNode.getAttribute('name'), | |
568 text: optNode.textContent | |
569 }); | |
570 } | |
571 }; | |
572 | |
573 this.encode = function(root) | |
574 { | |
575 var node = root.createElement("commentquestion"); | |
576 node.id = this.id; | |
577 node.setAttribute("type",this.type); | |
578 if (this.name != undefined){node.setAttribute("name",this.name);} | |
579 var statement = root.createElement("statement"); | |
580 statement.textContent = this.statement; | |
581 node.appendChild(statement); | |
582 for (var option of this.options) | |
583 { | |
584 var child = root.createElement("option"); | |
585 child.setAttribute("name",option.name); | |
586 child.textContent = option.text; | |
587 node.appendChild(child); | |
588 } | |
589 return node; | |
590 }; | |
591 }; | |
592 | |
593 this.audioElementNode = function() { | |
594 this.url = null; | |
595 this.id = null; | |
596 this.name = null; | |
597 this.parent = null; | |
598 this.type = null; | |
599 this.marker = null; | |
600 this.enforce = false; | |
601 this.gain = 0.0; | |
602 this.schema = specification.schema.getAllElementsByName('audioelement')[0];; | |
603 this.parent = null; | |
604 this.decode = function(parent,xml) | |
605 { | |
606 this.parent = parent; | |
607 var attributeMap = this.schema.getAllElementsByTagName('xs:attribute'); | |
608 for (var i=0; i<attributeMap.length; i++) | |
609 { | |
610 var attributeName = attributeMap[i].getAttribute('name') || attributeMap[i].getAttribute('ref'); | |
611 var projectAttr = xml.getAttribute(attributeName); | |
612 projectAttr = parent.parent.processAttribute(projectAttr,attributeMap[i],parent.parent.schema); | |
613 switch(typeof projectAttr) | |
614 { | |
615 case "number": | |
616 case "boolean": | |
617 eval('this.'+attributeName+' = '+projectAttr); | |
618 break; | |
619 case "string": | |
620 eval('this.'+attributeName+' = "'+projectAttr+'"'); | |
621 break; | |
622 } | |
623 } | |
624 | |
625 }; | |
626 this.encode = function(root) | |
627 { | |
628 var AENode = root.createElement("audioelement"); | |
629 var attributes = this.schema.getAllElementsByTagName('xs:attribute'); | |
630 for (var i=0; i<attributes.length; i++) | |
631 { | |
632 var name = attributes[i].getAttribute("name"); | |
633 if (name == undefined) { | |
634 name = attributes[i].getAttribute("ref"); | |
635 } | |
636 if(eval("this."+name+" != undefined") || attributes[i].getAttribute("use") == "required") | |
637 { | |
638 eval("AENode.setAttribute('"+name+"',this."+name+")"); | |
639 } | |
640 } | |
641 return AENode; | |
642 }; | |
643 }; | |
644 }; | |
645 } | |
646 | |
647 </script> | 9 </script> |
648 <script src="../jquery-2.1.4.js"></script> | 10 <script src="../jquery-2.1.4.js"></script> |
649 <script type="text/javascript" src="test_core.js"/> | 11 <script type="text/javascript" src='../specification.js'></script> |
650 <script type="text/javascript"> | 12 <script type="text/javascript" src="test_core.js"></script> |
651 | |
652 </script> | |
653 </head> | 13 </head> |
654 <body> | 14 <body> |
655 <div id="popupHolder"></div> | 15 <div id="popupHolder"></div> |
656 <div id="blanket"></div> | 16 <div id="blanket"></div> |
657 <div id="content"></div> | 17 <div id="content"></div> |