blob: 66c33a8fa1670b7488721d0b4fc02ba243f8d96d (
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
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Lijst</title>
<script>
function postReq(url, body) {
var xhr = new XMLHttpRequest();
xhr.open("POST", location.href + url);
xhr.responseType = "text";
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
document.getElementById("tbody").innerHTML = xhr.responseText;
} else {
alert(xhr.responseText);
}
}
};
xhr.send(body);
}
function addItem() {
postReq("/add", document.getElementById("text").value);
document.getElementById("text").value = "";
}
function removeItem(id) {
postReq("/remove/" + id);
}
function vote(id, num) {
postReq("/vote/" + id + "/" + num);
}
</script>
<style>
#table {
border-collapse: collapse;
}
#table td {
padding: 2px;
padding-left: 7px;
padding-right: 7px;
border: 1px #eee solid;
}
</style>
</head>
<body>
<table id="table"><tbody id="tbody">
<!--[[LIJST_ITEMS]]-->
</tbody></table>
<br>
<input type="text" id="text" placeholder="New item text">
<input type="button" onclick="addItem()" value="Add item"><br>
</body>
</html>
|