-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
139 lines (113 loc) · 4.65 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
document.getElementById("overlay").addEventListener("click", function () {
var videoContainer = document.getElementById("video-container");
videoContainer.innerHTML =
'<iframe src="https://www.youtube.com/embed/m6pTbEz4w3o?autoplay=1" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen style="width: 100%; height: 100%;"></iframe>';
videoContainer.style.display = "flex";
videoContainer.style.justifyContent = "center";
videoContainer.style.alignItems = "center";
videoContainer.style.height = "80vh";
videoContainer.style.position = "fixed";
videoContainer.style.top = "50%";
videoContainer.style.left = "50%";
videoContainer.style.transform = "translate(-50%, -50%)";
var backgroundContainer = document.getElementById("background-container");
backgroundContainer.style.display = "none";
});
document.querySelectorAll(".nav-item").forEach(function (menuItem) {
menuItem.addEventListener("mouseenter", function () {
var dropdown = menuItem.querySelector(".dropdown");
if (dropdown) {
dropdown.style.display = "flex";
}
});
menuItem.addEventListener("mouseleave", function () {
var dropdown = menuItem.querySelector(".dropdown");
if (dropdown) {
dropdown.style.display = "none";
}
});
});
document.querySelectorAll(".dropdown").forEach(function (dropdown) {
dropdown.addEventListener("mouseenter", function () {
this.style.display = "flex";
});
dropdown.addEventListener("mouseleave", function () {
this.style.display = "none";
});
});
document.addEventListener("DOMContentLoaded", function () {
const headerWrapper = document.querySelector(".header-wrapper");
let timeoutId;
headerWrapper.addEventListener("mouseenter", function () {
clearTimeout(timeoutId);
headerWrapper.classList.add("active");
});
headerWrapper.addEventListener("mouseleave", function () {
timeoutId = setTimeout(function () {
headerWrapper.classList.remove("active");
}, 200);
});
});
const mediaItems = [
{
type: "image",
url: "https://img.youtube.com/vi/m6pTbEz4w3o/maxresdefault.jpg",
videoId: "m6pTbEz4w3o",
},
{
type: "image",
url: "https://img.youtube.com/vi/bZPQImItCEg/maxresdefault.jpg",
videoId: "bZPQImItCEg",
},
{
type: "image",
url: "https://img.youtube.com/vi/p6w64hIPloI/maxresdefault.jpg",
videoId: "p6w64hIPloI",
},
];
let currentIndex = 0;
function updatePageInfo() {
const pageInfo = document.getElementById("pageInfo");
pageInfo.textContent = `${currentIndex + 1} / ${mediaItems.length}`;
const prevBtn = document.getElementById("prevBtn");
const nextBtn = document.getElementById("nextBtn");
prevBtn.disabled = currentIndex === 0;
nextBtn.disabled = currentIndex === mediaItems.length - 1;
prevBtn.style.opacity = prevBtn.disabled ? "0.5" : "1";
nextBtn.style.opacity = nextBtn.disabled ? "0.5" : "1";
}
function updateBackground() {
const backgroundContainer = document.getElementById("background-container");
backgroundContainer.style.backgroundImage = `url(${mediaItems[currentIndex].url})`;
updatePageInfo();
}
document.getElementById("prevBtn").addEventListener("click", () => {
currentIndex = (currentIndex - 1 + mediaItems.length) % mediaItems.length;
updateBackground();
});
document.getElementById("nextBtn").addEventListener("click", () => {
currentIndex = (currentIndex + 1) % mediaItems.length;
updateBackground();
});
updateBackground();
function playVideo() {
const videoContainer = document.getElementById("video-container");
videoContainer.innerHTML = `<iframe src="https://www.youtube.com/embed/${mediaItems[currentIndex].videoId}?autoplay=1" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen style="width: 100%; height: 100%;"></iframe>`;
videoContainer.style.display = "flex";
videoContainer.style.justifyContent = "center";
videoContainer.style.alignItems = "center";
videoContainer.style.height = "80vh";
const backgroundContainer = document.getElementById("background-container");
backgroundContainer.style.display = "none";
}
document.getElementById("overlay").addEventListener("click", playVideo);
document.getElementById("logo-link").addEventListener("click", function (e) {
e.preventDefault();
const videoContainer = document.getElementById("video-container");
videoContainer.style.display = "none";
const backgroundContainer = document.getElementById("background-container");
backgroundContainer.style.display = "block";
currentIndex = 0;
updateBackground();
document.getElementById("overlay").style.display = "flex";
});