-
Notifications
You must be signed in to change notification settings - Fork 9
/
client.js
37 lines (25 loc) · 953 Bytes
/
client.js
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
/*global List*/
(function() {
[].forEach.call(document.querySelectorAll(".url-row"), function(row) {
var button = row.querySelector(".delete");
button.addEventListener("click", function(e) {
e.preventDefault();
var sha1 = button.dataset.sha1;
button.parentNode.removeChild(button);
var req = new XMLHttpRequest();
req.onload = function(e) {
if (e.target.status !== 200) {
console.log("Failed to delete", sha1, e);
alert("Bad response: " + e.target.status + " Check the console");
return;
}
row.className += " deleted";
};
req.open("DELETE", "/req/" + sha1, true);
req.send();
}, false);
});
new List("cached-reqs", {
valueNames: [ "size", "url", "created", "timestamp", "sha1" ]
});
}());