-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
47 lines (38 loc) · 1.35 KB
/
main.js
File metadata and controls
47 lines (38 loc) · 1.35 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
/* -------------------------------------- */
/* Search Bar → Redirect to Projects Page */
/* -------------------------------------- */
const searchInput = document.getElementById("search");
if (searchInput) {
searchInput.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
const query = searchInput.value.trim();
if (query.length > 0) {
window.location.href = `projects.html?search=${encodeURIComponent(query)}`;
}
}
});
}
/* -------------------------------------- */
/* Smooth Scroll for Internal Links */
/* -------------------------------------- */
document.querySelectorAll('a[href^="#"]').forEach(link => {
link.addEventListener("click", (e) => {
const target = document.querySelector(link.getAttribute("href"));
if (target) {
e.preventDefault();
target.scrollIntoView({ behavior: "smooth" });
}
});
});
/* -------------------------------------- */
/* Homepage Commit List Enhancer */
/* -------------------------------------- */
const commitsList = document.querySelector("#commits ul");
function addCommit(message, author) {
if (!commitsList) return;
const li = document.createElement("li");
li.textContent = `"${message}" – ${author}`;
commitsList.prepend(li);
}
// Example commit (remove if not needed)
addCommit("TurtleMod homepage initialized", "ThatBobo");