-
Notifications
You must be signed in to change notification settings - Fork 7
/
search.html
668 lines (590 loc) · 25.1 KB
/
search.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="search.css">
<link rel="stylesheet" href="card.css">
<title>Aniteams-Filter</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap');
</style>
</head>
<body>
<header>
<nav class="navbar">
<div class="container">
<i class="fa-solid fa-bars fa-2x bars"></i>
<h2><span>Aniteams</span></h2>
<input type="search" name="Search" id="search-bar" placeholder="Search">
<a class="nav-links" href="animeindex.html">Home</a>
<a class="nav-links" href="">Subbed Anime</a>
<a class="nav-links" href="">Dubbed Anime</a>
<button class="login" onclick="onFilterButtonClick()">Search</button>
</div>
<div class="menu" id="menu">
<ul class="sidebar">
<button class="closemenu" id="closemenu"> <i class="fa-solid fa-angle-left" fa--1x close></i> Close Menu </button>
<li><a href="animeindex.html">Home</a></li>
<li><a href="">Subbed Anime</a></li>
<li><a href="">Dubbed Anime</a></li>
<li><a href="">Most Popular</a></li>
<li><a href="">TV Series</a></li>
<li><a href="">Specials</a></li>
<li><a href="">Movies</a></li>
<li><a href=""">Top Rated</a></li>
</ul>
</div>
</nav>
<main>
<section> <!-- Filter box Sectiom-->
<div class="category-filter">
<form method="get" id="filter-form">
<input type="hidden" name="keyword" value="">
<div>
<p>Filter</p>
<div class="filter-options">
<div class="filter-item">
<label for="type">Type</label>
<select id="type" name="type">
<option value="all">All</option>
<option value="Movie">Movie</option>
<option value="TV">TV</option>
<option value="ONA">ONA</option>
<option value="OVA">OVA</option>
<option value="Specials">Specials</option>
<option value="Season">Season</option>
</select>
</div>
<div class="filter-item">
<label for="status">Status</label>
<select id="status" name="status">
<option value="all">All</option>
<option value="Current Airing">Current Airing</option>
<option value="Finished Airing">Finished Airing</option>
<option value="Not Yet Aired">Not Yet Aired</option>
<!-- Other options -->
</select>
</div>
<div class="filter-item">
<label for="Rated">Rated</label>
<select id="Rated" name="Rated">
<option value="all">All</option>
<option value="G">G</option>
<option value="PG">PG</option>
<option value="R">R</option>
<option value="R+">R+</option>
<option value="Rx">Rx</option>
<!-- Other options -->
</select>
</div>
<div class="filter-item">
<label for="Season">Season</label>
<select id="Season" name="Season">
<option value="all">All</option>
<option value="Spring">Spring</option>
<option value="Summer">Summer</option>
<option value="Fall">Fall</option>
<option value="Winter">Winter</option>
<option value=""></option>
</select>
</div>
<div class="filter-item">
<label for="Score">Score</label>
<select id="Score" name="Score">
<option value="all">All</option>
<option value="(1)">(1) Disgusting</option>
<option value="(2)">(2) Horrible</option>
<option value="(3)">(3) Very Bad</option>
<option value="(4)">(4) Bad</option>
<option value="(5)">(5) Mid</option>
<option value="(6)">(6) Fine</option>
<option value="(7)">(7) Good</option>
<option value="(8)">(8) Very Good</option>
<option value="(9)">(9) Great</option>
<option value="(10)">(10) Goated</option>
</select>
</div>
<div class="filter-item">
<label for="Language">Language</label>
<select id="Language" name="Language">
<option value="all">All</option>
<option value="SUB">SUB</option>
<option value="DUB">DUB</option>
<option value="SUB & DUB">SUB & DUB</option>
</select>
</div>
<div class="filter-item">
<label for="start-date">Start Date</label>
<select class="start-year" name="Start-date-year">
<option value="Year">Year</option>
</select>
<select class="start-month" name="Start-date-month">
<option value="Month">Month</option>
</select>
<select class="start-day" name="Start-date-day">
<option value="Day">Day</option>
</select>
</div>
<div class="filter-item">
<label for="end-date">End Date</label>
<select class="start-year-2" name="Start-date-year">
<option value="Year">Year</option>
</select>
<select class="start-month-2" name="Start-date-month">
<option value="Month">Month</option>
</select>
<select class="start-day-2" name="Start-date-day">
<option value="Day">Day</option>
</select>
</div>
<div class="filter-item">
<label for="sort">Sort</label>
<select id="sort" name="sort">
<option value=">Default">Default</option>
<option value="Recently Updated">Recently Updated</option>
<option value="Recently Added">Recently Added</option>
<option value="Score">Score</option>
<option value="Named A-Z">Named A-Z</option>
<option value=">Relaease Date">Relaease Date</option>
<option value="Most Watched">Most Watched</option>
</select>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const form = document.getElementById('filter-form'); // Form element
if (!form) {
console.error('Form not found in DOM.');
return;
}
// Event Listener: Update URL parameters whenever a form field changes
form.addEventListener('input', () => {
const formData = new FormData(form); // Collect form data
const queryParams = new URLSearchParams();
// Loop through form data and append valid parameters
for (const [key, value] of formData.entries()) {
if (value !== '' && value !== 'all') { // Ignore empty or default "all" values
queryParams.append(key, value);
console.log(`Captured: ${key} = ${value}`); // Debug log
}
}
// Update the URL without refreshing the page
const baseUrl = window.location.origin + window.location.pathname;
const newUrl = queryParams.toString()
? `${baseUrl}?${queryParams.toString()}`
: baseUrl;
window.history.replaceState({}, '', newUrl); // Update URL
console.log(`Updated URL to: ${newUrl}`); // Debug log
});
// Function: Pre-fill form values from URL on page load
function prefillFormFromURL() {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.toString()) {
console.log('URL parameters detected:', urlParams.toString()); // Debug log
}
// Loop through each form element and set the value
for (const [key, value] of urlParams.entries()) {
const formElement = form.querySelector(`[name="${key}"]`);
if (formElement) {
formElement.value = value; // Set the value from the URL
console.log(`Pre-filling: ${key} = ${value}`); // Debug log
}
}
}
// Execute pre-filling on page load
prefillFormFromURL();
});
</script>
<div class="genre-filter">
<p>Genre</p>
</div>
<div class="ni-list" id="genre-list">
<input type="hidden" id="genre-ids" name="genres" value="1">
<!-- Genre items will be populated here dynamically -->
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
const apiUrl = 'https://aniwatch-api-net.vercel.app/api/v2/hianime/home';
const selectedGenres = new Set();
const genreList = document.getElementById('genre-list');
// Fetch genres from the API
fetch(apiUrl)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log("API Response:", data);
if (data.success && data.data && data.data.genres) {
const genres = data.data.genres;
genres.forEach((genre) => {
const genreItem = document.createElement('div');
genreItem.classList.add('f-genre-item');
genreItem.setAttribute('data-id', genre);
genreItem.textContent = genre;
genreList.appendChild(genreItem);
});
// Load selected genres from URL on page load
loadSelectedGenresFromUrl();
// Add click listeners after genre are loaded
addGenreClickListeners();
} else {
console.error('Invalid API response structure', data);
}
})
.catch(error => {
console.error('Error during fetch:', error);
console.log('Using fallback genres for testing');
const fallbackGenres = ['Action', 'Comedy', 'Drama', 'Fantasy'];
fallbackGenres.forEach((genre) => {
const genreItem = document.createElement('div');
genreItem.classList.add('f-genre-item');
genreItem.setAttribute('data-id', genre);
genreItem.textContent = genre;
genreList.appendChild(genreItem);
});
// Load selected genres from URL on page load
loadSelectedGenresFromUrl();
addGenreClickListeners();
});
function addGenreClickListeners() {
const genreItems = document.querySelectorAll('.f-genre-item');
genreItems.forEach(item => {
item.addEventListener('click', () => {
const genre = item.getAttribute('data-id');
if (selectedGenres.has(genre)) {
selectedGenres.delete(genre);
item.classList.remove('selected');
} else {
selectedGenres.add(genre);
item.classList.add('selected');
}
updateUrlParams(selectedGenres);
});
});
// Add click listener for the Filter button
const filterButton = document.querySelector('.filter-button');
filterButton.addEventListener('click', (event) => {
event.preventDefault(); // Prevent the default form submission
updateUrlParams(selectedGenres); // Ensure genres are updated in URL
// Optionally: Submit form or trigger search logic
// This can be adapted based on your specific needs
});
}
function updateUrlParams(genresSet) {
const url = new URL(window.location.href);
if (genresSet.size > 0) {
url.searchParams.set('genres', Array.from(genresSet).join(',')); // Use join ',' to separate
} else {
url.searchParams.delete('genres');
}
window.history.replaceState(null, '', url);
}
function loadSelectedGenresFromUrl() {
const urlParams = new URLSearchParams(window.location.search);
const genresFromUrl = urlParams.get('genres');
if (genresFromUrl) {
const genresArray = genresFromUrl.split(',');
genresArray.forEach(genre => {
selectedGenres.add(genre.trim());
// Highlight the genres in the UI
const genreItem = Array.from(genreList.children).find(item => item.getAttribute('data-id') === genre.trim());
if (genreItem) {
genreItem.classList.add('selected');
}
});
}
}
});
</script>
<div class="filter-button-con">
<button type="button" class="filter-button" onclick="onFilterButtonClick()">Filter</button>
</div>
<script>document.getElementById('search-bar').addEventListener('keypress', function(event) {
// Check if the Enter key is pressed
if (event.key === 'Enter') {
updateQueryParam(this.value); // Update the query parameter in the URL
}
});
function updateQueryParam(query) {
// Get the current value of the search input
const encodedQuery = encodeURIComponent(query);
// Create a new URL object based on the current URL
const url = new URL(window.location.href);
// Update or add the query parameter
url.searchParams.set('query', encodedQuery);
// Update the URL without reloading the page
window.history.pushState({ path: url.href }, '', url.href);
}
function onFilterButtonClick() {
// Get the value from the search bar
const searchBar = document.getElementById('search-bar');
if (searchBar) {
updateQueryParam(searchBar.value); // Update the query parameter
}
// Call the existing script
onFetchAnimeButtonClick();
}
</script>
</div>
</div>
</form>
</div>
</section>
<div id="loader" class="loading">Loading</div>
<div id="anime-list" class="card-container"></div>
<!------ styles for the loading animations ------>
<style>
.loading {
font-size: 1.5em;
animation: dots 1s steps(5, end) infinite;
}
@keyframes dots {
0%, 20% { content: ''; }
20% { content: '.'; }
40% { content: '..'; }
60% { content: '...'; }
80%, 100% { content: ''; }
}</style>
<script>
apiUrl = "https://aniwatch-api-net.vercel.app/api/v2/hianime/search";
const fetchParamsFromUrl = () => {
const urlParams = new URLSearchParams(window.location.search);
return {
query: urlParams.get('query') || '',
page: urlParams.get('page') || 1,
genres: urlParams.get('genres') || '',
type: urlParams.get('type') || '',
sort: urlParams.get('sort') || '',
season: urlParams.get('season') || '',
sub_or_dub: urlParams.get('language') || 'sub',
status: urlParams.get('status') || '',
rating: urlParams.get('rated') || '',
score: urlParams.get('score') || '',
start_date: `${urlParams.get('start-date-year')}-${urlParams.get('start-date-month')}-${urlParams.get('start-date-day')}`
};
}
const fetchAnimeData = async () => {
const params = fetchParamsFromUrl();
const url = `${apiUrl}?q=${params.query}&page=${params.page}&gen=${params.genres}&type=${params.type}&sort=${params.sort}&season=${params.season}&language=${params.sub_or_dub}&status=${params.status}&rated=${params.rating}&score=${params.score}&start_date=${params.start_date}`;
const loader = document.getElementById('loader');
const animeList = document.getElementById('anime-list');
loader.style.display = 'block';
animeList.innerHTML = ''; // Clear previous results
try {
const response = await fetch(url);
const data = await response.json();
loader.style.display = 'none';
if (data.success && data.data.animes.length > 0) {
data.data.animes.forEach(anime => {
const card = document.createElement('div');
card.className = 'card';
card.innerHTML = `
<div class="poster">
<img src="${anime.poster}" alt="${anime.name} Poster" class="image" />
<a href="details.html?id=${anime.id}" class="overlay">
<img src="play-buttton.png" alt="Play" class="play-button" />
</a>
<div class="info-left">
<div class="btn">SUB ${anime.episodes.sub}</div>
</div>
<div class="info-right">
<div class="btn-episode">DUB ${anime.episodes.dub}</div>
</div>
</div>
<div class="details">
<h3 class="name">${anime.name}</h3>
<p class="jname">${anime.jname}</p>
</div>
`;
animeList.appendChild(card);
});
} else {
animeList.innerHTML = '<p>No results found.</p>';
}
} catch (error) {
loader.style.display = 'none';
animeList.innerHTML = '<p>Error fetching data.</p>';
console.error('Error fetching data:', error);
}
}
// A function to be called on button click
function onFetchAnimeButtonClick() {
fetchAnimeData();
}
</script>
</div>
</main>
<footer class="footer">
<a href="index.html" class="logo-link">
<img src="logo.png" alt="AniTeams Logo" class="logo">
</a>
<div class="footer-container">
<div class="pagination">
<a href="#">A</a>
<a href="#">B</a>
<a href="#">C</a>
<a href="#">D</a>
<a href="#">E</a>
<a href="#">F</a>
<a href="#">G</a>
<a href="#">H</a>
<a href="#">I</a>
<a href="#">J</a>
<a href="#">K</a>
<a href="#">L</a>
<a href="#">M</a>
<a href="#">N</a>
<a href="#">O</a>
<a href="#">P</a>
<a href="#">Q</a>
<a href="#">R</a>
<a href="#">S</a>
<a href="#">T</a>
<a href="#">U</a>
<a href="#">V</a>
<a href="#">W</a>
<a href="#">X</a>
<a href="#">Y</a>
<a href="#">Z</a>
</div>
</div>
<div class="footer-links">
<a href="/credits">Credits</a> |
<span>Files not stored on this server.</span>
</div>
<div class="footer-bottom">
<span>© <span id="year"></span> AniTeams. All rights reserved.</span>
</div>
</footer>
<style>/* General Footer Styling */
.footer-container {
display: flex;
justify-content: flex-start;
align-items: flex-end;
flex-wrap: wrap;
margin: 0 50px 0 20px;
}
.footer {
background: url("footer.jpg") no-repeat center center;
background-size: cover;
height: 350px;
overflow: auto;
padding-bottom: 30px; /* Adds some space at the bottom */
}
/* Logo Styling */
.logo-link {
display: inline-block;
}
.logo {
height: 100px; /* Adjust the size of the logo */
z-index: 999;
transition: transform 0.3s ease; /* Animation for hover effect */
}
.logo-link:hover .logo {
transform: scale(1.05); /* Animation for logo hover */
}
/* Pagination Styling */
.pagination {
display: flex;
gap: 10px;
flex-wrap: wrap;
margin-left: 5px;
}
.pagination a {
color: white;
text-decoration: none;
padding: 8px 15px;
background-color: rgba(255, 255, 255, 0.1);
border-radius: 5px;
transition: background-color 100ms ease-in-out; /* Link hover effect animation */
}
/* Link Hover Effect */
.pagination a:hover {
background-color: hsl(271, 100%, 65%);
font-weight: bold;
}
/* Footer Links Styling */
.footer-links {
text-align: center;
margin-top: 20px;
}
.footer-links a {
color: white;
text-decoration: none;
margin: 0 10px;
}
.footer-links a:hover {
text-decoration: underline;
}
/* Footer Bottom Styling */
.footer-bottom {
text-align: center;
margin-top: 20px;
color: white;
}
/* Copyright Year */
#year {
font-weight: bold;
}
</style>
<script>
document.getElementById("year").textContent = new Date().getFullYear();
</script>
<script>
const bars = document.querySelector('.bars');
document.getElementById("closemenu").onclick = function(){
document.getElementById("menu").style.display = "none";
}
// Toggle menu and icon animation
bars.onclick = function(){
document.getElementById("menu").style.display = "flex";
}
document.addEventListener("DOMContentLoaded", function() {
document.getElementById("menu").style.display = "none";
});
// Select all elements with the given class names
const startYearSelects = document.querySelectorAll('.start-year, .start-year-2');
startYearSelects.forEach(startYearSelect => {
for (let year = 2024; year >= 1917; year--) {
const option = document.createElement('option');
option.value = year;
option.textContent = year;
startYearSelect.appendChild(option);
}
});
// Month dropdown menu javascript for the filter search
const startMonthSelects = document.querySelectorAll('.start-month, .start-month-2');
const months = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
];
startMonthSelects.forEach(startMonthSelect => {
for (let month = 0; month < months.length; month++) {
const option = document.createElement('option');
option.value = month + 1; // Month as numeric value (1-12)
option.textContent = months[month]; // Month name as text
startMonthSelect.appendChild(option);
}
});
const startDaySelects = document.querySelectorAll('.start-day, .start-day-2');
const days = [
'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'
];
startDaySelects.forEach(startDaySelect => {
for (let day = 0; day < days.length; day++) {
const option = document.createElement('option');
option.value = days[day]; // Use the day directly
option.textContent = days[day]; // Display day as text
startDaySelect.appendChild(option);
}
});
</script>
<script src="https://kit.fontawesome.com/54a003e4f7.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/eruda"></script>
<script>eruda.init();</script>
</body>
</html>