-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.nim
60 lines (54 loc) · 1.48 KB
/
script.nim
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
import templates
proc script(): string = tmpli js"""
function deleteItem(id) {
axios({
method: 'post',
url: '/deleteItem',
data: {
id: id
}
}).then(function (response) {
console.log(response);
window.location.reload();
}).catch(function (error) {
console.log(error);
})
}
function addItem() {
var todoDesc = document.getElementById("text").value;
var todoDate = document.getElementById("flatpickr").value;
axios({
method: 'post',
url: '/addItem',
data: {
desc: todoDesc,
date: todoDate
}
}).then(function (response) {
console.log(response);
document.getElementById("text").value = "";
document.getElementById("flatpickr").value = "";
window.location.reload();
}).catch(function (error) {
console.log(error);
window.location.reload();
})
}
const inputs = document.getElementsByClassName("inputfield")
inputs[0].addEventListener("keyup", ({key}) => {
if (key == "Enter") {
addItem();
}
});
inputs[1].addEventListener("keyup", ({key}) => {
if (key == "Enter") {
addItem();
}
});
var example = flatpickr('#flatpickr', {
enableTime: true,
dateFormat: "Y-m-d H:i",
time_24hr: true
});
"""
export script