-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrending.html
187 lines (163 loc) · 5.02 KB
/
trending.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
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<title>Document</title>
<style>
@font-face {
font-family: NetflixSans;
src: url("./fonts/NetflixSansRegular.ttf")
format("truetype");
}
@font-face {
font-family: NetflixBold;
src: url("./fonts/NetflixSansBold.ttf")
format("truetype");
}
body {
margin: 0px 0px 200px 0px;
font-family: NetflixSans;
background: rgb(20, 20, 20);
}
h1, h2 {
color: white;
}
.header {
width: 100%;
position: fixed;
background: rgb(20, 20, 20);
padding: 20px 50px;
display: flex;
z-index: 100;
}
.header img {
width: 80px;
margin-right: 10px;
}
.header ul {
margin: 0px;
list-style-type: none;
}
.header ul li {
display: inline;
margin-right: 20px;
font-size: 14px;
color: #e5e5e5;
cursor: pointer;
}
.header ul li:hover {
color: #fafafa;
}
.header ul li:first-child {
color: white;
}
.trending-banner {
width: 30%;
padding-top: 150px;
margin: 0px auto;
}
#trending-container {
width: 60%;
margin: 75px auto;
display: grid;
grid-template-columns: repeat(2, 1fr);
row-gap: 20px;
column-gap: 20px;
}
#trending-container > div {
background: #fafafa;
border-radius: 5px;
}
#trending-container > div h2 {
color: rgb(20, 20, 20);
margin: 5px 0px;
white-space: nowrap;
width: 350px;
overflow: hidden;
text-overflow: ellipsis;
}
#trending-container > div h5 {
margin: 5px 0px;
text-transform: uppercase;
color: #E50914;
}
#trending-container > div h6 {
margin: 5px 0px;
}
#trending-container > div > div {
padding: 10px 20px;
}
#trending-container > div img {
width: 100%;
margin-right: 10px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
#trending-container > div > div > p {
white-space: nowrap;
width: 350px;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div class="header">
<a href="./index.html"><div><img src="./images/netflix_logo.png" alt=""></div></a>
<ul>
<li>Home</li>
<li>TV Shows</li>
<li>Movies</li>
<li>New & Popular</li>
<li>My List</li>
</ul>
</div>
<div id="control"></div>
<div class="trending-banner">
<img src="./images/netflix_trending.png" width="100%" alt="">
</div>
<div id="trending-container">
</div>
</body>
<script>
async function loadTrending() {
try {
var res = await fetch(`https://api.themoviedb.org/3/trending/all/day?api_key=d5e74a00df86cc17925a9f779c2e9e24`);
var data = await res.json();
console.log(data.results);
showTrending(data.results);
} catch(err) {
console.log(err);
}
}
loadTrending();
function showTrending(results) {
document.querySelector("#trending-container").textContent = "";
results.length = 10;
results.map(function(trending) {
var outerDiv = document.createElement("div");
var img = document.createElement("img");
img.src = "https://image.tmdb.org/t/p/original/" + trending.backdrop_path;
var innerDiv = document.createElement("div");
var h5 = document.createElement("h5");
h5.textContent = trending.media_type;
var h2 = document.createElement("h2");
if(trending.name)
h2.textContent = trending.name;
else h2.textContent = trending.original_title
var h6 = document.createElement("div");
if(trending.vote_count == 0)
h6.textContent = "N/A";
else h6.textContent = trending.vote_average + " from " + trending.vote_count + " votes";
var p = document.createElement("p");
p.textContent = trending.overview;
innerDiv.append(h5, h2, h6, p);
outerDiv.append(img, innerDiv);
document.querySelector("#trending-container").append(outerDiv);
});
}
</script>
</html>