-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowVideo.html
309 lines (245 loc) · 8.31 KB
/
showVideo.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined"
rel="stylesheet">
<link rel="icon" href="https://www.youtube.com/s/desktop/4aac258c/img/favicon_32.png" sizes="32x32">
<link rel="stylesheet" type="text/css" href="youtubeclone.css">
<title>Youtube</title>
</head>
<body>
<!--NAVBAR -->
<div class="navbar">
<div class="side_menu">
<div class="logo__">
<div class="bar">
<span></span>
<span></span>
<span></span>
</div>
<div class="logo">
<a href="index.html"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b8/YouTube_Logo_2017.svg/2560px-YouTube_Logo_2017.svg.png" ></a>
</div>
</div>
</div>
<div>
<nav>
<div class="center_side--nav">
<div class="searchbar">
<input type="text" placeholder="Search" id="video_search"/>
<div onclick="SearchVideo__from_watch()">
<img src="https://cdn2.iconfinder.com/data/icons/apple-inspire-white/100/Apple-30-512.png" width="20px" height="20px"/>
</div>
</div>
<div class="mic">
<span class="material-icons">mic</span>
</div>
</div>
<div class="right_side--nav">
<div>
<span class="material-icons-outlined">
video_call
</span>
</div>
<div>
<span class="material-icons-outlined">
apps
</span>
</div>
<div>
<span class="material-icons-outlined">notifications</span>
</div>
<div>
<img src="https://png.pngtree.com/png-clipart/20190516/original/pngtree-cute-girl-avatar-material-png-image_4023832.jpg" class="avtar" />
</div>
</div>
</nav>
</div>
</div>
<!--WATCH CLICKED VIDEO AND RELETED VIDEOS -->
<div class="watchVideo">
<div class="mainVideo">
<!--VIDEO WATCH -->
<div class="video">
<iframe width="100%" height="480" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<p id="title"></p>
<div class="details_video">
<div id="viewsBig_video" ></div>
<div class="video_likes">
<div>
<span class="material-icons-outlined">
thumb_up
</span>
<span>like</span>
</div>
<div>
<span class="material-icons-outlined">
thumb_down
</span>
<span>dislike</span>
</div>
<div>
<span class="material-icons-outlined reply_swap">
reply
</span>
<span>share</span>
</div>
<div>
<span class="material-icons-outlined">
playlist_add
</span>
<span>save</span>
</div>
<div>
<span class="material-icons">
more_horiz
</span>
</div>
</div>
</div>
</div>
<!--DETAILS OF THAT VIDEEOS-->
<div class="channelDetails">
<div>
<img id="bigVideo__profile">
<div>
<p class="bigVideo__title"></p>
<p class="bigVideo__Des"></p>
<button onclick="show_des()">show more</button>
</div>
</div>
<div class="subscribe">SubScribe</div>
</div>
<!--COMMENTS-->
<div>
<p>Comments </p>
<div class="comments">
<img src="https://png.pngtree.com/png-clipart/20190516/original/pngtree-cute-girl-avatar-material-png-image_4023832.jpg" class="avtar" />
<input type="text" placeholder="Add a public comment...">
</div>
</div>
</div>
<!--RELATED VIDEOS -->
<div class="relatedVideo">
<div class="filter_container">
<div>All</div>
<div>Mixes</div>
<div>Comedies</div>
<div>Music</div>
<div class="remove_small_screen">Website</div>
<div class="remove_small_screen">HTML</div>
<div class="remove_small_screen">CSS</div>
<div class="remove_small_screen">Stock markets</div>
<div class="remove_small_screen">JavaScript</div>
<div class="remove_small_screen">Cartoon</div>
<div class="remove_small_screen">Moive</div>
</div>
<div class="recommend">
</div>
</div>
</div>
</body>
</html>
<script>
let API_KEY = "AIzaSyCA2ZgfmTkC6c0RGE4nlheSBhhmwXQm2-4"
//GETTING CLICKED VIDEO AND RELATED VIDEOS
MainVideo = JSON.parse(localStorage.getItem("mainVideo"))
recommened = JSON.parse(localStorage.getItem("relatedVideo"))
let channelDetail = document.querySelector(".channelDetails")
display(MainVideo , recommened)
function display(mainVideo , recommened){
console.log(mainVideo)
var iframe = document.querySelector("iframe")
let videoid ;
if(mainVideo.id.videoId){
videoid = mainVideo.id.videoId
}else{
videoid = mainVideo.id
}
iframe.src = `https://www.youtube.com/embed/${videoid}`
var h2 = document.querySelector("#title")
h2.innerText = mainVideo.snippet.title
var channelImg = document.querySelector("#bigVideo__profile")
//GETTING CHANNEL PROFILE IMG AND SUBSCIBER NUMBER
var channelicon = `https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&key=${API_KEY}&id=${mainVideo.snippet.channelId}`
fetch(channelicon)
.then((res)=>{
return res.json()
})
.then((res)=>{
channelImg.src = res.items[0].snippet.thumbnails.medium.url
document.querySelector("#viewsBig_video").innerText = res.items[0].statistics.viewCount + " views"
document.querySelector(".bigVideo__Des").innerText = res.items[0].snippet.description
var subscriber = res.items[0].statistics.subscriberCount
if(subscriber >= 1000 && subscriber < 1000000){
subscriber = Math.floor(subscriber/1000) + "K "
}else if(subscriber >= 1000000 && subscriber < 1000000000){
subscriber = Math.floor(subscriber/1000000) + "M "
}else if(subscriber >= 1000000000 && subscriber < 1e12){
subscriber = Math.floor(subscriber/1000000000) + "B "
}
document.querySelector(".bigVideo__title").innerHTML = `<span>${mainVideo.snippet.channelTitle}</span><span>${subscriber} subscribers</span>`
}).catch((err)=>{
console.log(err)
})
//RECOMMEND VIDEOS
recommened.map((item)=>{
if(item.snippet.title != mainVideo.snippet.title){
var div = document.createElement("div")
var videoImg = document.createElement("img")
videoImg.src = item.snippet.thumbnails.medium.url
var title_and_Profile = document.createElement("div")
title_and_Profile.setAttribute("class" , "title_and_Profile")
var divTitle = document.createElement("div")
var title = document.createElement("p")
title.innerText = item.snippet.title
var channelName = document.createElement("span")
channelName.innerText = item.snippet.channelTitle
var views = document.createElement("span")
divTitle.append(title , channelName , views)
//GETTING CHANNEL PROFILE IMG
var channelicon = `https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&key=${API_KEY}&id=${item.snippet.channelId}`
fetch(channelicon)
.then((res)=>{
return res.json()
})
.then((res)=>{
viewvideo = res.items[0].statistics.viewCount
if(viewvideo >= 1000 && viewvideo < 1000000){
views.innerText = Math.floor(viewvideo/1000) + "K views"
}else if(viewvideo >= 1000000 && viewvideo < 1000000000){
views.innerText = Math.floor(viewvideo/1000000) + "M views"
}else if(viewvideo >= 1000000000 && viewvideo < 1e12){
views.innerText = Math.floor(viewvideo/1000000000) + "B views"
}
}).catch((err)=>{
console.log(err)
})
title_and_Profile.append(divTitle)
div.append(videoImg , title_and_Profile)
document.querySelector(".recommend").append(div)
div.addEventListener("click" ,function(){
getVideo(item , recommened)
})
}
})
}
//SHOW CLICKED VIDEO
function getVideo(item , items){
localStorage.setItem("mainVideo" , JSON.stringify(item))
localStorage.setItem("relatedVideo" , JSON.stringify(items))
window.location.href = "showVideo.html"
}
//SHOW SEARCHED RESULTS FUNCTION
function SearchVideo__from_watch(){
var value = document.querySelector("#video_search").value
localStorage.setItem("valueFromWatchvideo" , value)
window.location.href = "index.html"
}
//TOGGLE FOR SHOW DESCRIPTION MORE AND LESS
function show_des(){
document.querySelector(".bigVideo__Des").classList.toggle("show_more")
}
</script>