changeset 2329:59083312c5ff

Fix for #50. WIP for #56. Can over-ride returnURL in test URL
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Wed, 04 May 2016 11:38:55 +0100
parents ced5aedb4cda
children fc8d79f8d9c5 ee5e2db32f7c
files js/core.js
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/js/core.js	Tue May 03 15:18:13 2016 +0100
+++ b/js/core.js	Wed May 04 11:38:55 2016 +0100
@@ -16,7 +16,7 @@
 var testState;
 var currentTrackOrder = []; // Hold the current XML tracks in their (randomised) order
 var audioEngineContext; // The custome AudioEngine object
-var projectReturn; // Hold the URL for the return
+var gReturnURL;
 
 
 // Add a prototype to the bufferSourceNode to reference to the audioObject holding it
@@ -150,9 +150,13 @@
         {
             // Split each request into
             searchQueries[i] = searchQueries[i].split('=');
-            if (searchQueries[i][0] == "url")
-            {
-                url = decodeURI(searchQueries[i][1]);
+            switch(searchQueries[i][0]) {
+                case "url":
+                    url = decodeURI(searchQueries[i][1]);
+                    break;
+                case "returnURL":
+                    gReturnURL = decodeURI(searchQueries[i][1]);
+                    break;
             }
         }
         loadProjectSpec(url);
@@ -399,6 +403,11 @@
             break;
 	}
 	document.getElementsByTagName("head")[0].appendChild(interfaceJS);
+    
+    if (gReturnURL != undefined) {
+        console.log("returnURL Overide from "+specification.returnURL+" to "+gReturnURL);
+        specification.returnURL = gReturnURL;
+    }
 	
 	// Create the audio engine object
 	audioEngineContext = new AudioEngine(specification);
@@ -454,7 +463,9 @@
                     var file = response.getElementsByTagName("file")[0];
                     console.log("Save: OK, written "+file.getAttribute("bytes")+"B");
                     if (typeof specification.returnURL == "string") {
-                        window.location = returnURL;
+                        if (specification.returnURL.length > 0) {
+                            window.location = specification.returnURL;
+                        }
                     } else {
                         popup.popupContent.textContent = specification.exitText;
                     }