-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.html
More file actions
137 lines (117 loc) · 3.61 KB
/
index.html
File metadata and controls
137 lines (117 loc) · 3.61 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>todo sample course</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;600&display=swap" rel="stylesheet">
<script src="https://unpkg.com/@phosphor-icons/web"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Outfit;
}
.container {
background-color: #303443;
/* background-color: rgb(94, 19, 30); */
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.content {
display: flex;
align-items: center;
gap: 0.25rem
}
.titleHost {
color: white;
font-size: 1.5rem;
margin-bottom: 1rem;
}
.input {
border: none;
padding: 0.45rem 1rem;
border-radius: 0.25rem;
}
.btn-send {
border: none;
background-color: transparent;
}
#listToDo>span {
color: white;
font-size: 0.875rem;
font-weight: 300;
}
#listToDo>strong {
color: white;
font-size: 0.875rem;
margin-bottom: 0.25rem;
}
#listToDo {
margin-top: 1rem;
gap: 0.25rem;
display: flex;
flex-direction: column;
align-items: flex-start;
width: 16rem;
}
</style>
</head>
<body>
<div class="container">
<p class="titleHost">O host esta rodando em: <span id="host"></span></p>
<div class="content">
<input type="text" id="todo" class="input" placeholder="Adicione um To Do" />
<button onclick="handleInsertToDo()" class="btn-send"><i class="ph-fill ph-plus-square"
style="color:#0886FD;font-size: 2.125rem;cursor: pointer;"></i></button>
</div>
<div id="listToDo">
</div>
</div>
</div>
<script>
function getOS() {
fetch('/os').then(data => data.json()).then(result => {
document.getElementById("host").innerText = result;
})
}
function handleGetListToDo() {
fetch('/todo').then(data => data.json()).then(result => {
const el = document.getElementById("listToDo")
if (result.length > 0) {
let listMap = "<strong>Sua Lista</strong>";
result.map(item => {
listMap += `<span id="${item.id}">${item.todo} </span>`
})
el.innerHTML = listMap
}
})
}
function handleInsertToDo() {
const el = document.getElementById("todo")
console.log(el.value)
fetch('/todo', {
method: "POST",
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ todo: el.value })
}).then(() => {
handleGetListToDo()
})
el.value = ""
}
handleGetListToDo()
getOS()
</script>
</body>
</html>