changeset 269:8be863078392 Dev_main

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 af166dc1bfad
children 10fac2ffe7d1
files core.js example_eval/project.xml
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/core.js	Wed Jul 22 14:10:55 2015 +0100
+++ b/core.js	Wed Jul 22 17:58:01 2015 +0100
@@ -1321,6 +1321,9 @@
 					}
 				} else if (this.type == 'anchor' || this.type == 'reference') {
 					this.value = Number(child.textContent);
+					this.enforce = child.getAttribute('enforce');
+					if (this.enforce == 'true') {this.enforce = true;}
+					else {this.enforce = false;}
 				}
 			};
 			this.options = [];
@@ -1443,10 +1446,14 @@
 			this.marker = xml.getAttribute('marker');
 			if (this.marker == null) {this.marker = undefined;}
 			
-			if (this.anchor == true && this.marker == undefined) {
+			if (this.anchor == true) {
+				if (this.marker != undefined) {this.enforce = true;}
+				else {this.enforce = enforceAnchor;}
 				this.marker = anchor;
 			}
-			else if (this.reference == true && this.marker == undefined) {
+			else if (this.reference == true) {
+				if (this.marker != undefined) {this.enforce = true;}
+				else {this.enforce = enforceReference;}
 				this.marker = reference;
 			}
 			
@@ -1510,11 +1517,13 @@
 		else {this.elementComments = false;}
 		
 		var anchor = xml.getElementsByTagName('anchor');
+		var enforceAnchor = false;
 		if (anchor.length == 0) {
 			// Find anchor in commonInterface;
 			for (var i=0; i<parent.commonInterface.options.length; i++) {
 				if(parent.commonInterface.options[i].type == 'anchor') {
 					anchor = parent.commonInterface.options[i].value;
+					enforceAnchor = parent.commonInterface.options[i].enforce;
 					break;
 				}
 			}
@@ -1526,11 +1535,13 @@
 		}
 		
 		var reference = xml.getElementsByTagName('anchor');
+		var enforceReference = false;
 		if (reference.length == 0) {
 			// Find anchor in commonInterface;
 			for (var i=0; i<parent.commonInterface.options.length; i++) {
 				if(parent.commonInterface.options[i].type == 'reference') {
 					reference = parent.commonInterface.options[i].value;
+					enforceReference = parent.commonInterface.options[i].enforce;
 					break;
 				}
 			}
@@ -2008,7 +2019,7 @@
 		if (audioHolder.anchorId != null)
 		{
 			var audioObject = audioEngineContext.audioObjects[audioHolder.anchorId];
-			if (audioObject.interfaceDOM.getValue() > audioObject.specification.marker)
+			if (audioObject.interfaceDOM.getValue() > audioObject.specification.marker && audioObject.interfaceDOM.enforce == true)
 			{
 				// Anchor is not set below
 				console.log('Anchor node not below marker value');
@@ -2025,7 +2036,7 @@
 		if (audioHolder.referenceId != null)
 		{
 			var audioObject = audioEngineContext.audioObjects[audioHolder.referenceId];
-			if (audioObject.interfaceDOM.getValue() < audioObject.specification.marker)
+			if (audioObject.interfaceDOM.getValue() < audioObject.specification.marker && audioObject.interfaceDOM.enforce == true)
 			{
 				// Anchor is not set below
 				console.log('Reference node not above marker value');
--- a/example_eval/project.xml	Wed Jul 22 14:10:55 2015 +0100
+++ b/example_eval/project.xml	Wed Jul 22 17:58:01 2015 +0100
@@ -41,6 +41,7 @@
 			<check name="fragmentComments"/>-->
 			<check name="scalerange" min="25" max="75"/>
 			<option name='playhead'/>
+			<anchor enforce="false">40</anchor>
 		</interface>
 	</setup>
 	<audioHolder id='test-0' hostURL="example_eval/" sampleRate="44100" randomiseOrder='true' repeatCount='0' loop='false' elementComments='true'>
@@ -51,7 +52,6 @@
 			<scale position="50">Middle</scale>
 			<scale position="20">20</scale>
 			<commentBoxPrefix>Comment on fragment</commentBoxPrefix>
-			<anchor>40</anchor>
 		</interface>
 		<audioElements url="0.wav" id="0" type="anchor"/>
 		<audioElements url="1.wav" id="1"/>