diff core.js @ 265:ec693ceb2444 Dev_main

Update dev_main
author Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk>
date Wed, 22 Jul 2015 12:41:22 +0100
parents 2e19ac736876
children 23f4f4c0a13a
line wrap: on
line diff
--- a/core.js	Sun Jun 28 09:52:47 2015 +0100
+++ b/core.js	Wed Jul 22 12:41:22 2015 +0100
@@ -394,16 +394,19 @@
 			}
 			this.stateIndex = -1;
 			var that = this;
+			var aH_pId = 0;
 			for (var id=0; id<this.stateMap.length; id++){
 				var name = this.stateMap[id].type;
 				var obj = document.createElement(name);
 				if (name == 'audioHolder') {
 					obj.id = this.stateMap[id].id;
+					obj.setAttribute('presentedid',aH_pId);
+					aH_pId+=1;
 				}
 				this.stateResults.push(obj);
 			}
 		} else {
-			conolse.log('FATAL - StateMap not correctly constructed. EMPTY_STATE_MAP');
+			console.log('FATAL - StateMap not correctly constructed. EMPTY_STATE_MAP');
 		}
 	};
 	this.advanceState = function(){
@@ -634,6 +637,29 @@
 	}
 }
 
+function errorSessionDump(msg){
+	// Create the partial interface XML save
+	// Include error node with message on why the dump occured
+	var xmlDoc = interfaceXMLSave();
+	var err = document.createElement('error');
+	err.textContent = msg;
+	xmlDoc.appendChild(err);
+	var parent = document.createElement("div");
+	parent.appendChild(xmlDoc);
+	var file = [parent.innerHTML];
+	var bb = new Blob(file,{type : 'application/xml'});
+	var dnlk = window.URL.createObjectURL(bb);
+	var a = document.createElement("a");
+	a.hidden = '';
+	a.href = dnlk;
+	a.download = "save.xml";
+	a.textContent = "Save File";
+	
+	popup.showPopup();
+	popup.popupContent.innerHTML = "ERROR : "+msg;
+	popup.popupContent.appendChild(a);
+}
+
 // Only other global function which must be defined in the interface class. Determines how to create the XML document.
 function interfaceXMLSave(){
 	// Create the XML string to be exported with results
@@ -885,6 +911,12 @@
 				if (audioObj.state == 0 || audioObj.buffer == undefined) {
 					// Genuine error
 					console.log('FATAL - Error loading buffer on '+audioObj.id);
+					if (request.status == 404)
+					{
+						console.log('FATAL - Fragment '+audioObj.id+' 404 error');
+						console.log('URL: '+audioObj.url);
+						errorSessionDump('Fragment '+audioObj.id+' 404 error');
+					}
 				}
 			});
 		};
@@ -1256,7 +1288,11 @@
 		this.commonInterface = new function() {
 			this.OptionNode = function(child) {
 				this.type = child.nodeName;
-				if (this.type == 'check') {
+				if (this.type == 'option')
+				{
+					this.name = child.getAttribute('name');
+				}
+				else if (this.type == 'check') {
 					this.check = child.getAttribute('name');
 					if (this.check == 'scalerange') {
 						this.min = child.getAttribute('min');
@@ -1622,6 +1658,7 @@
 				question.textContent = this.trackString.textContent;
 				var response = document.createElement('response');
 				response.textContent = this.trackCommentBox.value;
+				console.log("Comment frag-"+this.id+": "+response.textContent);
 				root.appendChild(question);
 				root.appendChild(response);
 			}
@@ -1655,6 +1692,8 @@
 			root.id = this.specification.id;
 			root.setAttribute('type',this.specification.type);
 			root.textContent = this.textArea.value;
+			console.log("Question: "+this.string.textContent);
+			console.log("Response: "+root.textContent);
 			return root;
 		};
 	};
@@ -1969,5 +2008,4 @@
 		}
 		return true;
 	};
-}
-
+}
\ No newline at end of file