-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
151 lines (57 loc) · 2.2 KB
/
app.js
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
import nvbr from "./componnents/navbar.js"
document.getElementById("navbar").innerHTML =nvbr()
import filterbtn from "./componnents/filter.js"
document.getElementById("filtersdiv").innerHTML=filterbtn()
async function content_show(data){
document.querySelector(".container").innerHTML=null
let parent = document.querySelector(".container")
for(let el of data){
let child = document.createElement("div")
child.className="video"
child.addEventListener("click",function(){
store(el)
})
let channel_picture = await channel(el.snippet.channelId)
child.innerHTML = `
<img src="${el.snippet.thumbnails.high.url}" class="thumbnail" alt="">
<div class="content">
<img src="${channel_picture}" class="channel-icon" alt="">
<div class="info">
<h4 class="title">${el.snippet.title}</h4>
<p class="channel-name">${el.snippet.channelTitle}</p>
</div>
</div> `
parent.append(child)
}
}
const store =(el)=>{
localStorage.setItem("video_data",JSON.stringify(el))
window.location.href="video.html"
}
import jump from "./componnents/redirect.js"
document.getElementById("searchbtn").addEventListener("click" , jump())
const empty=async()=>{
let data=await fetch(`https://youtube.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular®ionCode=IN&maxResults=50&key=AIzaSyBihnXKUmx9h6DHAlTNkrZ-6znzrz3ME1M`)
data=await data.json()
content_show(data.items)
}
empty()
const channel= async (channelid)=>{
let g= await fetch ( ` https://www.googleapis.com/youtube/v3/channels?part=snippet&id=${channelid}&key=AIzaSyA8HVQEsyROLmeZ4P3GhKRCU2BajTnJUNc` )
g = await g.json()
let url = await g.items[0].snippet.thumbnails.high.url
return await url
}
const change =async (el)=>{
let value=el.innerHTML
let data = await fetch(`https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&q=${value}&key=AIzaSyCGz_8bE32q4NAkjdAXjpAiigBS6z9ZASU`)
data = await data.json()
let actual_data = data.items
content_show(actual_data)
}
let arr = document.querySelectorAll("#filtersdiv>button")
for(let el of arr){
el.addEventListener("click",function(){
change(el)
})
}