-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathsample.html
221 lines (196 loc) · 5.7 KB
/
sample.html
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anime Watching Page</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
:root {
--primary-bg: #121212;
--secondary-bg: #1e1e1e;
--accent-color: #7354e7;
--text-color: #ffffff;
--hover-color: #333333;
--odd-bg: #1e1e1e;
--even-bg: #2a2a2a;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Poppins", Arial, sans-serif;
background-color: var(--primary-bg);
color: var(--text-color);
display: flex;
justify-content: center;
align-items: flex-start;
min-height: 100vh;
padding: 20px;
}
#container {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
max-width: 800px;
}
.iframe-container {
width: 100%;
padding-top: 56.25%;
position: relative;
border-radius: 5px;
margin-bottom: 20px;
overflow: hidden;
}
iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}
.search-container {
width: 100%;
margin-bottom: 20px;
}
.search-container input {
width: 100%;
padding: 10px;
border: 1px solid #333;
border-radius: 5px;
background-color: #1e1e1e;
color: var(--text-color);
font-size: 16px;
}
.square-container {
width: 100%;
padding: 20px;
background-color: var(--secondary-bg);
border-radius: 5px;
display: flex;
flex-direction: column;
gap: 20px;
}
.episodes-number-only {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
gap: 10px;
}
.episode-number {
display: flex;
justify-content: center;
align-items: center;
background-color: var(--accent-color);
color: var(--text-color);
font-weight: bold;
font-size: 14px;
width: 50px;
height: 50px;
cursor: pointer;
transition: all 0.2s ease;
}
.episode-number:hover {
background-color: var(--hover-color);
}
.episodes-title {
display: flex;
flex-direction: column;
gap: 5px;
}
.episode-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 15px;
background-color: var(--odd-bg);
color: var(--text-color);
cursor: pointer;
border-left: 4px solid transparent;
}
.episode-item:nth-child(even) {
background-color: var(--even-bg);
}
.episode-item.active {
border-left: 4px solid var(--accent-color);
}
.episode-item:hover {
background-color: var(--hover-color);
}
.episode-number-text {
font-weight: bold;
margin-right: 10px;
}
.episode-title {
flex-grow: 1;
text-align: right;
}
</style>
</head>
<body>
<div id="container">
<div class="iframe-container">
<iframe id="animeIframe" src="about:blank" title="Anime Viewer"></iframe>
</div>
<div class="search-container">
<input type="text" id="search" placeholder="Search episodes by number or title">
</div>
<div class="square-container">
<div class="episodes-number-only" id="episodesNumberOnly"></div>
<div class="episodes-title" id="episodesWithTitle"></div>
</div>
</div>
<script>
// Extract anime ID from URL
const urlParams = new URLSearchParams(window.location.search);
const animeId = urlParams.get("id");
if (!animeId) {
alert("Anime ID is missing from the URL!");
throw new Error("Anime ID is required.");
}
const apiUrl = `https://aniwatch-api-net.vercel.app/api/v2/hianime/anime/${animeId}/episodes`;
// Fetch and render episodes
fetch(apiUrl)
.then(response => response.json())
.then(data => {
if (data.success) {
const episodes = data.data.episodes;
const numberOnlyContainer = document.getElementById('episodesNumberOnly');
const titleContainer = document.getElementById('episodesWithTitle');
episodes.forEach((episode, index) => {
// Render episode number only
const numberOnlyDiv = document.createElement('div');
numberOnlyDiv.className = 'episode-number';
numberOnlyDiv.textContent = episode.number;
numberOnlyDiv.onclick = () => loadEpisode(episode.episodeId);
numberOnlyContainer.appendChild(numberOnlyDiv);
// Render episode title and number
const titleDiv = document.createElement('div');
titleDiv.className = 'episode-item';
titleDiv.innerHTML = `
<span class="episode-number-text">${episode.number}</span>
<span class="episode-title">${episode.title}</span>
`;
titleDiv.onclick = () => {
loadEpisode(episode.episodeId);
document.querySelectorAll('.episode-item').forEach(item => item.classList.remove('active'));
titleDiv.classList.add('active');
};
titleContainer.appendChild(titleDiv);
});
} else {
console.error("Failed to fetch episodes.");
}
})
.catch(error => console.error("Error fetching episodes:", error));
// Load episode in iframe
function loadEpisode(episodeId) {
const iframe = document.getElementById('animeIframe');
iframe.src = `./player.html?id=${episodeId}`;
}
</script>
</body>
</html>