Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
78 lines (68 loc) · 1.93 KB
/
Copy pathscript.js
File metadata and controls
78 lines (68 loc) · 1.93 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
// Subject Management
function addSubject() {
const input = document.getElementById("subjectInput");
const subject = input.value.trim();
if (subject) {
const li = document.createElement("li");
li.textContent = subject;
const delBtn = document.createElement("button");
delBtn.textContent = "❌";
delBtn.onclick = () => li.remove();
li.appendChild(delBtn);
document.getElementById("subjectList").appendChild(li);
input.value = "";
}
}
// Pomodoro Timer
let timer;
let timeLeft = 25 * 60;
function updateTimerDisplay() {
const minutes = Math.floor(timeLeft / 60);
const seconds = timeLeft % 60;
document.getElementById("timer").textContent =
`${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
}
function startTimer() {
if (!timer) {
timer = setInterval(() => {
if (timeLeft > 0) {
timeLeft--;
updateTimerDisplay();
} else {
clearInterval(timer);
timer = null;
alert("Time's up!");
}
}, 1000);
}
}
function resetTimer() {
clearInterval(timer);
timer = null;
timeLeft = 25 * 60;
updateTimerDisplay();
}
// Weekly Schedule Grid
window.onload = function () {
const days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
const grid = document.getElementById("scheduleGrid");
if (grid) {
days.forEach(day => {
const cell = document.createElement("div");
cell.classList.add("day-cell");
cell.innerHTML = `<strong>${day}</strong><br><span class="editable">Click to add subject</span>`;
// ✅ Add click behavior
cell.onclick = () => {
const subject = prompt(`Enter subject for ${day}:`);
if (subject) {
cell.querySelector(".editable").textContent = subject;
}
};
grid.appendChild(cell);
});
}
};
// Theme Toggle
document.getElementById("themeToggle").onclick = () => {
document.body.classList.toggle("dark-mode");
};