-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsearch.html
194 lines (172 loc) · 7.07 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
<title>Anime Search Results</title>
<style>
body {
background-color: #333;
color: #fff;
margin: 0;
font-family: Arial, sans-serif;
}
.search-bar {
width: 100%;
padding: 10px;
box-sizing: border-box;
margin-bottom: 20px;
font-size: 18px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #fff;
color: #000;
transition: background-color 0.3s ease, color 0.3s ease;
}
.search-bar.has-text {
background-color: #333;
color: #fff;
border-color: #333;
}
.movie-cards-container {
display: flex;
flex-wrap: wrap;
gap: 30px;
padding: 20px;
justify-content: flex-start;
}
.movie-card {
width: 250px;
position: relative;
overflow: hidden;
border-radius: 10px;
background-color: #444;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease, opacity 0.3s ease;
opacity: 1;
margin: 10px;
display: flex;
flex-direction: column;
justify-content: flex-start;
}
.movie-card img {
width: 100%;
height: auto;
border-radius: 10px 10px 0 0;
transition: filter 0.3s ease;
}
.movie-card .movie-info {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.8);
color: #fff;
padding: 20px;
opacity: 0;
transition: opacity 0.3s ease;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}
.movie-card:hover img {
filter: blur(4px);
}
.movie-card:hover .movie-info {
opacity: 1;
}
.movie-card:hover {
transform: translateY(-10px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.movie-info p {
margin: 5px 0;
}
/* Media Queries for Mobile Devices */
@media only screen and (max-width: 767px) {
.movie-card {
width: 100%;
margin: 10px 0;
}
}
</style>
</head>
<body>
<input type="text" id="search-bar" class="search-bar" placeholder="Search for an anime...">
<div class="movie-cards-container" id="movie-cards-container">
<!-- Movie cards will be dynamically inserted here -->
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const searchBar = document.getElementById('search-bar');
const container = document.getElementById('movie-cards-container');
const params = new URLSearchParams(window.location.search);
const query = params.get('query');
if (query) {
searchBar.value = query;
fetchData(query);
}
searchBar.addEventListener('input', function() {
const query = searchBar.value;
params.set('query', query);
window.history.replaceState({}, '', `${window.location.pathname}?${params.toString()}`);
fetchData(query);
});
function fetchData(query) {
const apiUrl = `https://api-p1xr.vercel.app/api/v2/search?q=${query}`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
container.innerHTML = ''; // Clear the container
data.results.forEach(anime => {
const card = document.createElement('a');
card.href = `details.html?id=${anime.id}`;
card.className = 'movie-card';
card.innerHTML = `
<img src="${anime.coverImage.extraLarge}" alt="${anime.title.userPreferred}">
<div class="movie-info">
<p><strong>${anime.title.userPreferred}</strong></p>
<p>${anime.season} ${anime.seasonYear}</p>
<p>${anime.format} | ${anime.type}</p>
<p>Episodes: ${anime.episodes}</p>
</div>
`;
container.appendChild(card);
});
})
.catch(error => {
console.error('Error fetching data:', error);
});
}
});
</script>
<!-- Bottom Toolbar -->
<div class="bg-gray-900 p-4 shadow-md fixed bottom-0 inset-x-0 flex justify-around">
<!-- Home Icon -->
<a href="index.html" class="flex flex-col items-center transform transition-transform duration-200 hover:scale-110">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-white hover:text-blue-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M13 5v6a1 1 0 001 1h3m4 0a1 1 0 011 1v6a1 1 0 01-1 1H6a1 1 0 01-1-1v-6a1 1 0 011-1h3m-4 0l2 2" />
</svg>
<span class="text-white text-xs mt-1 hover:text-blue-400">Home</span>
</a>
<!-- Search Icon -->
<a href="search.html" class="flex flex-col items-center transform transition-transform duration-200 hover:scale-110">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-white hover:text-green-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-4.35-4.35M18 10a8 8 0 11-16 0 8 8 0 0116 0z" />
</svg>
<span class="text-white text-xs mt-1 hover:text-green-400">Search</span>
</a>
<!-- Bookmark Icon -->
<a href="bookmark.html" class="flex flex-col items-center transform transition-transform duration-200 hover:scale-110">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-white hover:text-red-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 5v16l7-5 7 5V5a2 2 0 00-2-2H7a2 2 0 00-2 2z" />
</svg>
<span class="text-white text-xs mt-1 hover:text-red-400">Bookmark</span>
</a>
</div>
</div>
</body>
</html>