diff js/core.js @ 2302:f7604317ac27

Fix for #39. projectReturn is now used to determine which server to save the session to if using different servers for hosting and analysis
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 28 Apr 2016 09:57:21 +0100
parents 18d390c66b47
children e4a2a39838db
line wrap: on
line diff
--- a/js/core.js	Wed Apr 27 20:44:00 2016 +0100
+++ b/js/core.js	Thu Apr 28 09:57:21 2016 +0100
@@ -408,7 +408,13 @@
 		popup.popupContent.appendChild(a);
 	} else {
 		var xmlhttp = new XMLHttpRequest;
-		xmlhttp.open("POST","php/save.php?key="+storage.SessionKey.key,true);
+        var returnURL = "";
+        if (typeof specification.projectReturn == "string") {
+            if (specification.projectReturn.substr(0,4) == "http") {
+                returnURL = specification.projectReturn;
+            }
+        }
+		xmlhttp.open("POST",returnURL+"php/save.php?key="+storage.SessionKey.key,true);
 		xmlhttp.setRequestHeader('Content-Type', 'text/xml');
 		xmlhttp.onerror = function(){
 			console.log('Error saving file to server! Presenting download locally');
@@ -2837,14 +2843,26 @@
         },
         generateKey: function() {
             var temp_key = randomString(32);
-            this.request.open("GET","php/keygen.php?key="+temp_key,true);
+            var returnURL = "";
+            if (typeof specification.projectReturn == "string") {
+                if (specification.projectReturn.substr(0,4) == "http") {
+                    returnURL = specification.projectReturn;
+                }
+            }
+            this.request.open("GET",returnURL+"php/keygen.php?key="+temp_key,true);
             this.request.addEventListener("load",this);
             this.request.send();
         },
         update: function() {
             this.parent.root.setAttribute("state","update");
             var xmlhttp = new XMLHttpRequest();
-            xmlhttp.open("POST","php/"+specification.projectReturn+"?key="+this.key);
+            var returnURL = "";
+            if (typeof specification.projectReturn == "string") {
+                if (specification.projectReturn.substr(0,4) == "http") {
+                    returnURL = specification.projectReturn;
+                }
+            }
+            xmlhttp.open("POST",returnURL+"php/save.php?key="+this.key);
             xmlhttp.setRequestHeader('Content-Type', 'text/xml');
             xmlhttp.onerror = function(){
                 console.log('Error updating file to server!');