-
Notifications
You must be signed in to change notification settings - Fork 0
/
style.css formatted.html
84 lines (76 loc) · 3.12 KB
/
style.css formatted.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
<!DOCTYPE html>
<html>
<head>
<!-- CSS stylesheets -->
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body>
<!-- Website header -->
<header>
<h1 id="headertext">The Casual Reviews</h1>
</header>
<!-- Navigation menu -->
<nav>
<ul>
<!-- About Us link -->
<a href="about.html" id="about">About Us</a>
</ul>
<ul>
<!-- Home link -->
<a href=index.html id="home">Home</a>
</ul>
<ul>
<!-- Sign up or Login link -->
<a href="loginAuth.html" id="SignupLogin">Sign up or Login</a>
</ul>
</nav>
<!-- Search section -->
<div style="display: flex; flex-direction: column; align-items: center; margin-top: 50px;">
<h1 id="whatmovie" style="margin-bottom: 20px;">What movie would you like to review?</h1>
<div style="display: flex; align-items: center;">
<input type="text" id="search-input" placeholder="Enter your movie title...">
<button onclick="searchAPI()" id="search-button">Search</button>
</div>
<ul id="search-results"></ul>
</div>
<!-- Trending movies section -->
<div id="movies"></div>
<!-- Footer -->
<div class="footer">Check out this week's Trending Movies!</div>
<!-- JavaScript code -->
<script>
// Function to search the movie API
function searchAPI() {
const searchQuery = document.getElementById("search-input").value;
const apiUrl = `https://api.themoviedb.org/3/search/movie?api_key=6aa86f5797de13c2b8d8eb2581248f51&language=en-US&query=${searchQuery}&page=1&include_adult=false`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
const resultsList = document.getElementById("search-results");
resultsList.innerHTML = "";
data.results.slice(0, 5).forEach((result, index) => {
const listItem = document.createElement("li");
const link = document.createElement("a");
link.href = `movie.html?movie-title=${result.title}`;
link.innerText = `${index + 1}. ${result.title}`;
const movieTitle = result.title;
localStorage.setItem('movie-title', result.title);
listItem.appendChild(link);
resultsList.appendChild(listItem);
});
});
}
// Fetch trending movies from API
const apiKey = '6aa86f5797de13c2b8d8eb2581248f51';
const apiUrl = `https://api.themoviedb.org/3/trending/movie/week?api_key=${apiKey}`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
const movies = data.results.slice(0, 5); // Extract top 5 movies
const moviesContainer = document.getElementById('movies');
movies.forEach(movie => {
const movieElement = document.createElement('div');
movieElement.classList.add('movie');
const movieContainer = document.createElement('div'); // Create container for title and poster
movieContainer.classList.add('movie-container');
const titleElement = document