-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
672 lines (578 loc) · 19.3 KB
/
index.html
File metadata and controls
672 lines (578 loc) · 19.3 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
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TimeTrackly</title>
<!--
TimeTrackly
===========
ARCHITECTURE OVERVIEW:
This is a single-page application (SPA) for local time tracking. It operates
entirely in the browser with a local Node.js server providing data persistence.
DESIGN PHILOSOPHY - Single-User, Local-First:
- No authentication or user accounts
- All data stored locally in JSON files
- Complete privacy (no external network requests except CDNs)
- Survives browser/system restarts via server-side state persistence
MODULAR STRUCTURE:
The application uses ES6 modules for clean separation of concerns:
- app.js: Main orchestrator, initializes everything
- state.js: Centralized state management
- api.js: Server communication layer
- ui.js: DOM manipulation and user interactions
- reports.js: Chart generation and analytics
- utils.js: Shared utility functions
- constants.js: Configuration values
UI ORGANIZATION:
The interface uses collapsible sections to reduce visual clutter:
- Start New Timer: Collapsed by default (indigo background)
- Active Timers: Expanded by default (green background)
- Data Export: Collapsed by default (gray background)
All sections have smooth animations with rotating chevron icons.
NOTES FEATURE:
Each timer includes a Notes button that opens a floating modal dialog:
- Click Notes button on any timer row
- Modal displays "Notes for <Task Name>"
- Explicit Save button required (or cancel/ESC to discard)
- Close with: Save button, Cancel, ESC key, or click backdrop
- Notes persist when saved, included in CSV exports
- Empty notes stored as empty strings
EXTERNAL DEPENDENCIES (CDN):
- Tailwind CSS: Utility-first CSS framework for styling
- Chart.js: Canvas-based charts for reports
- Google Fonts (Inter): Typography
IMPACT OF CHANGES:
- Changing script type from "module" will break ES6 imports
- Removing/changing CDN URLs will break styling or charts
- DOM element IDs are referenced in ui.js - changing them breaks functionality
MAINTAINABILITY:
- Keep this HTML minimal - business logic belongs in JS modules
- New features should add modules, not inline scripts
- DOM structure changes require corresponding updates in ui.js
-->
<!-- Load Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Load Chart.js for Visualization -->
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.3/dist/chart.umd.min.js"></script>
<!-- Material Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Configure Font -->
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
body {
font-family: 'Roboto', sans-serif;
}
/* Subtle shadow for cards */
.elevation-1 {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
/* Google Brand Colors */
.google-blue {
background-color: #4285F4;
}
.google-red {
background-color: #EA4335;
}
.google-yellow {
background-color: #FBBC04;
}
.google-green {
background-color: #34A853;
}
.rotate-90 {
transform: rotate(90deg);
}
.paused-card {
border-left: 4px solid #FBBC04;
/* Google Yellow */
}
.tab-button {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.tab-button.active {
border-bottom: 3px solid #4285F4;
/* Google Blue */
color: #202124;
font-weight: 500;
}
/* Material Design Button States */
.md-button {
transition: background-color 0.2s ease;
text-transform: uppercase;
letter-spacing: 0.5px;
font-weight: 500;
}
/* Material Design Input Field Focus State */
.material-input:focus {
border-width: 2px;
border-color: #4285F4;
box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}
/* Task Row Status Indicator Bar */
.task-row-active {
border-left: 4px solid #4285F4;
/* Google Blue for active tasks */
}
.task-row-paused {
border-left: 4px solid #FBBC04;
/* Google Yellow for paused tasks */
}
/* Button Container - Always Visible */
.action-buttons {
transition: all 0.2s ease-in-out;
}
/* Project Header Hover Effect */
.project-header {
transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.project-header:hover {
background-color: #e5e7eb;
}
/* Enhanced Material Design Focus Ring */
.material-textarea:focus {
border-color: #4285F4;
box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}
/* Compact Task Row Styles */
.task-row {
transition: background-color 0.15s ease;
}
/* STEP 2: Notes container (visible by default) */
.task-notes-container {
background-color: #F9FAFB;
border-top: 1px solid #E5E7EB;
border-bottom: 1px solid #E5E7EB;
}
.task-notes-container textarea {
background-color: white;
border: 1px solid #D1D5DB;
}
.task-notes-container textarea:focus {
background-color: white;
}
/* STEP 3: Notes badge styling */
.notes-badge {
cursor: pointer;
display: inline-block;
}
.notes-badge:hover {
transform: scale(1.2);
transition: transform 0.15s ease;
}
/* STEP 4: Action buttons hover behavior */
.group:hover .action-buttons {
animation: fadeIn 0.15s ease-in;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* STEP 6: Scannability - Duration alignment and visual hierarchy */
.duration {
letter-spacing: 0.5px;
min-width: 5rem;
}
/* Ensure all durations align vertically for quick scanning */
.task-row .duration {
text-align: right;
font-weight: 500;
color: #374151;
}
/* Project header visual distinction */
.project-header {
border-left: 4px solid #4F46E5;
/* Indigo border for strong visual separation */
padding-left: 12px;
}
/* Task row - subtle visual separator */
.task-row {
border-top: 1px solid transparent;
border-bottom: 1px solid transparent;
}
.task-row:hover {
border-bottom-color: #E5E7EB;
}
/* STEP 5: Project-level action buttons */
.project-action-btn {
opacity: 0;
transition: all 0.2s ease;
margin-left: auto;
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 32px;
min-height: 32px;
border-radius: 50%;
background-color: transparent;
color: #666;
border: none;
cursor: pointer;
font-size: 18px;
}
.project-header:hover .project-action-btn {
opacity: 1;
}
.project-action-btn:hover {
background-color: rgba(79, 70, 229, 0.1);
color: #4F46E5;
transform: scale(1.15);
}
/* Modal Styling */
.modal-backdrop {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 40;
animation: fadeIn 0.15s ease-in;
}
.modal-backdrop.active {
display: block;
}
.modal-dialog {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0.95);
background: white;
border-radius: 12px;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
z-index: 50;
max-width: 500px;
width: 90%;
max-height: 70vh;
flex-direction: column;
animation: slideUp 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-dialog.active {
display: flex;
}
@keyframes slideUp {
from {
opacity: 0;
transform: translate(-50%, -45%) scale(0.95);
}
to {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px;
border-bottom: 1px solid #E5E7EB;
flex-shrink: 0;
}
.modal-title {
font-size: 18px;
font-weight: 600;
color: #202124;
margin: 0;
}
.modal-close-btn {
background: none;
border: none;
color: #6B7280;
cursor: pointer;
font-size: 24px;
padding: 0;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 6px;
transition: all 0.2s ease;
}
.modal-close-btn:hover {
background-color: #F3F4F6;
color: #202124;
}
.modal-body {
padding: 16px;
overflow-y: auto;
flex: 1;
}
.modal-body textarea {
width: 100%;
padding: 12px;
border: 1px solid #D1D5DB;
border-radius: 8px;
font-family: inherit;
font-size: 14px;
resize: vertical;
min-height: 150px;
transition: all 0.2s ease;
}
.modal-body textarea:focus {
outline: none;
border-color: #4285F4;
box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}
.modal-footer {
padding: 12px 16px;
border-top: 1px solid #E5E7EB;
display: flex;
justify-content: flex-end;
gap: 8px;
flex-shrink: 0;
}
.modal-footer-btn {
padding: 8px 16px;
border-radius: 6px;
border: none;
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: all 0.2s ease;
}
.modal-footer-btn.primary {
background-color: #4285F4;
color: white;
}
.modal-footer-btn.primary:hover {
background-color: #357ABD;
box-shadow: 0 4px 8px rgba(66, 133, 244, 0.2);
}
.modal-footer-btn.secondary {
background-color: #F3F4F6;
color: #202124;
}
.modal-footer-btn.secondary:hover {
background-color: #E5E7EB;
}
/* Chart Section Collapsible Styles */
.chart-section-header {
transition: background-color 0.2s ease;
}
.chart-section-icon {
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.chart-section-header.collapsed ~ .chart-section-content {
max-height: 0 !important;
padding: 0 !important;
overflow: hidden;
}
.chart-section-header.collapsed .chart-section-icon {
transform: rotate(-90deg);
}
/* Statistics Card Grid */
.stat-card {
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body class="bg-gray-100 min-h-screen p-2 sm:p-4">
<div id="app" class="max-w-5xl mx-auto bg-white elevation-1 rounded-lg p-4 sm:p-6">
<h1 class="text-4xl font-light text-gray-900 mb-8 text-center tracking-tight">Time Trackly</h1>
<!-- Tab Navigation -->
<div class="flex border-b-2 border-gray-200 mb-8">
<button id="tab-tracker" data-tab="tracker"
class="tab-button active flex-1 py-4 text-center text-gray-500 hover:text-gray-900 text-base">
<span class="material-icons align-middle mr-2 text-xl">schedule</span>
Create & Track Tasks
</button>
<button id="tab-reports" data-tab="reports"
class="tab-button flex-1 py-4 text-center text-gray-500 hover:text-gray-900 text-base">
<span class="material-icons align-middle mr-2 text-xl">analytics</span>
Anayze Time Reports
</button>
</div>
<!-- Content Views -->
<div id="view-tracker" class="content-view">
<!-- Data Entry Section -->
<div class="mb-6">
<div id="data-entry-header"
class="flex justify-between items-center p-3 google-blue text-white cursor-pointer rounded-t-lg font-medium mb-0">
<div class="flex items-center space-x-3">
<span id="icon-data-entry" class="material-icons transition-transform duration-200">chevron_right</span>
<span class="text-lg">Start New Timer</span>
</div>
</div>
<div id="data-entry-content"
class="transition-all duration-300 ease-in-out overflow-hidden h-0 border border-t-0 border-gray-200 rounded-b-lg">
<div class="p-4">
<p class="text-sm text-gray-600 mb-4 text-center">Format: <span
class="font-mono bg-white px-2 py-1 rounded-md elevation-1">Project / Task</span></p>
<!-- Smart Activity Input with Datalist -->
<div class="flex flex-col sm:flex-row gap-4 mb-4">
<div class="flex-grow relative">
<span class="material-icons absolute left-3 top-3.5 text-gray-400">work</span>
<input list="activity-suggestions" type="text" id="topic-input"
placeholder="Enter Project / Task or select from suggestions"
class="w-full pl-12 pr-4 py-3 border border-gray-400 rounded-lg text-base focus:outline-none material-input transition">
<datalist id="activity-suggestions"></datalist>
</div>
<button id="start-button"
class="w-full sm:w-40 flex-shrink-0 text-white md-button py-3 px-6 rounded-lg google-blue hover:opacity-90 disabled:bg-gray-400 disabled:cursor-not-allowed">
<span class="material-icons align-middle mr-1 text-xl">play_arrow</span>
Start
</button>
</div>
<p id="error-message" class="text-sm text-red-600 mb-2 min-h-[20px] flex items-center"></p>
</div>
</div>
</div>
<!-- Active Timers Display -->
<div class="mb-6">
<div id="active-timers-header"
class="flex justify-between items-center p-3 google-green text-white cursor-pointer rounded-t-lg font-medium mb-0">
<div class="flex items-center space-x-3">
<span id="icon-active-timers"
class="material-icons rotate-90 transition-transform duration-200">chevron_right</span>
<span class="text-lg">Active Timers (<span id="active-count">0</span>)</span>
</div>
</div>
<div id="active-timers-content"
class="transition-all duration-300 ease-in-out overflow-hidden border border-t-0 border-gray-200 rounded-b-lg"
style="height: auto;">
<div id="active-timers-list" class="space-y-3 p-4 min-h-[100px]">
<div id="no-active-message" class="text-gray-500 text-center py-8 flex flex-col items-center">
<span class="material-icons text-5xl text-gray-300 mb-3">timer_off</span>
<p>No tasks currently running</p>
</div>
</div>
</div>
</div>
<!-- Data Export Section -->
<div class="mt-6">
<div id="data-export-header"
class="flex justify-between items-center p-3 bg-gray-600 text-white cursor-pointer rounded-t-lg font-medium mb-0">
<div class="flex items-center space-x-3">
<span id="icon-data-export" class="material-icons transition-transform duration-200">chevron_right</span>
<span class="text-lg">Data Export</span>
</div>
</div>
<div id="data-export-content"
class="transition-all duration-300 ease-in-out overflow-hidden h-0 border border-t-0 border-gray-200 rounded-b-lg">
<div class="p-4">
<button id="export-button"
class="w-full bg-gray-700 text-white md-button py-3 px-6 rounded-lg hover:bg-gray-800">
<span class="material-icons align-middle mr-2">download</span>
Export All Data (CSV)
</button>
</div>
</div>
</div>
</div>
<div id="view-reports" class="content-view hidden">
<div id="reports-loading" class="text-center text-gray-500 py-12">Loading historical data...</div>
<div id="reports-error" class="text-center text-red-500 py-12 hidden">Error loading reports. Check console.</div>
<div id="reports-content" class="space-y-8 hidden">
<!-- Date Range Selector -->
<div class="flex gap-2 justify-center border-b pb-4">
<button class="date-range-btn active px-4 py-2 text-sm font-medium text-blue-600 border-b-2 border-blue-600" data-range="7">
Last 7 Days
</button>
<button class="date-range-btn px-4 py-2 text-sm font-medium text-gray-600 hover:text-gray-900" data-range="30">
Last 30 Days
</button>
<button class="date-range-btn px-4 py-2 text-sm font-medium text-gray-600 hover:text-gray-900" data-range="365">
All Time
</button>
</div>
<!-- Summary Statistics -->
<div class="grid grid-cols-2 sm:grid-cols-3 gap-4">
<div class="p-4 bg-blue-50 rounded-lg border border-blue-200 stat-card">
<p class="text-xs font-medium text-blue-600 uppercase">This Period</p>
<p class="text-2xl font-bold text-blue-900 mt-2" id="stat-total-hours">0 h</p>
</div>
<div class="p-4 bg-green-50 rounded-lg border border-green-200 stat-card">
<p class="text-xs font-medium text-green-600 uppercase">Daily Avg</p>
<p class="text-2xl font-bold text-green-900 mt-2" id="stat-daily-avg">0 h</p>
</div>
<div class="p-4 bg-purple-50 rounded-lg border border-purple-200 stat-card">
<p class="text-xs font-medium text-purple-600 uppercase">Busiest Day</p>
<p class="text-2xl font-bold text-purple-900 mt-2" id="stat-busiest-day">—</p>
</div>
<div class="p-4 bg-orange-50 rounded-lg border border-orange-200 stat-card">
<p class="text-xs font-medium text-orange-600 uppercase">Top Project</p>
<p class="text-lg font-bold text-orange-900 mt-2 truncate" id="stat-top-project">—</p>
</div>
<div class="p-4 bg-pink-50 rounded-lg border border-pink-200 stat-card">
<p class="text-xs font-medium text-pink-600 uppercase">Today</p>
<p class="text-2xl font-bold text-pink-900 mt-2" id="stat-today-hours">0 h</p>
</div>
<div class="p-4 bg-gray-50 rounded-lg border border-gray-200 stat-card">
<p class="text-xs font-medium text-gray-600 uppercase">Tracking Days</p>
<p class="text-2xl font-bold text-gray-900 mt-2" id="stat-tracking-days">0</p>
</div>
</div>
<!-- Project Distribution Collapsible Section -->
<div class="border rounded-lg overflow-hidden">
<div class="p-4 bg-gray-100 cursor-pointer hover:bg-gray-200 flex items-center justify-between chart-section-header" data-section="project-dist">
<h3 class="text-lg font-semibold text-gray-800">Project Time Distribution</h3>
<span class="material-icons transition-transform duration-200 chart-section-icon">expand_more</span>
</div>
<div class="chart-section-content bg-white p-6 overflow-hidden transition-all duration-300" style="max-height: 500px;">
<div class="flex justify-center h-80">
<canvas id="project-pie-chart"></canvas>
</div>
</div>
</div>
<!-- Daily Trends Collapsible Section -->
<div class="border rounded-lg overflow-hidden">
<div class="p-4 bg-gray-100 cursor-pointer hover:bg-gray-200 flex items-center justify-between chart-section-header" data-section="daily-trends">
<h3 class="text-lg font-semibold text-gray-800">Daily Time Logged</h3>
<span class="material-icons transition-transform duration-200 chart-section-icon">expand_more</span>
</div>
<div class="chart-section-content bg-white p-6 overflow-hidden transition-all duration-300" style="max-height: 500px;">
<div class="h-80">
<canvas id="daily-bar-chart"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Status and ID Display -->
<p class="text-sm text-center text-gray-400 mt-6" id="user-id-display">User ID: Loading...</p>
</div>
<!-- Notes Modal -->
<div id="notes-modal-backdrop" class="modal-backdrop"></div>
<div id="notes-modal" class="modal-dialog">
<div class="modal-header">
<h2 id="notes-modal-title" class="modal-title">Notes</h2>
<button id="notes-modal-close" class="modal-close-btn" aria-label="Close modal">
<span class="material-icons">close</span>
</button>
</div>
<div class="modal-body">
<textarea id="notes-modal-textarea" placeholder="Add notes..."></textarea>
</div>
<div class="modal-footer">
<button id="notes-modal-cancel" class="modal-footer-btn secondary">Cancel</button>
<button id="notes-modal-save" class="modal-footer-btn primary">Save</button>
</div>
</div>
<!--
ES6 Module Entry Point
======================
CRITICAL: type="module" enables ES6 import/export syntax.
Loading app.js kicks off the entire application:
1. Loads all other modules via imports
2. Fetches data from server
3. Initializes UI
4. Sets up event listeners
IMPACT: Removing type="module" or changing src path breaks the entire app.
The server must serve this with proper MIME type (application/javascript).
-->
<script type="module" src="js/app.js"></script>
</body>
</html>