Mercurial > hg > webaudioevaluationtool
changeset 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 | cb01bc04ab2c 42f4d06fa98a |
files | js/core.js php/save.php |
diffstat | 2 files changed, 23 insertions(+), 9 deletions(-) [+] |
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');
--- a/php/save.php Tue May 10 16:55:06 2016 +0100 +++ b/php/save.php Tue May 10 17:44:21 2016 +0100 @@ -1,10 +1,11 @@ <?php error_reporting(0); + $saveFilenamePrefix = isset($_GET['saveFilenamePrefix']) ? $_GET['saveFilenamePrefix'].'-' : ''; header('Access-Control-Allow-Origin: *'); header("Content-type: text/xml"); $postText = file_get_contents('php://input'); - $file_key = $_GET['key']; - $filename = "../saves/save-".$file_key.".xml"; + $file_key = $_GET['key']; + $filename = '../saves/'.$saveFilenamePrefix.'save-'.$file_key.".xml"; $doc = new DOMDocument; $doc->preserveWhiteSpace = false; $doc->formatOutput = true;