-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotedit.html
116 lines (85 loc) · 2.83 KB
/
plotedit.html
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<HTML>
<HEAD>
<TITLE>Plot Config</TITLE>
<LINK rel='stylesheet' type='text/css' href='style.css'>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<script src="./Sortable.min.js"></script>
<h2>Status Config</h2>
<script type="text/javascript" src="links.js"></script>
<script type="text/javascript" src="recent.json"></script>
<script type="text/javascript" src="./makerow.js"></script>
<div id='var_area' class='block_container'>
<b>Variables</b>
</div><br>
<div id='tail_area' class='block_container'>
<input type='submit' id='update_button' style="float: right;">
</div>
<script>
//
var sort_opts = {
filter: '.js-remove',
onFilter: function (evt) {
var el = editableList.closest(evt.item);
el && el.parentNode.removeChild(el);
}
};
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'init.json', false);
httpRequest.send();
var init = JSON.parse(httpRequest.responseText).init;
httpRequest.open('GET', 'plotedit.json', false);
httpRequest.send();
var plotVars = JSON.parse(httpRequest.responseText).plotVars;
console.log(plotVars);
//make table
table = document.createElement('table');
var sortableInputVals = Sortable.create(table, sort_opts);
header = table.createTHead();
header.appendChild( make_row(['Variable', 'Xaxis','Label', 'isBool', 'Options']) );
for (var v in plotVars) {
var new_row = make_row( [
v,
{"type": "radio", "val": ["isX", plotVars[v].Axis === "x"]},
{"type": "inputText", "val": plotVars[v].Label},
{"type": "checkBox", "val": plotVars[v].isBool},
{"type": "inputText", "val": plotVars[v].Options}
]);
table.appendChild(new_row);
}
var_area.appendChild(table);
var button = document.getElementById('update_button');
update_button.value = 'Update!';
update_button.onclick = function(){ update_page(); };
function update_page() {
dat = {};
for (var i = 1; i < table.rows.length; i++) {
var var_name = table.rows[i].cells[0].children[0].innerText;
var ax = (table.rows[i].cells[1].children[0].checked) ? "x" : "y";
dat[var_name] = {
"Axis": ax,
"Label": table.rows[i].cells[2].children[0].value,
"isBool": table.rows[i].cells[3].children[0].checked,
"Options": table.rows[i].cells[4].children[0].value
};
}
xhr = new XMLHttpRequest();
var url = "/plotedit.html";
xhr.open("POST", url);//, true);
xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
//var json = JSON.parse(xhr.responseText);
//console.log(xhr.responseText);
alert(xhr.responseText);
}
};
var dataSend = JSON.stringify({"plotVars": dat}, null, ' ');
console.log(dataSend);
xhr.send(dataSend);
window.location.href = "plotedit.html";
}
</script>
<a href='status.html'>return to status</a>
</BODY>
</HTML>