forked from zero-to-mastery/HTML-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo_list.html
158 lines (134 loc) Β· 5.78 KB
/
todo_list.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>ToDo List</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.2/dist/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<title>ToDo List</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora|Montserrat&display=swap" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.2/dist/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="icon" href="resources\images\logo.png" />
<link rel="stylesheet" href="resources/style/style.css" />
<link rel="stylesheet" href="resources/style/about-page.css" />
<!-- Dark Mode -->
<link rel="stylesheet" type="text/css" href="resources/style/themeToggle.css" />
<script src="resources/scripts/themeToggle.js" defer></script>
<!-- /Dark Mode -->
<style>
body {
text-align: center;
font-family: 'Josefin Sans', sans-serif;
}
h1 {
margin-top: 10rem;
margin-bottom: 30px;
font-size: 5em;
}
li {
list-style: none;
}
.newBtn {
margin: 10px;
background-color: #dc3545;
}
.done {
text-decoration: line-through;
}
#reload {
margin: 25px;
}
</style>
</head>
<body>
<!-- navbar -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<a class="navbar-brand" href="index.html"><img src="resources/images/logo.png" alt=""></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link font-weight-bold" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="instructor.html">Instructor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="register.html">Sign Up</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contributersProfile.html">Contributors</a>
</li>
<li class="nav-item active-link">
<a class="nav-link" href="todo_list.html">Student Projects</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact-us.html">Contact Us</a>
</li>
</ul>
</div>
<div class='theme-toggle-container'>
<span class='theme-toggle-text my-2'>Light Mode</span>
<label class='theme-toggle'>
<input id='theme-toggle-switch' type='checkbox'>
<span class='slider round'></span>
</label>
</div>
<a class="nav-link ml-md-auto" href="beyondztm.html">Beyond Zero to Mastery <i
class="fas fa-arrow-right"></i></a>
</nav>
<!-- end nav bar -->
<h1>ToDo List</h1>
<form action="/nowhere">
<input type="text" id="product" name="product" placeholder="enter item">
<button disabled id="btn-submit">Submit</button>
</form>
<br><br>
<h3>List:</h3>
<ul id="list"></ul>
<button id="reload" onclick="location.reload()">Refresh</button>
<!-- ------------------------------------------------------------- -->
<!-- ------------------------------------------------------------- -->
<script>
let form = document.querySelector('form');
let product = document.getElementById("product");
let buttonSubmit = document.getElementById("btn-submit")
product.addEventListener('keyup', (event) => {
let value = event.target.value;
value !== '' ? buttonSubmit.disabled = false : buttonSubmit.disabled = true
});
form.addEventListener("submit", (event) => {
let li = document.createElement("li");
let btn = document.createElement("button");
let span = document.createElement("span");
btn.innerText = "Delete Item";
btn.classList.add("newBtn");
li.append(product.value, btn);
li.addEventListener('click', () => {
li.classList.toggle('done');
});
span.append(li);
let ul = document.querySelector("#list");
ul.append(span);
btn.addEventListener("click", () => {
span.remove();
})
product.value = "";
buttonSubmit.disabled = true;
event.preventDefault();
});
</script>
</body>
</html>