comparison core.js @ 1455:36352403f473

<anchor> and <reference> tags depricated. All anchor/ref are directly applied as attributes on <audioElements>
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Fri, 09 Oct 2015 10:38:03 +0100
parents 04e8a9c07c7e
children 7b0ce3a9ddc1
comparison
equal deleted inserted replaced
1454:128832b9678b 1455:36352403f473
1374 } else { 1374 } else {
1375 this.max = Number(this.max); 1375 this.max = Number(this.max);
1376 } 1376 }
1377 } 1377 }
1378 } else if (this.type == 'anchor' || this.type == 'reference') { 1378 } else if (this.type == 'anchor' || this.type == 'reference') {
1379 this.value = Number(child.textContent); 1379 Console.log("WARNING: Anchor and Reference tags in the <interface> node are depricated");
1380 this.enforce = child.getAttribute('enforce');
1381 if (this.enforce == 'true') {this.enforce = true;}
1382 else {this.enforce = false;}
1383 } 1380 }
1384 }; 1381 };
1385 this.options = []; 1382 this.options = [];
1386 if (commonInterfaceNode != undefined) { 1383 if (commonInterfaceNode != undefined) {
1387 var child = commonInterfaceNode.firstElementChild; 1384 var child = commonInterfaceNode.firstElementChild;
1522 if (this.type == 'anchor') {this.anchor = true;} 1519 if (this.type == 'anchor') {this.anchor = true;}
1523 else {this.anchor = false;} 1520 else {this.anchor = false;}
1524 if (this.type == 'reference') {this.reference = true;} 1521 if (this.type == 'reference') {this.reference = true;}
1525 else {this.reference = false;} 1522 else {this.reference = false;}
1526 1523
1527 this.marker = xml.getAttribute('marker'); 1524 if (this.anchor == true || this.reference == true)
1528 if (this.marker == null) {this.marker = undefined;} 1525 {
1529 1526 this.marker = xml.getAttribute('marker');
1530 if (this.anchor == true) { 1527 if (this.marker != undefined)
1531 if (this.marker != undefined) {this.enforce = true;} 1528 {
1532 else {this.enforce = enforceAnchor;} 1529 this.marker = Number(this.marker);
1533 this.marker = anchor; 1530 if (isNaN(this.marker) == false)
1534 } 1531 {
1535 else if (this.reference == true) { 1532 if (this.marker > 1)
1536 if (this.marker != undefined) {this.enforce = true;} 1533 { this.marker /= 100.0;}
1537 else {this.enforce = enforceReference;} 1534 if (this.marker >= 0 && this.marker <= 1)
1538 this.marker = reference; 1535 {
1539 } 1536 this.enforce = true;
1540 1537 return;
1541 if (this.marker != undefined) { 1538 } else {
1542 this.marker = Number(this.marker); 1539 console.log("ERROR - Marker of audioElement "+this.id+" is not between 0 and 1 (float) or 0 and 100 (integer)!");
1543 if (this.marker > 1) {this.marker /= 100;} 1540 console.log("ERROR - Marker not enforced!");
1544 } 1541 }
1542 } else {
1543 console.log("ERROR - Marker of audioElement "+this.id+" is not a number!");
1544 console.log("ERROR - Marker not enforced!");
1545 }
1546 }
1547 }
1548 this.marker = false;
1549 this.enforce = false;
1545 }; 1550 };
1546 1551
1547 this.commentQuestionNode = function(xml) { 1552 this.commentQuestionNode = function(xml) {
1548 this.childOption = function(element) { 1553 this.childOption = function(element) {
1549 this.type = 'option'; 1554 this.type = 'option';
1595 if (xml.getAttribute('loop') == 'true') {this.loop = true;} 1600 if (xml.getAttribute('loop') == 'true') {this.loop = true;}
1596 else {this.loop == false;} 1601 else {this.loop == false;}
1597 if (xml.getAttribute('elementComments') == "true") {this.elementComments = true;} 1602 if (xml.getAttribute('elementComments') == "true") {this.elementComments = true;}
1598 else {this.elementComments = false;} 1603 else {this.elementComments = false;}
1599 1604
1600 var anchor = xml.getElementsByTagName('anchor');
1601 var enforceAnchor = false;
1602 if (anchor.length == 0) {
1603 // Find anchor in commonInterface;
1604 for (var i=0; i<parent.commonInterface.options.length; i++) {
1605 if(parent.commonInterface.options[i].type == 'anchor') {
1606 anchor = parent.commonInterface.options[i].value;
1607 enforceAnchor = parent.commonInterface.options[i].enforce;
1608 break;
1609 }
1610 }
1611 if (typeof(anchor) == "object") {
1612 anchor = null;
1613 }
1614 } else {
1615 anchor = anchor[0].textContent;
1616 }
1617
1618 var reference = xml.getElementsByTagName('anchor');
1619 var enforceReference = false;
1620 if (reference.length == 0) {
1621 // Find anchor in commonInterface;
1622 for (var i=0; i<parent.commonInterface.options.length; i++) {
1623 if(parent.commonInterface.options[i].type == 'reference') {
1624 reference = parent.commonInterface.options[i].value;
1625 enforceReference = parent.commonInterface.options[i].enforce;
1626 break;
1627 }
1628 }
1629 if (typeof(reference) == "object") {
1630 reference = null;
1631 }
1632 } else {
1633 reference = reference[0].textContent;
1634 }
1635
1636 if (typeof(anchor) == 'number') {
1637 if (anchor > 1 && anchor < 100) {anchor /= 100.0;}
1638 }
1639
1640 if (typeof(reference) == 'number') {
1641 if (reference > 1 && reference < 100) {reference /= 100.0;}
1642 }
1643
1644 this.preTest = new parent.prepostNode('pretest',xml.getElementsByTagName('PreTest')); 1605 this.preTest = new parent.prepostNode('pretest',xml.getElementsByTagName('PreTest'));
1645 this.postTest = new parent.prepostNode('posttest',xml.getElementsByTagName('PostTest')); 1606 this.postTest = new parent.prepostNode('posttest',xml.getElementsByTagName('PostTest'));
1646 1607
1647 this.interfaces = []; 1608 this.interfaces = [];
1648 var interfaceDOM = xml.getElementsByTagName('interface'); 1609 var interfaceDOM = xml.getElementsByTagName('interface');
1675 } 1636 }
1676 1637
1677 if (this.randomiseOrder) { 1638 if (this.randomiseOrder) {
1678 this.audioElements = randomiseOrder(this.audioElements); 1639 this.audioElements = randomiseOrder(this.audioElements);
1679 } 1640 }
1680
1681 // Check only one anchor and one reference per audioNode
1682 var anchor = [];
1683 var reference = [];
1684 this.anchorId = null;
1685 this.referenceId = null;
1686 for (var i=0; i<this.audioElements.length; i++)
1687 {
1688 if (this.audioElements[i].anchor == true) {anchor.push(i);}
1689 if (this.audioElements[i].reference == true) {reference.push(i);}
1690 }
1691
1692 if (anchor.length > 1) {
1693 console.log('Error - cannot have more than one anchor!');
1694 console.log('Each anchor node will be a normal mode to continue the test');
1695 for (var i=0; i<anchor.length; i++)
1696 {
1697 this.audioElements[anchor[i]].anchor = false;
1698 this.audioElements[anchor[i]].value = undefined;
1699 }
1700 } else {this.anchorId = anchor[0];}
1701 if (reference.length > 1) {
1702 console.log('Error - cannot have more than one anchor!');
1703 console.log('Each anchor node will be a normal mode to continue the test');
1704 for (var i=0; i<reference.length; i++)
1705 {
1706 this.audioElements[reference[i]].reference = false;
1707 this.audioElements[reference[i]].value = undefined;
1708 }
1709 } else {this.referenceId = reference[0];}
1710 1641
1711 this.commentQuestions = []; 1642 this.commentQuestions = [];
1712 var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion'); 1643 var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion');
1713 for (var i=0; i<commentQuestionsDOM.length; i++) { 1644 for (var i=0; i<commentQuestionsDOM.length; i++) {
1714 this.commentQuestions.push(new this.commentQuestionNode(commentQuestionsDOM[i])); 1645 this.commentQuestions.push(new this.commentQuestionNode(commentQuestionsDOM[i]));