blob: 3f8b8a5f8eed032197942750a0268be209c5a525 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// 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 setHome(){
call("setHome", "home");
}
function generateRoutes(){
call("generateRoutes");
}
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.");
}
|