changeset 454:c251206bdddf Dev_main

APE Integrated to new specifications
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Wed, 06 Jan 2016 12:28:22 +0000
parents 44a6fe06e71a
children 4772247426f8
files ape.js core.js
diffstat 2 files changed, 24 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ape.js	Wed Jan 06 10:36:37 2016 +0000
+++ b/ape.js	Wed Jan 06 12:28:22 2016 +0000
@@ -371,14 +371,12 @@
 		
 		var node = interfaceContext.createCommentBox(audioObject);
 		// Create a slider per track
-		audioObject.interfaceDOM = new sliderObject(audioObject,interfaceObj);
-		audioObject.metric.initialise(convSliderPosToRate(audioObject.interfaceDOM.trackSliderObjects[0]));
-		if (audioObject.state == 1)
-		{
-			audioObject.interfaceDOM.enable();
-		}
-        
+		var sliderNode = new sliderObject(audioObject,interfaceObj);
+		audioObject.bindInterface(sliderNode);
 	});
+	
+	// Initialse the interfaceSlider object metrics
+	
 	$('.track-slider').mousedown(function(event) {
 		interfaceContext.selectObject($(this)[0]);
 	});
@@ -566,7 +564,7 @@
 		this.canvas.appendChild(trackObj);
 		this.sliders.push(trackObj);
 		this.metrics.push(new metricTracker(this));
-		this.metrics[this.metrics.length-1].initialPosition = convSliderPosToRate(trackObj);
+		this.metrics[this.metrics.length-1].initialise(convSliderPosToRate(trackObj));
 		return trackObj;
 	};
 	
@@ -654,8 +652,8 @@
 function buttonSubmitClick()
 {
 	var checks = [];
-	checks.concat(testState.currentStateMap.interfaces[0].options);
-	checks.concat(specification.interfaces.options);
+	checks = checks.concat(testState.currentStateMap.interfaces[0].options);
+	checks = checks.concat(specification.interfaces.options);
 	var canContinue = true;
 	
 	// Check that the anchor and reference objects are correctly placed
@@ -665,7 +663,7 @@
 	for (var i=0; i<checks.length; i++) {
 		if (checks[i].type == 'check')
 		{
-			switch(checks[i].check) {
+			switch(checks[i].name) {
 			case 'fragmentPlayed':
 				// Check if all fragments have been played
 				var checkState = interfaceContext.checkAllPlayed();
@@ -692,7 +690,7 @@
 				if (checkState == false) {canContinue = false;}
 				break;
 			default:
-				console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface");
+				console.log("WARNING - Check option "+checks[i].name+" is not supported on this interface");
 				break;
 			}
 
--- a/core.js	Wed Jan 06 10:36:37 2016 +0000
+++ b/core.js	Wed Jan 06 12:28:22 2016 +0000
@@ -1127,6 +1127,16 @@
 		this.storeDOM.setAttribute('presentedId',this.id);
 		this.storeDOM.setAttribute('playGain',linearToDecibel(this.onplayGain));
 	};
+	
+	this.bindInterface = function(interfaceObject)
+	{
+		this.interfaceDOM = interfaceObject;
+		this.metric.initialise(interfaceObject.getValue());
+		if (this.state == 1)
+		{
+			this.interfaceDOM.enable();
+		}
+	};
     
 	this.loopStart = function() {
 		this.outputGain.gain.value = this.onplayGain;
@@ -1335,12 +1345,13 @@
 	{
 		if (this.initialPosition == -1) {
 			this.initialPosition = position;
+			this.moved(0,position);
 		}
 	};
 	
 	this.moved = function(time,position)
 	{
-		this.wasMoved = true;
+		if (time > 0) {this.wasMoved = true;}
 		this.movementTracker[this.movementTracker.length] = [time, position];
 	};
 	
@@ -2641,7 +2652,7 @@
 		{
 			if (ao.specification.type == "anchor")
 			{
-				if (ao.interfaceDOM.getValue() > ao.specification.marker && ao.interfaceDOM.enforce == true) {
+				if (ao.interfaceDOM.getValue() > (ao.specification.marker/100) && ao.specification.marker > 0) {
 					// Anchor is not set below
 					console.log('Anchor node not below marker value');
 					alert('Please keep listening');
@@ -2658,7 +2669,7 @@
 		{
 			if (ao.specification.type == "reference")
 			{
-				if (ao.interfaceDOM.getValue() < ao.specification.marker && ao.interfaceDOM.enforce == true) {
+				if (ao.interfaceDOM.getValue() < (ao.specification.marker/100) && ao.specification.marker > 0) {
 					// Anchor is not set below
 					console.log('Reference node not below marker value');
 					alert('Please keep listening');