-
Notifications
You must be signed in to change notification settings - Fork 5
/
mainpage.js
161 lines (146 loc) · 5.55 KB
/
mainpage.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
let imgs = {
1: "/final_project/anime img/wp11068436-naruto-4k-ultra-hd-pc-wallpapers.jpg",
2: "/final_project/anime img/aot.jpg",
3: "/final_project/anime img/hikyu.png",
};
let title = {
1: "/final_project/title_card/naruto-37656.png",
2: "/final_project/title_card/kindpng_4991300.png",
3: "/final_project/title_card/Haikyuu_Logo_PNG(4).png",
};
var about = {
1: "Naruto is a beloved Japanese manga and anime series created by Masashi Kishimoto, following Naruto Uzumaki, a young ninja with dreams of becoming the strongest in his village.",
2: "Attack on Titan is a popular Japanese manga and anime series created by Hajime Isayama. It revolves around a world where humanity resides within enormous walled cities to protect themselves from gigantic humanoid creatures known as Titans.",
3: '"Haikyu!!" is a Japanese manga and anime series created by Haruichi Furudate, focusing on high school volleyball. It follows Shoyo Hinata, a determined and short-statured player inspired by a legendary player known as the "Little Giant".',
};
var generes = {
1: "Sub | Dub : Adventure,Action",
2: "Sub | Dub : Adventure,Action,Fantasy",
3: "Sub | Dub : Sports",
};
var anime_img = document.getElementById("img-1");
var anime_title = document.getElementById("title-1");
var description = document.querySelector(".about-title");
var genere = document.querySelector(".genere");
var current_index = 1;
var timeout;
function updateContent() {
timeout = setTimeout(function () {
current_index = (current_index % 3) + 1;
anime_img.src = imgs[current_index];
anime_title.src = title[current_index];
genere.innerHTML = generes[current_index];
description.innerHTML = about[current_index];
updateContent();
}, 5000);
}
updateContent();
var left_arrow = document.getElementById("left-arrow");
var right_arrow = document.getElementById("right-arrow");
function right_arrows() {
clearTimeout(timeout);
current_index = (current_index % 3) + 1;
anime_img.src = imgs[current_index];
anime_title.src = title[current_index];
genere.innerHTML = generes[current_index];
description.innerHTML = about[current_index];
updateContent();
}
function left_arrows() {
clearTimeout(timeout);
current_index = ((current_index - 2 + 3) % 3) + 1;
anime_img.src = imgs[current_index];
anime_title.src = title[current_index];
genere.innerHTML = generes[current_index];
description.innerHTML = about[current_index];
updateContent();
}
function updateindex(index) {
clearTimeout(timeout);
current_index = index;
anime_img.src = imgs[current_index];
anime_title.src = title[current_index];
genere.innerHTML = generes[current_index];
description.innerHTML = about[current_index];
updateContent();
}
// ARROW SCROLL
var scroll_img = {
1: "/final_project/anime_card/bluelock.jpg",
2: "/final_project/anime_card/dr.stone.jpg",
3: "/final_project/anime_card/jujutusu.jpg",
4: "/final_project/anime_card/peakpx.jpg",
5: "/final_project/anime_card/my hero acc.jpg",
};
var image_index = 0;
//RIGHT ARROW
var more_images = document.querySelector(".img-container");
var arrow1 = document.querySelector("#right-arrow1");
arrow1.addEventListener("click", function () {
image_index++;
var create_img = document.createElement("img");
create_img.src = scroll_img[image_index];
if (image_index >= 5) {
image_index = 0;
}
create_img.classList.add("image");
if (more_images.children.length > 0) {
var firstImg = more_images.children[0];
more_images.removeChild(firstImg);
}
more_images.appendChild(create_img);
more_images.scrollLeft += create_img.offsetWidth;
more_images.style.transform = `translateX(-${
more_images.scrollLeft + create_img.offsetWidth
}px)`;
});
var more_images1 = document.querySelector(".img-container1");
var arrow2 = document.querySelector("#right-arrow2");
arrow2.addEventListener("click", function () {
image_index++;
var create_img = document.createElement("img");
create_img.src = scroll_img[image_index];
if (image_index == 5) {
image_index = 0;
}
create_img.classList.add("image");
if (more_images1.children.length > 0) {
var firstImg1 = more_images1.children[0];
more_images1.removeChild(firstImg1);
}
more_images1.appendChild(create_img);
more_images1.scrollLeft += create_img.offsetWidth;
});
//LEFT ARROW
var arrow2 = document.querySelector("#left-arrow1");
arrow2.addEventListener("click", function () {
image_index--;
if (image_index < 1) {
image_index = 5;
}
var create_img = document.createElement("img");
create_img.src = scroll_img[image_index];
create_img.classList.add("image");
if (more_images.children.length > 0) {
var lastImg = more_images.children[more_images.children.length - 1];
more_images.removeChild(lastImg);
}
more_images.insertBefore(create_img, more_images.firstChild);
more_images.scrollLeft -= create_img.offsetWidth;
});
var arrow3 = document.querySelector("#left-arrow2");
arrow3.addEventListener("click", function () {
image_index--;
if (image_index < 1) {
image_index = 5;
}
var create_img = document.createElement("img");
create_img.src = scroll_img[image_index];
create_img.classList.add("image");
if (more_images1.children.length > 0) {
var lastImg = more_images1.children[more_images1.children.length - 1];
more_images1.removeChild(lastImg);
}
more_images1.insertBefore(create_img, more_images1.firstChild);
more_images1.scrollLeft -= create_img.offsetWidth;
});