-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
52 lines (42 loc) · 1.78 KB
/
index.js
File metadata and controls
52 lines (42 loc) · 1.78 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
function switchTab(tabId) {
document.querySelectorAll(".tab-content").forEach(tab => tab.classList.remove("active"));
document.querySelectorAll(".tab-button").forEach(btn => btn.classList.remove("active"));
document.getElementById(tabId).classList.add("active");
document.querySelector(`[data-tab="${tabId}"]`).classList.add("active");
}
document.addEventListener("DOMContentLoaded", () => {
const searchInput = document.getElementById("searchInput");
if (searchInput) {
searchInput.addEventListener("keydown", event => {
if (event.key === "Enter") {
const query = searchInput.value.toLowerCase();
const methods = document.querySelectorAll(".method-name");
for (const method of methods) {
const text = method.textContent.toLowerCase();
if (text.toLowerCase().includes(query)) {
method.scrollIntoView({ behavior: "smooth", block: "center" });
method.classList.add("highlight");
setTimeout(() => method.classList.remove("highlight"), 800);
break;
}
}
}
});
}
document.querySelectorAll('a[data-target-tab]').forEach(link => {
link.addEventListener("click", function (e) {
e.preventDefault();
const tabId = this.getAttribute("data-target-tab");
const anchor = this.getAttribute("href");
switchTab(tabId);
setTimeout(() => {
const target = document.querySelector(anchor);
if (target) {
target.scrollIntoView({ behavior: "smooth", block: "center" });
target.classList.add("highlight");
setTimeout(() => target.classList.remove("highlight"), 800);
}
}, 50);
});
});
});