-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
267 lines (227 loc) · 7.26 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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel=" shortcut icon" type="image/png" href="assets/icons/favicon.png" />
<link rel="stylesheet" href="app.css" />
<script src="https://unpkg.com/lucide@latest"></script>
</head>
<script language="JavaScript">
window.onload = function() {
document.addEventListener("contextmenu", function(e){
e.preventDefault();
}, false);
document.addEventListener("keydown", function(e) {
//document.onkeydown = function(e) {
// "I" key
if (e.ctrlKey && e.shiftKey && e.keyCode == 73) {
disabledEvent(e);
}
// "J" key
if (e.ctrlKey && e.shiftKey && e.keyCode == 74) {
disabledEvent(e);
}
// "S" key + macOS
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
disabledEvent(e);
}
// "U" key
if (e.ctrlKey && e.keyCode == 85) {
disabledEvent(e);
}
// "F12" key
if (event.keyCode == 123) {
disabledEvent(e);
}
}, false);
function disabledEvent(e){
if (e.stopPropagation){
e.stopPropagation();
} else if (window.event){
window.event.cancelBubble = true;
}
e.preventDefault();
return false;
}
};
</script>
<!--
ahaha sup bbg
-->
<body class="">
<button id="themeButton">
<i id="themeIcon" icon-name="moon"></i>
</button>
<center>
<div id="tasks-wrap">
<h1 id="headh1">Tasks</h1>
<div id="greetings"></div>
<div class="weatherBlock">
<div class="date">
<div id="month"></div>
<div id="day"></div>
</div>
<div class="timeBlock">
<div class="clock">
<div id="hour"></div>
<div id="separator"></div>
<div id="minutes"></div>
</div>
</div>
</div>
</div>
<p align="right" style="position:absolute; bottom:0px; left:0px;">Created By <a href="https://github.com/justanediot">dumbass</a></p>
<form id="tasks-add">
<input type="text" id="tasks-item" placeholder="Add a new task" autocomplete="off" autofocus required />
<input type="submit" id="tasks-save" value="✚"/>
</form><br>
<div id="tasks-del">
<input type="button" value="Delete All Tasks" id="tasks-delall"/>
<input type="button" value="Delete Completed Tasks" id="tasks-delcom"/>
</div><br><br><br><br><br>
<div id="tasks-list"></div>
</div>
<div align="right" style="position:absolute; top: 20px; left:20px;" class="weather">
<div class="weatherIcon">
<img src="assets/icons/OneDark/unknown.png" />
</div>
<div class="weatherValue">
<p>- °<span class="g">c</span></p>
</div>
<!-- <div class="weatherDescription">
<p></p>
-->
</div>
</div>
</center>
<!-- Date and Weather -->
<!-- Config -->
<script src="config.js"></script>
<!-- Scripts -->
<script src="assets/js/layout.js"></script>
<script src="assets/js/time.js"></script>
<script src="assets/js/greeting.js"></script>
<script src="assets/js/weather.js"></script>
<script src="assets/js/theme.js"></script>
<script src="assets/js/title.js"></script>
<!-- Generators -->
<script src="assets/js/buttons.js"></script>
<script src="assets/js/lists.js"></script>
<!-- Icons -->
<script>
lucide.createIcons();
</script>
</body>
<script>
window.onoffline = function() {
alert('You are now offline please connect to internet to save changes if you choose to continue offline please click ok');
}
var todo = {
data: [],
// (A) LOAD DATA FROM LOCAL STORAGE INTO TODO.DATA
load: function () {
// (A1) INIT LOCALSTORAGE
if (localStorage.list == undefined) {
localStorage.list = "[]";
}
// (A2) DECODE PREVIOUS SESSION INTO TODO.DATA
// todo.data is an array with format of:
// [0] = Task
// [1] = Status : 0 not done, 1 completed, 2 cancelled
todo.data = JSON.parse(localStorage.list);
todo.list();
},
// (B) SAVE CURRENT DATA INTO LOCAL STORAGE
save: function () {
localStorage.list = JSON.stringify(todo.data);
todo.list();
},
// (C) DRAW TODO HTML
list: function () {
// (C1) CLEAR THE OLD LIST
var container = document.getElementById("todo-list");
container.innerHTML = "";
// (C2) BUILD LIST
if (todo.data.length > 0) {
var row = "", el = "";
for (var key in todo.data) {
// Item row
row = document.createElement("div");
row.classList.add("todo-row");
row.dataset.id = key;
// Item text
el = document.createElement("div");
el.classList.add("todo-item");
if (todo.data[key][1] == 1) {
el.classList.add("done");
}
if (todo.data[key][1] == 2) {
el.classList.add("cx");
}
el.innerHTML = todo.data[key][0];
row.appendChild(el);
// Cancel button
el = document.createElement("input");
el.setAttribute("type", "button");
el.value = "\u2716";
el.classList.add("todo-cx");
el.addEventListener("click", function () {
todo.status(this, 2);
});
row.appendChild(el);
// OK button
el = document.createElement("input");
el.setAttribute("type", "button");
el.value = "\u2714";
el.classList.add("todo-ok");
el.addEventListener("click", function () {
todo.status(this, 1);
});
row.appendChild(el);
// Add row to list
container.appendChild(row);
}
}
},
// (D) ADD NEW TODO ITEM
add: function () {
let item = document.getElementById("todo-item");
todo.data.push([item.value, 0]);
item.value = "";
todo.save();
},
// (E) UPDATE TODO ITEM STATUS
status: function (el, stat) {
todo.data[el.parentElement.dataset.id][1] = stat;
todo.save();
},
// (F) DELETE ITEM(S)
del: function (type) { if (confirm("Delete tasks?")) {
// (F1) DELETE ALL
if (type == 0) {
todo.data = [];
todo.save();
}
// (F2) DELETE ONLY COMPLETED TASKS
else {
todo.data = todo.data.filter(row => row[1]==0);
todo.save();
}
}}
};
// (G) PAGE INIT
window.addEventListener("load", function () {
document.getElementById("todo-delall").addEventListener("click", function () {
todo.del(0);
});
document.getElementById("todo-delcom").addEventListener("click", function () {
todo.del(1);
});
document.getElementById("todo-add").addEventListener("submit", function (evt) {
evt.preventDefault();
todo.add();
});
todo.load();
});
</script>
</html>