Skip to content
This repository was archived by the owner on Oct 27, 2021. It is now read-only.

Commit 24444a9

Browse files
Add files via upload
1 parent a3429dc commit 24444a9

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<html>
2+
<head>
3+
<title>Simple YouTube Video Search Engine and Embed</title>
4+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
5+
<script src="auth.js"></script>
6+
<script async src="script.js"></script>
7+
8+
</head>
9+
<body>
10+
<section id="display" align="center">
11+
<input id="searchBar" value="Developers@Work"/>
12+
<button type="submit" onClick="buttonClicked()">Submit</button>
13+
</section>
14+
</body>
15+
</html>

script.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
var videoId = [],videoTitle = [],videoThumbnail = [],temp =[];
2+
3+
function designHTML(){
4+
//document.getElementById('display').innerHTML = '';
5+
var count=1;
6+
for(var i=0;i<temp.length;i++){
7+
$('#display').append('\
8+
<iframe src="https://www.youtube.com/embed/'+videoId[i]+'"><iframe>\
9+
');
10+
}
11+
}
12+
13+
14+
function searchCode(keyword){
15+
this.keyword = keyword || 'Developers@Work';
16+
var Api = API();
17+
$.ajax({
18+
url:'https://www.googleapis.com/youtube/v3/search',
19+
data:{
20+
q:this.keyword,
21+
key:Api,
22+
type:'video',
23+
videoEmbeddable:'true',
24+
part:'snippet'
25+
},
26+
async:false,
27+
success:function(data){
28+
temp = data.items;
29+
for(var i=0;i<temp.length;i++){
30+
videoId[i] = temp[i].id.videoId;
31+
videoTitle[i] = temp[i].snippet.title;
32+
videoThumbnail[i] = temp[i].snippet.thumbnails.default.url;
33+
}
34+
}
35+
});
36+
}
37+
38+
function buttonClicked(){
39+
var keyword = document.getElementById('searchBar').value;
40+
searchCode(keyword);
41+
designHTML();
42+
}
43+
44+
45+
46+
47+
48+
49+
50+

0 commit comments

Comments
 (0)