comparison core.js @ 862:cf593a8bfd71

Completed Anchor and Reference Features, including optional enforcement
author Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk>
date Wed, 22 Jul 2015 17:58:01 +0100
parents 212b353a5cd3
children 54c1fb5ca218
comparison
equal deleted inserted replaced
861:212b353a5cd3 862:cf593a8bfd71
1319 this.max = Number(this.max); 1319 this.max = Number(this.max);
1320 } 1320 }
1321 } 1321 }
1322 } else if (this.type == 'anchor' || this.type == 'reference') { 1322 } else if (this.type == 'anchor' || this.type == 'reference') {
1323 this.value = Number(child.textContent); 1323 this.value = Number(child.textContent);
1324 this.enforce = child.getAttribute('enforce');
1325 if (this.enforce == 'true') {this.enforce = true;}
1326 else {this.enforce = false;}
1324 } 1327 }
1325 }; 1328 };
1326 this.options = []; 1329 this.options = [];
1327 if (commonInterfaceNode != undefined) { 1330 if (commonInterfaceNode != undefined) {
1328 var child = commonInterfaceNode.firstElementChild; 1331 var child = commonInterfaceNode.firstElementChild;
1441 else {this.reference = false;} 1444 else {this.reference = false;}
1442 1445
1443 this.marker = xml.getAttribute('marker'); 1446 this.marker = xml.getAttribute('marker');
1444 if (this.marker == null) {this.marker = undefined;} 1447 if (this.marker == null) {this.marker = undefined;}
1445 1448
1446 if (this.anchor == true && this.marker == undefined) { 1449 if (this.anchor == true) {
1450 if (this.marker != undefined) {this.enforce = true;}
1451 else {this.enforce = enforceAnchor;}
1447 this.marker = anchor; 1452 this.marker = anchor;
1448 } 1453 }
1449 else if (this.reference == true && this.marker == undefined) { 1454 else if (this.reference == true) {
1455 if (this.marker != undefined) {this.enforce = true;}
1456 else {this.enforce = enforceReference;}
1450 this.marker = reference; 1457 this.marker = reference;
1451 } 1458 }
1452 1459
1453 if (this.marker != undefined) { 1460 if (this.marker != undefined) {
1454 this.marker = Number(this.marker); 1461 this.marker = Number(this.marker);
1508 else {this.loop == false;} 1515 else {this.loop == false;}
1509 if (xml.getAttribute('elementComments') == "true") {this.elementComments = true;} 1516 if (xml.getAttribute('elementComments') == "true") {this.elementComments = true;}
1510 else {this.elementComments = false;} 1517 else {this.elementComments = false;}
1511 1518
1512 var anchor = xml.getElementsByTagName('anchor'); 1519 var anchor = xml.getElementsByTagName('anchor');
1520 var enforceAnchor = false;
1513 if (anchor.length == 0) { 1521 if (anchor.length == 0) {
1514 // Find anchor in commonInterface; 1522 // Find anchor in commonInterface;
1515 for (var i=0; i<parent.commonInterface.options.length; i++) { 1523 for (var i=0; i<parent.commonInterface.options.length; i++) {
1516 if(parent.commonInterface.options[i].type == 'anchor') { 1524 if(parent.commonInterface.options[i].type == 'anchor') {
1517 anchor = parent.commonInterface.options[i].value; 1525 anchor = parent.commonInterface.options[i].value;
1526 enforceAnchor = parent.commonInterface.options[i].enforce;
1518 break; 1527 break;
1519 } 1528 }
1520 } 1529 }
1521 if (typeof(anchor) == "object") { 1530 if (typeof(anchor) == "object") {
1522 anchor = null; 1531 anchor = null;
1524 } else { 1533 } else {
1525 anchor = anchor[0].textContent; 1534 anchor = anchor[0].textContent;
1526 } 1535 }
1527 1536
1528 var reference = xml.getElementsByTagName('anchor'); 1537 var reference = xml.getElementsByTagName('anchor');
1538 var enforceReference = false;
1529 if (reference.length == 0) { 1539 if (reference.length == 0) {
1530 // Find anchor in commonInterface; 1540 // Find anchor in commonInterface;
1531 for (var i=0; i<parent.commonInterface.options.length; i++) { 1541 for (var i=0; i<parent.commonInterface.options.length; i++) {
1532 if(parent.commonInterface.options[i].type == 'reference') { 1542 if(parent.commonInterface.options[i].type == 'reference') {
1533 reference = parent.commonInterface.options[i].value; 1543 reference = parent.commonInterface.options[i].value;
1544 enforceReference = parent.commonInterface.options[i].enforce;
1534 break; 1545 break;
1535 } 1546 }
1536 } 1547 }
1537 if (typeof(reference) == "object") { 1548 if (typeof(reference) == "object") {
1538 reference = null; 1549 reference = null;
2006 { 2017 {
2007 var audioHolder = testState.currentStateMap[testState.currentIndex]; 2018 var audioHolder = testState.currentStateMap[testState.currentIndex];
2008 if (audioHolder.anchorId != null) 2019 if (audioHolder.anchorId != null)
2009 { 2020 {
2010 var audioObject = audioEngineContext.audioObjects[audioHolder.anchorId]; 2021 var audioObject = audioEngineContext.audioObjects[audioHolder.anchorId];
2011 if (audioObject.interfaceDOM.getValue() > audioObject.specification.marker) 2022 if (audioObject.interfaceDOM.getValue() > audioObject.specification.marker && audioObject.interfaceDOM.enforce == true)
2012 { 2023 {
2013 // Anchor is not set below 2024 // Anchor is not set below
2014 console.log('Anchor node not below marker value'); 2025 console.log('Anchor node not below marker value');
2015 alert('Please keep listening'); 2026 alert('Please keep listening');
2016 return false; 2027 return false;
2023 { 2034 {
2024 var audioHolder = testState.currentStateMap[testState.currentIndex]; 2035 var audioHolder = testState.currentStateMap[testState.currentIndex];
2025 if (audioHolder.referenceId != null) 2036 if (audioHolder.referenceId != null)
2026 { 2037 {
2027 var audioObject = audioEngineContext.audioObjects[audioHolder.referenceId]; 2038 var audioObject = audioEngineContext.audioObjects[audioHolder.referenceId];
2028 if (audioObject.interfaceDOM.getValue() < audioObject.specification.marker) 2039 if (audioObject.interfaceDOM.getValue() < audioObject.specification.marker && audioObject.interfaceDOM.enforce == true)
2029 { 2040 {
2030 // Anchor is not set below 2041 // Anchor is not set below
2031 console.log('Reference node not above marker value'); 2042 console.log('Reference node not above marker value');
2032 alert('Please keep listening'); 2043 alert('Please keep listening');
2033 return false; 2044 return false;