Mercurial > hg > webaudioevaluationtool
comparison core.js @ 891:8c44e2d0d6c4
Feature #1271 and #1272 implemented.
author | Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk> |
---|---|
date | Wed, 17 Jun 2015 16:37:32 +0100 |
parents | 716cd1efe64c |
children | a049c6cf7eb3 |
comparison
equal
deleted
inserted
replaced
890:716cd1efe64c | 891:8c44e2d0d6c4 |
---|---|
890 | 890 |
891 this.exportXMLDOM = function() { | 891 this.exportXMLDOM = function() { |
892 var root = document.createElement('audioElement'); | 892 var root = document.createElement('audioElement'); |
893 root.id = this.specification.id; | 893 root.id = this.specification.id; |
894 root.setAttribute('url',this.url); | 894 root.setAttribute('url',this.url); |
895 root.appendChild(this.interfaceDOM.exportXMLDOM()); | 895 root.appendChild(this.interfaceDOM.exportXMLDOM(this)); |
896 root.appendChild(this.commentDOM.exportXMLDOM()); | 896 root.appendChild(this.commentDOM.exportXMLDOM(this)); |
897 root.appendChild(this.metric.exportXMLDOM()); | 897 root.appendChild(this.metric.exportXMLDOM()); |
898 return root; | 898 return root; |
899 }; | 899 }; |
900 } | 900 } |
901 | 901 |
1363 this.anchor = xml.getAttribute('anchor'); | 1363 this.anchor = xml.getAttribute('anchor'); |
1364 if (this.anchor == 'true') {this.anchor = true;} | 1364 if (this.anchor == 'true') {this.anchor = true;} |
1365 else {this.anchor = false;} | 1365 else {this.anchor = false;} |
1366 | 1366 |
1367 this.reference = xml.getAttribute('reference'); | 1367 this.reference = xml.getAttribute('reference'); |
1368 if (this.reference == 'true') {this.anchor = true;} | 1368 if (this.reference == 'true') {this.reference = true;} |
1369 else {this.reference = false;} | 1369 else {this.reference = false;} |
1370 | 1370 |
1371 if (this.anchor == true && this.reference == true) { | 1371 if (this.anchor == true && this.reference == true) { |
1372 console.log('ERROR - Cannot have one audioElement be both the reference and anchor!') | 1372 console.log('ERROR - Cannot have one audioElement be both the reference and anchor!'); |
1373 console.log(this); | 1373 console.log(this); |
1374 console.log('Neither will be enabled'); | 1374 console.log('Neither reference nor anchor will be enabled on this fragment'); |
1375 this.anchor = false; | 1375 this.anchor = false; |
1376 this.reference = false; | 1376 this.reference = false; |
1377 } | |
1378 if (this.anchor == true) { | |
1379 this.marker = anchor; | |
1380 } | |
1381 if (this.reference == true) { | |
1382 this.marker = reference; | |
1377 } | 1383 } |
1378 }; | 1384 }; |
1379 | 1385 |
1380 this.commentQuestionNode = function(xml) { | 1386 this.commentQuestionNode = function(xml) { |
1381 this.childOption = function(element) { | 1387 this.childOption = function(element) { |
1428 if (xml.getAttribute('loop') == 'true') {this.loop = true;} | 1434 if (xml.getAttribute('loop') == 'true') {this.loop = true;} |
1429 else {this.loop == false;} | 1435 else {this.loop == false;} |
1430 if (xml.getAttribute('elementComments') == "true") {this.elementComments = true;} | 1436 if (xml.getAttribute('elementComments') == "true") {this.elementComments = true;} |
1431 else {this.elementComments = false;} | 1437 else {this.elementComments = false;} |
1432 | 1438 |
1433 this.anchor = xml.getElementsByTagName('anchor'); | 1439 var anchor = xml.getElementsByTagName('anchor'); |
1434 if (this.anchor.length == 0) { | 1440 if (anchor.length == 0) { |
1435 // Find anchor in commonInterface; | 1441 // Find anchor in commonInterface; |
1436 for (var i=0; i<parent.commonInterface.options.length; i++) { | 1442 for (var i=0; i<parent.commonInterface.options.length; i++) { |
1437 if(parent.commonInterface.options[i].type == 'anchor') { | 1443 if(parent.commonInterface.options[i].type == 'anchor') { |
1438 this.anchor = parent.commonInterface.options[i].value; | 1444 anchor = parent.commonInterface.options[i].value; |
1439 break; | 1445 break; |
1440 } | 1446 } |
1441 } | 1447 } |
1442 if (typeof(this.anchor) == "object") { | 1448 if (typeof(anchor) == "object") { |
1443 this.reference = null; | 1449 anchor = null; |
1444 } | 1450 } |
1445 } else { | 1451 } else { |
1446 this.anchor = this.anchor[0].textContent; | 1452 anchor = anchor[0].textContent; |
1447 } | 1453 } |
1448 | 1454 |
1449 this.reference = xml.getElementsByTagName('reference'); | 1455 var reference = xml.getElementsByTagName('anchor'); |
1450 if (this.reference.length == 0) { | 1456 if (reference.length == 0) { |
1451 // Find anchor in commonInterface; | 1457 // Find anchor in commonInterface; |
1452 for (var i=0; i<parent.commonInterface.options.length; i++) { | 1458 for (var i=0; i<parent.commonInterface.options.length; i++) { |
1453 if(parent.commonInterface.options[i].type == 'reference') { | 1459 if(parent.commonInterface.options[i].type == 'reference') { |
1454 this.reference = parent.commonInterface.options[i].value; | 1460 reference = parent.commonInterface.options[i].value; |
1455 break; | 1461 break; |
1456 } | 1462 } |
1457 } | 1463 } |
1458 if (typeof(this.reference) == "object") { | 1464 if (typeof(reference) == "object") { |
1459 this.reference = null; | 1465 reference = null; |
1460 } | 1466 } |
1461 } else { | 1467 } else { |
1462 this.reference = this.reference[0].textContent; | 1468 reference = reference[0].textContent; |
1469 } | |
1470 | |
1471 if (typeof(anchor) == 'number') { | |
1472 if (anchor > 1 && anchor < 100) {anchor /= 100.0;} | |
1473 } | |
1474 | |
1475 if (typeof(reference) == 'number') { | |
1476 if (reference > 1 && reference < 100) {reference /= 100.0;} | |
1463 } | 1477 } |
1464 | 1478 |
1465 this.preTest = new parent.prepostNode('pretest',xml.getElementsByTagName('PreTest')); | 1479 this.preTest = new parent.prepostNode('pretest',xml.getElementsByTagName('PreTest')); |
1466 this.postTest = new parent.prepostNode('posttest',xml.getElementsByTagName('PostTest')); | 1480 this.postTest = new parent.prepostNode('posttest',xml.getElementsByTagName('PostTest')); |
1467 | 1481 |
1480 | 1494 |
1481 this.audioElements =[]; | 1495 this.audioElements =[]; |
1482 var audioElementsDOM = xml.getElementsByTagName('audioElements'); | 1496 var audioElementsDOM = xml.getElementsByTagName('audioElements'); |
1483 for (var i=0; i<audioElementsDOM.length; i++) { | 1497 for (var i=0; i<audioElementsDOM.length; i++) { |
1484 this.audioElements.push(new this.audioElementNode(this,audioElementsDOM[i])); | 1498 this.audioElements.push(new this.audioElementNode(this,audioElementsDOM[i])); |
1499 } | |
1500 | |
1501 // Check only one anchor and one reference per audioNode | |
1502 var anchor = []; | |
1503 var reference = []; | |
1504 for (var i=0; i<this.audioElements.length; i++) | |
1505 { | |
1506 if (this.audioElements[i].anchor == true) {anchor.push(i);} | |
1507 if (this.audioElements[i].reference == true) {reference.push(i);} | |
1508 } | |
1509 | |
1510 if (anchor.length > 1) { | |
1511 console.log('Error - cannot have more than one anchor!'); | |
1512 console.log('Each anchor node will be a normal mode to continue the test'); | |
1513 for (var i=0; i<anchor.length; i++) | |
1514 { | |
1515 this.audioElements[anchor[i]].anchor = false; | |
1516 this.audioElements[anchor[i]].value = undefined; | |
1517 } | |
1518 } | |
1519 if (reference.length > 1) { | |
1520 console.log('Error - cannot have more than one anchor!'); | |
1521 console.log('Each anchor node will be a normal mode to continue the test'); | |
1522 for (var i=0; i<reference.length; i++) | |
1523 { | |
1524 this.audioElements[reference[i]].reference = false; | |
1525 this.audioElements[reference[i]].value = undefined; | |
1526 } | |
1485 } | 1527 } |
1486 | 1528 |
1487 this.commentQuestions = []; | 1529 this.commentQuestions = []; |
1488 var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion'); | 1530 var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion'); |
1489 for (var i=0; i<commentQuestionsDOM.length; i++) { | 1531 for (var i=0; i<commentQuestionsDOM.length; i++) { |