annotate test_create/test_create.html @ 1254:6dbb9c24d53e

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