var startTime = new Date(); $(function() { var savePath = ''; $('#saveLocationBtn').click(function() { savePath = mozillaSelectFolder().file.path; // alert(savePath.file.path); }); $('#selectAudioFile').click(function() { if (savePath === '') { alert("Please select a save location first."); return false; } fil = selectFile(); // alert(savePath); var destName = getDateString(startTime) + ".mp3"; mozillaCopyFile(fil.file.path, savePath, destName); }); $('#saveFormData').click(function() { if (savePath === '') { alert("Please select a save location first."); return false; } var arr = $('#metadataForm').serializeArray(); var s = JSON.stringify(arr); // alert(s); var destFilePath = savePath + "/" + getDateString(startTime) + ".json"; // alert(destFilePath); mozillaSaveFile(destFilePath, s); alert("saved " + destFilePath); }); }); function getDateString(dateObj) { return dateObj.toUTCString().replace(",", "").replace(":", "."); }