-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
56 lines (47 loc) · 1.47 KB
/
script.js
File metadata and controls
56 lines (47 loc) · 1.47 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
const notices = [
{ title: "Math Exam on Friday", category: "exam" },
{ title: "College Fest Tomorrow", category: "event" },
{ title: "Library Timing Update", category: "general" }
];
function goTo(page) {
// hide all pages
document.querySelectorAll(".page").forEach(p => {
p.classList.add("hidden");
});
// show selected page
const target = document.getElementById(page);
if (target) {
target.classList.remove("hidden");
}
// render notices when opening notices page
if (page === "notices") {
renderNotices();
}
// scroll to section
target?.scrollIntoView({ behavior: "smooth" });
}
function generateQR() {
const file = document.getElementById("fileInput").files[0];
if (!file) {
alert("Select a file first");
return;
}
const url = URL.createObjectURL(file);
const qrUrl =
"https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=" +
encodeURIComponent(url);
document.getElementById("qrResult").innerHTML =
`<img src="${qrUrl}" alt="QR Code" />`;
}
function renderNotices() {
const q = document.getElementById("search").value.toLowerCase();
const c = document.getElementById("category").value;
const list = document.getElementById("noticeList");
list.innerHTML = notices
.filter(n =>
(c === "all" || n.category === c) &&
n.title.toLowerCase().includes(q)
)
.map(n => `<div class="notice">${n.title}</div>`)
.join("");
}