annotate test_create/test_create.html @ 1105:d2afd2ee8684

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