// uses functions in utils.js var host = window.location.protocol + "//" + window.location.host; function downloadCurrent(){ call("downloadSave"); } // load and append dirty file function loadDirty(){ call("loadDirty", "dirty"); } // load save file (clean) function loadSave(){ call("loadSave", "clean"); } function call(command, formid=""){ var formData; if (formid == "") { formData = new FormData(); }else { formData = new FormData(document.getElementById(formid)); } formData.append("command", command); console.log(formData); fetch(host+'/controls', { method: "POST", body: formData }).then( res => res.blob() ) .then( blob => { var file = window.URL.createObjectURL(blob); window.location.assign(file);}); //.then((response) => response.json()) //.then((json) => handleCallResponse(json)); } function handleLatestInfo(json){ if(json['status'] != "OK")alert("Error."); }