Mercurial > hg > webaudioevaluationtool
diff js/core.js @ 2337:d347dbab980d
Added support for saveFilenamePrefix= querystring , closed #56
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 10 May 2016 17:44:21 +0100 |
parents | e22ec7b6cfbd |
children | 5f1e2b66d8bb |
line wrap: on
line diff
--- a/js/core.js Tue May 10 16:55:06 2016 +0100 +++ b/js/core.js Tue May 10 17:44:21 2016 +0100 @@ -17,6 +17,7 @@ var currentTrackOrder = []; // Hold the current XML tracks in their (randomised) order var audioEngineContext; // The custome AudioEngine object var gReturnURL; +var gSaveFilenamePrefix; // Add a prototype to the bufferSourceNode to reference to the audioObject holding it @@ -160,6 +161,9 @@ case "returnURL": gReturnURL = value; break; + case "saveFilenamePrefix": + gSaveFilenamePrefix = value; + break; } } loadProjectSpec(url); @@ -411,6 +415,9 @@ console.log("returnURL Overide from "+specification.returnURL+" to "+gReturnURL); specification.returnURL = gReturnURL; } + if (gSaveFilenamePrefix != undefined){ + specification.saveFilenamePrefix = gSaveFilenamePrefix; + } // Create the audio engine object audioEngineContext = new AudioEngine(specification); @@ -439,14 +446,20 @@ popup.popupContent.innerHTML = "<span>Please save the file below to give to your test supervisor</span><br>"; popup.popupContent.appendChild(a); } else { + var saveUrlSuffix = ""; + var saveFilenamePrefix = specification.saveFilenamePrefix; + if(typeof(saveFilenamePrefix) === "string" && saveFilenamePrefix.length > 0){ + saveUrlSuffix = "&saveFilenamePrefix="+saveFilenamePrefix; + } + var projectReturn = ""; + if (typeof specification.projectReturn == "string") { + if (specification.projectReturn.substr(0,4) == "http") { + projectReturn = specification.projectReturn; + } + } + var saveURL = projectReturn+"php/save.php?key="+storage.SessionKey.key+saveUrlSuffix; var xmlhttp = new XMLHttpRequest; - 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.open("POST", saveURL, true); xmlhttp.setRequestHeader('Content-Type', 'text/xml'); xmlhttp.onerror = function(){ console.log('Error saving file to server! Presenting download locally');