-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
64 lines (56 loc) · 1.98 KB
/
script.js
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
document.addEventListener("DOMContentLoaded", function () {
var scrollTarget = document.getElementById("scroll-target");
if (scrollTarget) {
var targetPosition =
scrollTarget.getBoundingClientRect().top + window.scrollY;
window.scrollTo({
top: targetPosition,
behavior: "smooth",
});
}
const navigation = document.querySelector(".navigation");
document.querySelector(".toggle").onclick = function () {
this.classList.toggle("active");
navigation.classList.toggle("active");
};
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
console.log(entry);
if (entry.isIntersecting) {
entry.target.classList.add("show");
} else {
entry.target.classList.remove("show");
}
});
});
const hiddenElements = document.querySelectorAll(".hidden");
hiddenElements.forEach((el) => observer.observe(el));
});
function toggleFooterVisibility() {
var footer = document.getElementById("footer1");
if (footer.style.display === "none" || footer.style.display === "") {
footer.style.opacity = "1";
footer.style.display = "block";
} else {
footer.style.opacity = "0";
setTimeout(() => {
footer.style.display = "none";
}, 300);
}
}
// code for searchbar
const searchInput = document.getElementById("search");
console.log(searchInput);
searchInput.addEventListener("input", (e) => {
const searchValue = e.target.value.toLowerCase();
console.log(searchValue);
const allNames = document.querySelectorAll(".header1");
console.log(allNames[0].innerHTML);
allNames.forEach((name) => {
if (name.innerHTML.toLowerCase().startsWith(searchValue)) {
name.parentElement.style.display = "block";
} else {
name.parentElement.style.display = "none";
}
});
});