summaryrefslogtreecommitdiff
path: root/dashboard_website/static/js/controls.js
blob: 3d810323ad80773011066b875a2890d0f9a00078 (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
// 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.");
}