blob: d26a15d11e02518fcf155d83c8461441d220a2af (
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
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
|
function resetOnClick() {
var changepoints = d3.selectAll(".changepoint");
changepoints.each(function(d, i) {
var elem = d3.select(this);
elem.classed("changepoint", false);
elem.style("fill", "blue");
});
updateTable();
}
function noCPOnClick(task_id) {
var changepoints = document.getElementsByClassName("changepoint");
// validation
if (changepoints.length > 0) {
$('#NoCPYesCPModal').modal();
return;
}
var obj = {
task: task_id,
changepoints: null
};
var xhr = new XMLHttpRequest();
xhr.open("POST", "");
xhr.withCredentials = true;
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(obj));
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
if (xhr.status === 200)
window.location.href = xhr.responseText;
} else {
console.log("Error: " + xhr.status);
}
};
}
function submitOnClick(task_id) {
var changepoints = document.getElementsByClassName("changepoint");
// validation
if (changepoints.length === 0) {
$('#submitNoCPModal').modal();
return;
}
var obj = {};
obj["task"] = task_id;
obj["changepoints"] = [];
var i, cp;
for (i=0; i<changepoints.length; i++) {
cp = changepoints[i];
elem = {
id: i,
x: cp.getAttribute("data_X"),
y: cp.getAttribute("data_Y")
};
obj["changepoints"].push(elem);
}
var xhr = new XMLHttpRequest();
xhr.open("POST", "");
xhr.withCredentials = true;
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(obj));
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
if (xhr.status === 200)
window.location.href = xhr.responseText;
} else {
console.log("Error: " + xhr.status);
}
};
}
|