-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
349 lines (337 loc) · 12.1 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Habit Tracker</title>
<link rel="stylesheet" href="colors.css" />
<link rel="stylesheet" href="style.css" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<script
src="https://kit.fontawesome.com/596af747e3.js"
crossorigin="anonymous"
></script>
</head>
<body>
<h1 class="title">🔥 Habit Tracker</h1>
<div class="container" id="container">
<table class="habit-table">
<thead>
<tr id="cal-days">
<th class="habit-header"></th>
<th class="habit-header"></th>
<!-- Adjusted header for context menu button -->
<th class="cal-day">mo</th>
<th class="cal-day">tu</th>
<th class="cal-day">we</th>
<th class="cal-day">th</th>
<th class="cal-day">fr</th>
<th class="cal-day">sa</th>
<th class="cal-day">su</th>
</tr>
</thead>
<tbody id="habit-list">
<!-- Habit rows will be dynamically added here -->
</tbody>
</table>
<div class="habit-new" id="habit-new" onclick="showPrompt()">+</div>
<div class="button-groups-container">
<!-- Template Buttons Group - Left Side -->
<div class="button-group-wrapper">
<h3 class="button-group-title">Templates</h3>
<div class="button-group template-buttons">
<button id="template-beginner" class="btn template-btn beginner">
<i class="fas fa-leaf"></i>Beginner
</button>
<button id="template-medium" class="btn template-btn medium">
<i class="fas fa-fire"></i>Medium
</button>
<button id="template-advanced" class="btn template-btn advanced">
<i class="fas fa-dragon"></i>Advanced
</button>
<button id="template-nutrition" class="btn template-btn nutrition">
<i class="fas fa-apple-alt"></i>Nutrition
</button>
<button id="template-studying" class="btn template-btn studying">
<i class="fas fa-book"></i>Studying
</button>
<button id="template-sports" class="btn template-btn sports">
<i class="fas fa-futbol"></i>Sports
</button>
</div>
</div>
<!-- Action Buttons Group - Right Side -->
<div class="button-group-wrapper">
<h3 class="button-group-title">Actions</h3>
<div class="button-group action-buttons">
<button id="save-habits" class="btn save-btn">
<i class="fas fa-download"></i>Export
</button>
<button id="import-habits" class="btn import-btn">
<i class="fas fa-upload"></i>Import
</button>
<button id="reset-tracker" class="btn reset-btn">
<i class="fas fa-undo"></i>Reset
</button>
<button id="dark-mode-toggle" class="btn theme-btn">
<i class="fas fa-moon"></i>Theme
</button>
<button id="help-button" class="btn help-btn">
<i class="fas fa-question-circle"></i>Help
</button>
</div>
<input
type="file"
id="file-input"
accept=".json"
style="display: none"
/>
</div>
</div>
<div class="creator">
<div class="credits-container">
<div class="credits-scan"></div>
<div class="credits-text">
<span class="bolt">⚡</span> POWERED BY <span class="bolt">⚡</span
><br />
<strong
><a
href="https://github.com/agepoor"
target="_blank"
rel="noopener"
>AGE P.</a
></strong
>
<br />
<a
href="https://github.com/agepoor/tinytracker"
target="_blank"
rel="noopener"
>View source on GitHub</a
>
</div>
</div>
</div>
</div>
<div class="modal-container" id="habit-prompt-container">
<div class="modal">
<h3>Add New Habit</h3>
<form id="habit-prompt">
<div class="form-control">
<label for="habit-name">Name:</label>
<input type="text" id="habit-name" placeholder="Enter habit name" />
</div>
<div class="form-control">
<label>Days:</label>
<div class="days-picker" id="habit-days">
<div class="day-item">
<input type="checkbox" name="day-0" id="day-0" />
<label for="day-0">Mon</label>
</div>
<div class="day-item">
<input type="checkbox" name="day-1" id="day-1" />
<label for="day-1">Tue</label>
</div>
<div class="day-item">
<input type="checkbox" name="day-2" id="day-2" />
<label for="day-2">Wed</label>
</div>
<div class="day-item">
<input type="checkbox" name="day-3" id="day-3" />
<label for="day-3">Thu</label>
</div>
<div class="day-item">
<input type="checkbox" name="day-4" id="day-4" />
<label for="day-4">Fri</label>
</div>
<div class="day-item">
<input type="checkbox" name="day-5" id="day-5" />
<label for="day-5">Sat</label>
</div>
<div class="day-item">
<input type="checkbox" name="day-6" id="day-6" />
<label for="day-6">Sun</label>
</div>
</div>
</div>
<div class="form-control">
<label>Color:</label>
<div class="color-picker" id="habit-color"></div>
</div>
<div class="modal-buttons">
<button type="button" class="btn close-btn" id="close-prompt">
Cancel
</button>
<button type="button" class="btn save-btn" id="add-habit">
Add Habit
</button>
</div>
</form>
</div>
</div>
<script src="script.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
<script>
var el = document.getElementById("habit-list");
var sortable = new Sortable(el, {
animation: 150,
handle: ".habit-name",
forceFallback: false,
ghostClass: "sortable-ghost",
dragClass: "sortable-drag",
chosenClass: "sortable-chosen",
scroll: true,
scrollSensitivity: 30,
scrollSpeed: 10,
onStart: function (evt) {
document.body.style.cursor = "grabbing";
},
onEnd: function (evt) {
document.body.style.cursor = "default";
const evtTo = evt.to.children;
let newHabitsOrder = [...evtTo].map((i) => i.dataset.hTitle);
let newHabits = newHabitsOrder.map((i) =>
habits.find((item) => item.name == i)
);
habits = newHabits;
updateLocalStorage();
},
});
</script>
<div class="modal-container" id="reset-modal">
<div class="modal">
<h3>Reset Tracker</h3>
<p>Are you sure you want to reset all completed habits to planned?</p>
<div class="modal-buttons">
<button class="btn close-btn" id="cancel-reset">Cancel</button>
<button class="btn reset-btn" id="confirm-reset">Reset</button>
</div>
</div>
</div>
<div class="modal-container" id="template-modal">
<div class="modal">
<h3>Load Template</h3>
<p>
Are you sure you want to load this template? This will replace all
your current habits.
</p>
<div class="modal-buttons">
<button class="btn close-btn" id="cancel-template">Cancel</button>
<button class="btn template-btn" id="confirm-template">
Load Template
</button>
</div>
</div>
</div>
<div class="modal-container" id="help-modal">
<div class="modal">
<h3>Help & Principles</h3>
<p>
Welcome to the Tiny Habit Tracker! This tool helps you track your
habits weekly.
</p>
<h4>📅 Why Weekly Tracking?</h4>
<ul>
<li>Focus on short-term goals for better habit formation</li>
<li>Stay motivated with weekly progress</li>
<li>Make quick adjustments to your routine</li>
</ul>
<strong>Warning:</strong> Don't use this tracker for detailed progress
logging! Include progress tracking within each habit itself. For
example, with fitness:
<ul>
<li><i>Track sets/reps each session</i></li>
<li><i>Note your running times/distances</i></li>
<li><i>Monitor weekly weight changes</i></li>
<li><i>Record energy levels after workouts</i></li>
</ul>
<h4>💡 General Tips on Habit Formation</h4>
<ul>
<li><strong>Start Small:</strong> Begin with manageable habits</li>
<li>
<strong>Be Consistent:</strong> Perform habits at the same time
daily
</li>
<li>
<strong>Track Progress:</strong> Monitor and celebrate small wins
</li>
<li>
<strong>Learn More:</strong> Read books like:
<ul>
<li>"Atomic Habits" by James Clear</li>
<li>"The Power of Habit" by Charles Duhigg</li>
</ul>
</li>
</ul>
<h4>🛠️ How to Use</h4>
<ul>
<li><strong>Add habits:</strong> Click the "+" button</li>
<li><strong>Edit habits:</strong> Click on a habit name</li>
<li>
<strong>Track daily:</strong> Click day cells to mark progress.
Click again on a checked day to unplan it (neither planned nor
finished)
</li>
<li>
<strong>Manage data:</strong>
<ul>
<li>Export habits to save them</li>
<li>Import habits from a file</li>
<li>Reset to clear all progress and start a new week!</li>
</ul>
</li>
</ul>
<h4>✨ Hidden Surprises</h4>
<ul>
<li>
<strong>Complete a habit:</strong> Watch your habit row light up
when you finish all planned days
</li>
<li>
<strong>Perfect week:</strong> Complete all habits for a special
celebration effect
</li>
</ul>
<div class="modal-buttons">
<button class="btn close-btn" id="close-help">Close</button>
</div>
</div>
</div>
<div class="modal-container" id="delete-modal">
<div class="modal">
<h3>Delete Habit</h3>
<p>Are you sure you want to delete this habit?</p>
<div class="modal-buttons">
<button class="btn close-btn" id="cancel-delete">Cancel</button>
<button class="btn reset-btn" id="confirm-delete">Delete</button>
</div>
</div>
</div>
<div id="edit-modal" class="modal-container">
<div class="modal-content">
<h3>Edit Habit</h3>
<form id="edit-form">
<div class="form-control">
<label for="edit-name">Name</label>
<input
type="text"
id="edit-name"
name="edit-name"
placeholder="Enter new name"
/>
</div>
<div class="form-control">
<label>Pick a color</label>
<div id="edit-colors" class="clrs">
<!-- color options to be loaded here -->
</div>
</div>
<div class="form-control btns">
<button id="cancel-edit" class="close-btn btn">Cancel</button>
<button id="save-edit" class="save-btn btn">Save</button>
</div>
</form>
</div>
</div>
</body>
</html>