This repository was archived by the owner on Oct 27, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments