-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
91 lines (77 loc) · 2.99 KB
/
Copy pathpopup.js
File metadata and controls
91 lines (77 loc) · 2.99 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
//load UI for watchlist
document.addEventListener("DOMContentLoaded", () => {
updateUI(); // always reload from storage when popup opens
});
//settings button
document.getElementById("settings-btn").onclick = () => {
chrome.tabs.create( { url: chrome.runtime.getURL("settings.html") } );
};
//registration season
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth();
let season = '';
if (month >= 10 || month <= 4) {
season = 'Spring';
}
else {
season = 'Fall';
}
document.getElementById("season").textContent = `${season} ${year}`;
function updateUI() {
chrome.storage.local.get("watchlist", (data) => {
const container = document.getElementById("watchlistCourses");
container.innerHTML = "";
const watchlist = data.watchlist || [];
watchlist.forEach(course => {
const courseRow = document.createElement("div");
courseRow.className = "courseRow";
courseRow.id = `course-${course.unique}`;
const courseInfo = document.createElement("div");
courseInfo.className = "courseInfo";
const p = document.createElement("p");
p.textContent = `${course.unique} - ${course.instructor}`;
courseInfo.appendChild(p);
courseRow.appendChild(courseInfo);
const sliderBox = document.createElement("div");
sliderBox.className = "sliderBox";
const sliderContainer = document.createElement("div");
sliderContainer.className = "sliderContainer";
const slider = document.createElement("input");
slider.type = "range";
slider.min = 5;
slider.max = 3600;
slider.step = 1;
slider.value = course.interval;
const sliderValueDisplay = document.createElement("span");
sliderValueDisplay.textContent = slider.value + "s";
slider.addEventListener("input", () => {
sliderValueDisplay.textContent = slider.value + "s";
chrome.runtime.sendMessage({
action: "UpdateInterval",
course: course,
interval: parseInt(slider.value)
})
})
sliderContainer.appendChild(slider);
sliderContainer.appendChild(sliderValueDisplay);
sliderBox.appendChild(sliderContainer);
courseRow.appendChild(sliderBox);
container.appendChild(courseRow);
});
});
chrome.storage.local.get("updates", (data) => {
const updates = data.updates || [];
renderUpdates(updates);
});
}
function renderUpdates(updates) {
const updatesBox = document.getElementById("statusUpdates");
if (!updatesBox) return;
updatesBox.innerHTML = "";
updates.forEach(update => {
const row = document.createElement("p");
row.textContent = `${update.unique}: ${update.oldStatus} → ${update.newStatus}`;
updatesBox.appendChild(row);
});
}