-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
75 lines (69 loc) · 2.11 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Apple Notes Database</title>
<style>
fieldset {
display: flex;
flex-direction: column;
gap: 1ex;
}
label {
display: flex;
}
label>span {
width: 10ch;
}
label>input {
width: 20ch;
}
</style>
<script type="module">
const typeInput = document.getElementById('typeInput');
const idInput = document.getElementById('idInput');
const dataTextArea = document.getElementById('dataTextArea');
const listButton = document.getElementById('listButton');
const getButton = document.getElementById('getButton');
const postButton = document.getElementById('postButton');
listButton.addEventListener('click', async () => {
const response = await fetch(`/${typeInput.value}`);
const data = await response.json();
dataTextArea.value = JSON.stringify(data, null, 2);
});
getButton.addEventListener('click', async () => {
const response = await fetch(`/${typeInput.value}/${idInput.value}`);
const data = await response.json();
dataTextArea.value = JSON.stringify(data, null, 2);
});
postButton.addEventListener('click', async () => {
await fetch(`/${typeInput.value}/${idInput.value}`, {
method: 'POST',
body: dataTextArea.value,
});
});
</script>
</head>
<body>
<fieldset>
<legend>To-Do List</legend>
<a href="todo.html">To-Do List</a>
</fieldset>
<fieldset>
<legend>Apple Notes Database</legend>
<label>
<span>Type:</span>
<input id="typeInput" />
</label>
<label>
<span>ID:</span>
<input id="idInput" />
</label>
<textarea id="dataTextArea" rows="10"></textarea>
<button id="listButton">GET type</button>
<button id="getButton">GET type/id</button>
<button id="postButton">POST type/id</button>
</fieldset>
</body>
</html>