-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplanner.html
More file actions
488 lines (433 loc) · 19.3 KB
/
Copy pathplanner.html
File metadata and controls
488 lines (433 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="./db.js"></script>
<title>ShareHive - Planner</title>
<style>
/* --- Base & Theme (Unchanged) --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
transition: background-color 0.3s, color 0.3s;
}
:root {
--bg-color: #f9f9f9;
--text-color: #222;
--primary-color: #0077ff;
--sidebar-bg: #ffffff;
--card-bg: #ffffff;
--border-color: #e0e0e0;
--shadow-color: rgba(0,0,0,0.05);
--priority-high: #f44336;
--priority-medium: #ff9800;
--priority-low: #4caf50;
}
body.dark {
--bg-color: #1e1e1e;
--text-color: #f0f0f0;
--sidebar-bg: #2c2c2c;
--card-bg: #333333;
--border-color: #444;
--shadow-color: rgba(0,0,0,0.2);
}
/* --- Navbar & Sidebar (Unchanged) --- */
.navbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; background: var(--primary-color); color: white; }
.navbar h1 { font-size: 20px; }
.toggle-btn { background: white; border: none; color: var(--primary-color); padding: 5px 10px; border-radius: 5px; cursor: pointer; font-weight: bold; }
.container { display: flex; height: calc(100vh - 50px); }
.sidebar { width: 220px; background: var(--sidebar-bg); padding: 20px; overflow-y: auto; border-right: 1px solid var(--border-color); }
.sidebar h2 { font-size: 16px; margin-bottom: 10px; }
.sidebar a { display: block; text-decoration: none; color: var(--text-color); padding: 8px 10px; border-radius: 5px; margin-bottom: 5px; }
.sidebar a:hover { background: var(--primary-color); color: white; }
/* --- Main Content Area (Improved) --- */
.main { flex: 1; padding: 20px; overflow-y: auto; }
.main-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px;}
.main-header h2 { margin: 0; font-size: 24px; }
.add-task-btn {
padding: 10px 20px; border: none; background: var(--primary-color);
color: white; border-radius: 8px; cursor: pointer; font-weight: bold;
font-size: 16px; transition: background-color 0.2s;
}
.add-task-btn:hover { background-color: #005fcc; }
.filters-and-search { display: flex; gap: 15px; margin-bottom: 20px; align-items: center; }
.search-box { flex-grow: 1; }
.search-box input { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-color); }
.filter-btn { padding: 8px 12px; border: 1px solid var(--border-color); background: transparent; color: var(--text-color); border-radius: 8px; cursor: pointer; }
.filter-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }
/* --- Task Groups & Cards (New & Improved) --- */
.task-group h3 { font-size: 18px; margin-top: 25px; margin-bottom: 10px; padding-bottom: 5px; border-bottom: 1px solid var(--border-color); }
.tasks-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; }
.task {
background: var(--card-bg); padding: 15px; border-radius: 10px;
box-shadow: 0 4px 12px var(--shadow-color);
border-left: 5px solid transparent;
transition: transform 0.2s, box-shadow 0.2s;
display: flex; flex-direction: column;
}
.task:hover { transform: translateY(-3px); box-shadow: 0 6px 16px var(--shadow-color); }
/* Priority Borders */
.task.priority-high { border-left-color: var(--priority-high); }
.task.priority-medium { border-left-color: var(--priority-medium); }
.task.priority-low { border-left-color: var(--priority-low); }
.task-header { display: flex; align-items: flex-start; gap: 10px; }
.task-header input[type="checkbox"] { margin-top: 4px; width: 18px; height: 18px; cursor: pointer; }
.task-header h4 { font-size: 16px; flex-grow: 1; line-height: 1.4; }
.task-body { margin: 10px 0 15px 28px; font-size: 14px; color: #666; flex-grow: 1; }
body.dark .task-body { color: #bbb; }
.task.completed { opacity: 0.6; }
.task.completed h4, .task.completed .task-body { text-decoration: line-through; }
.task-footer { display: flex; justify-content: space-between; align-items: center; margin-left: 28px;}
.task-date { font-size: 12px; padding: 3px 8px; border-radius: 12px; background-color: #eee; color: #555; }
body.dark .task-date { background-color: #444; color: #ccc; }
.task-date.overdue { background-color: var(--priority-high); color: white; }
.task-date.today { background-color: var(--priority-medium); color: white; }
.actions button { background: none; border: none; cursor: pointer; font-size: 18px; padding: 5px; color: #888; }
body.dark .actions button { color: #aaa; }
/* --- Modal (New) --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; display: none; justify-content: center; align-items: center; }
.modal {
background: var(--bg-color); padding: 25px; border-radius: 12px; width: 90%; max-width: 500px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { margin: 0; }
.modal-header .close-btn { font-size: 24px; background: none; border: none; cursor: pointer; color: var(--text-color); }
.form { display: flex; flex-direction: column; gap: 15px; }
.form input, .form textarea, .form select {
width: 100%; padding: 12px; font-size: 14px;
border: 1px solid var(--border-color); border-radius: 8px;
background: var(--card-bg); color: var(--text-color);
}
.form textarea { min-height: 100px; resize: vertical; }
.form button {
padding: 12px; border: none; background: var(--primary-color);
color: white; border-radius: 8px; cursor: pointer; font-weight: bold;
font-size: 16px;
}
</style>
</head>
<body>
<!-- Navbar -->
<div class="navbar">
<h1>🐝 ShareHive - Planner</h1>
<button class="toggle-btn" onclick="toggleTheme()">🌙</button>
</div>
<div class="container">
<!-- Sidebar -->
<div class="sidebar">
<h2>Menu</h2>
<a href="index.html">🏠 Dashboard</a>
<a href="notes.html">📝 Notes</a>
<a href="bookmarks.html">🔖 Bookmarks</a>
<a href="videos.html">🎬 Video Links</a>
<a href="expense.html">💰 Expense Tracker</a>
<a href="planner.html"><b>📅 Planner</b></a>
<a href="uploads.html">📂 Upload Files</a>
<a href="projects.html">📌 Projects</a>
<a href="watchlist.html">🎥 Watchlist</a>
<a href="courses.html">📚 Courses</a>
<a href="profile.html">👤 Profile</a>
<a href="settings.html">⚙️ Settings</a>
<hr>
<a href="about.html">ℹ️ About</a>
<a href="help.html">❓ Help</a>
<a href="faq.html">❔ FAQ</a>
<a href="blog.html">📰 Blog</a>
<a href="contact.html">✉️ Contact</a>
<a href="join.html">🤝 Join Us</a>
<a href="report.html">🐞 Report</a>
<a href="privacy.html">📜 Privacy & Policy</a>
<a href="community.html">🌍 Community</a>
</div>
<!-- Main Content -->
<div class="main">
<div class="main-header">
<h2>Your Planner</h2>
<button class="add-task-btn" id="addTaskBtn">➕ Add New Task</button>
</div>
<div class="filters-and-search">
<div class="search-box">
<input type="text" id="search" placeholder="Search tasks by title or description...">
</div>
<div>
<button class="filter-btn active" data-filter="all">All</button>
<button class="filter-btn" data-filter="pending">Pending</button>
<button class="filter-btn" data-filter="completed">Completed</button>
</div>
</div>
<div id="planner-content">
<!-- Task groups will be dynamically inserted here -->
</div>
</div>
</div>
<!-- Add/Edit Task Modal -->
<div class="modal-overlay" id="taskModal">
<div class="modal">
<div class="modal-header">
<h2 id="modalTitle">Add New Task</h2>
<button class="close-btn" id="closeModalBtn">×</button>
</div>
<div class="form">
<input type="text" id="title" placeholder="Task title (e.g., Finish project report)">
<textarea id="description" placeholder="Task description..."></textarea>
<input type="date" id="date">
<select id="priority">
<option value="low">Low Priority</option>
<option value="medium" selected>Medium Priority</option>
<option value="high">High Priority</option>
</select>
<button id="saveBtn">Save Task</button>
</div>
</div>
</div>
<script>
// 🌙 Dark Mode
const toggleBtn = document.querySelector('.toggle-btn');
function toggleTheme() {
document.body.classList.toggle("dark");
const isDark = document.body.classList.contains("dark");
localStorage.setItem("theme", isDark ? "dark" : "light");
toggleBtn.textContent = isDark ? '☀️' : '🌙';
}
if (localStorage.getItem("theme") === "dark") {
document.body.classList.add("dark");
toggleBtn.textContent = '☀️';
}
// 📦 IndexedDB (v21 unified)
let db;
const stores = ["notes","bookmarks","videos","todos","expenses","planner","wiki","uploads","projects","watchlist","courses","profile","community"];
const request = indexedDB.open("ShareHiveDB", 22);
request.onupgradeneeded = e => {
db = e.target.result;
if (!db.objectStoreNames.contains("planner")) {
// Add `completed` and `priority` fields
db.createObjectStore("planner", { keyPath: "id", autoIncrement: true });
}
};
request.onsuccess = e => {
db = e.target.result;
displayTasks();
};
request.onerror = e => console.error("DB error:", e.target.error);
// --- Modal Handling ---
const modal = document.getElementById('taskModal');
const addTaskBtn = document.getElementById('addTaskBtn');
const closeModalBtn = document.getElementById('closeModalBtn');
const saveBtn = document.getElementById('saveBtn');
const modalTitle = document.getElementById('modalTitle');
const form = {
title: document.getElementById('title'),
description: document.getElementById('description'),
date: document.getElementById('date'),
priority: document.getElementById('priority'),
};
function openModalForNew() {
modalTitle.textContent = 'Add New Task';
saveBtn.textContent = 'Save Task';
saveBtn.removeAttribute('data-edit');
form.title.value = '';
form.description.value = '';
form.date.value = '';
form.priority.value = 'medium';
modal.style.display = 'flex';
}
function openModalForEdit(task) {
modalTitle.textContent = 'Edit Task';
saveBtn.textContent = 'Update Task';
saveBtn.setAttribute('data-edit', task.id);
form.title.value = task.title;
form.description.value = task.description;
form.date.value = task.date;
form.priority.value = task.priority || 'medium';
modal.style.display = 'flex';
}
function closeModal() {
modal.style.display = 'none';
}
addTaskBtn.onclick = openModalForNew;
closeModalBtn.onclick = closeModal;
modal.onclick = (e) => {
if (e.target === modal) closeModal();
};
// --- CRUD Operations ---
saveBtn.onclick = () => {
const title = form.title.value.trim();
if (!title) {
alert("Title is required.");
return;
}
const editId = saveBtn.getAttribute("data-edit");
const tx = db.transaction("planner", "readwrite");
const store = tx.objectStore("planner");
const taskData = {
title: title,
description: form.description.value.trim(),
date: form.date.value,
priority: form.priority.value,
};
let operation;
if (editId) {
// For updates, we need to fetch the existing task to preserve its `completed` state
operation = store.get(Number(editId));
operation.onsuccess = () => {
const existingTask = operation.result;
const updatedTask = { ...existingTask, ...taskData, id: Number(editId) };
store.put(updatedTask);
}
} else {
// For new tasks, set completed to false
taskData.completed = false;
operation = store.add(taskData);
}
tx.oncomplete = () => {
closeModal();
displayTasks();
};
tx.onerror = (e) => console.error("Save error:", e.target.error);
};
// --- Display Logic ---
let currentFilter = 'all';
function displayTasks() {
const tx = db.transaction("planner", "readonly");
const store = tx.objectStore("planner");
const req = store.getAll();
req.onsuccess = () => {
let tasks = req.result;
// 1. Apply Search
const searchTerm = document.getElementById("search").value.toLowerCase();
if (searchTerm) {
tasks = tasks.filter(t =>
(t.title || "").toLowerCase().includes(searchTerm) ||
(t.description || "").toLowerCase().includes(searchTerm)
);
}
// 2. Apply Filter (Pending/Completed)
if (currentFilter === 'pending') {
tasks = tasks.filter(t => !t.completed);
} else if (currentFilter === 'completed') {
tasks = tasks.filter(t => t.completed);
}
// 3. Group tasks by date
const groupedTasks = { overdue: [], today: [], tomorrow: [], upcoming: [], someday: [] };
const today = new Date();
today.setHours(0,0,0,0);
const tomorrow = new Date(today);
tomorrow.setDate(today.getDate() + 1);
tasks.forEach(task => {
if (!task.date) {
groupedTasks.someday.push(task);
} else {
const taskDate = new Date(task.date + 'T00:00:00'); // Ensure it's treated as local date
taskDate.setHours(0,0,0,0);
if (taskDate < today) groupedTasks.overdue.push(task);
else if (taskDate.getTime() === today.getTime()) groupedTasks.today.push(task);
else if (taskDate.getTime() === tomorrow.getTime()) groupedTasks.tomorrow.push(task);
else groupedTasks.upcoming.push(task);
}
});
const container = document.getElementById('planner-content');
container.innerHTML = ""; // Clear previous content
// 4. Render groups
const groupOrder = [
{ key: 'overdue', title: '🔴 Overdue' },
{ key: 'today', title: '🟠 Today' },
{ key: 'tomorrow', title: '🟡 Tomorrow' },
{ key: 'upcoming', title: '🟢 Upcoming' },
{ key: 'someday', title: '⚪️ Someday' }
];
groupOrder.forEach(group => {
const tasksInGroup = groupedTasks[group.key];
if (tasksInGroup.length > 0) {
// Sort within the group: Pending first, then by priority
tasksInGroup.sort((a, b) => {
if (a.completed !== b.completed) return a.completed - b.completed;
const priorityOrder = { 'high': 0, 'medium': 1, 'low': 2 };
return (priorityOrder[a.priority] || 2) - (priorityOrder[b.priority] || 2);
});
const groupDiv = document.createElement('div');
groupDiv.className = 'task-group';
groupDiv.innerHTML = `<h3>${group.title}</h3>`;
const tasksContainer = document.createElement('div');
tasksContainer.className = 'tasks-container';
tasksInGroup.forEach(task => {
const taskEl = createTaskElement(task);
tasksContainer.appendChild(taskEl);
});
groupDiv.appendChild(tasksContainer);
container.appendChild(groupDiv);
}
});
};
}
function createTaskElement(task) {
const div = document.createElement("div");
div.className = `task priority-${task.priority || 'medium'} ${task.completed ? 'completed' : ''}`;
const [dateClass, dateText] = formatDate(task.date);
div.innerHTML = `
<div class="task-header">
<input type="checkbox" onchange="toggleComplete(${task.id})" ${task.completed ? 'checked' : ''}>
<h4>${task.title}</h4>
</div>
<p class="task-body">${task.description || ''}</p>
<div class="task-footer">
${task.date ? `<span class="task-date ${dateClass}">${dateText}</span>` : '<span></span>'}
<div class="actions">
<button onclick="editTask(${task.id})" title="Edit">✏️</button>
<button onclick="deleteTask(${task.id})" title="Delete">🗑️</button>
</div>
</div>`;
return div;
}
function formatDate(dateString) {
if (!dateString) return ['', 'No Date'];
const today = new Date();
today.setHours(0,0,0,0);
const taskDate = new Date(dateString + 'T00:00:00');
taskDate.setHours(0,0,0,0);
const diffTime = taskDate - today;
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
if (diffDays < 0) return ['overdue', `Overdue by ${Math.abs(diffDays)}d`];
if (diffDays === 0) return ['today', 'Today'];
if (diffDays === 1) return ['', 'Tomorrow'];
return ['', taskDate.toLocaleDateString(undefined, { month: 'short', day: 'numeric' })];
}
// --- Actions ---
function editTask(id) {
const tx = db.transaction("planner", "readonly");
const req = tx.objectStore("planner").get(id);
req.onsuccess = () => openModalForEdit(req.result);
}
function deleteTask(id) {
if (!confirm("Are you sure you want to delete this task?")) return;
const tx = db.transaction("planner", "readwrite");
tx.objectStore("planner").delete(id);
tx.oncomplete = displayTasks;
}
function toggleComplete(id) {
const tx = db.transaction("planner", "readwrite");
const store = tx.objectStore("planner");
const req = store.get(id);
req.onsuccess = () => {
const task = req.result;
task.completed = !task.completed;
store.put(task);
};
tx.oncomplete = displayTasks;
}
// --- Event Listeners ---
document.getElementById("search").addEventListener("input", displayTasks);
document.querySelectorAll('.filter-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
document.querySelector('.filter-btn.active').classList.remove('active');
e.target.classList.add('active');
currentFilter = e.target.getAttribute('data-filter');
displayTasks();
});
});
</script>
</body>
</html>
```