This repository was archived by the owner on Oct 27, 2021. It is now read-only.
File tree 3 files changed +76
-0
lines changed
3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ function youtubeAPI ( ) {
3
+ var keys = [
4
+ 'key Replaced by your own'
5
+ ] ;
6
+ var APIKey = keys [ Math . floor ( Math . random ( ) * keys . length ) ] ;
7
+ return APIKey ;
8
+ }
Original file line number Diff line number Diff line change
1
+ < html >
2
+ < head >
3
+ < title > Simple YouTube Channel Search Engine</ title >
4
+ < script src ="auth.js "> </ script >
5
+ < script src ="script.js "> </ script >
6
+ < script src ="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js "> </ script >
7
+ </ head >
8
+ < body >
9
+ < section id ="display " align ="center ">
10
+ < input id ="searchBar " value ="Developers@Work "/>
11
+ < button type ="submit " onClick ="buttonClicked() "> Submit</ button >
12
+ </ section >
13
+ </ body >
14
+ </ html >
Original file line number Diff line number Diff line change
1
+ var channelId = [ ] , channelTitle = [ ] , channelThumbnail = [ ] , 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 ( '<div id="' + channelId [ i ] + '"align="center"><img src="' + channelThumbnail [ i ] + '"/>\
8
+ <a href="https://youtube.com/channel/' + channelId [ i ] + '" target="_blank"><H3>' + channelTitle [ i ] + '</H3></a>\
9
+ </div>' ) ;
10
+ if ( count == 3 ) {
11
+ $ ( '#display' ) . append ( '<br>' ) ;
12
+ count = 1 ;
13
+ }
14
+ if ( i == temp . length - 1 ) {
15
+ $ ( '#display' ) . append ( '<input id="searchBar" value="Developers@Work"/>\
16
+ <button type="submit" onClick="buttonClicked()">Submit</button>' ) ;
17
+ }
18
+ count ++ ;
19
+ }
20
+ }
21
+
22
+
23
+ function searchCode ( keyword ) {
24
+ this . keyword = keyword || 'Developers@Work' ;
25
+ var Api = youtubeAPI ( ) ;
26
+ $ . get ( 'https://www.googleapis.com/youtube/v3/search' , {
27
+ q :this . keyword ,
28
+ key :Api ,
29
+ type :'channel' ,
30
+ part :'snippet'
31
+ } , function ( data ) {
32
+ temp = data . items ;
33
+ for ( var i = 0 ; i < temp . length ; i ++ ) {
34
+ channelId [ i ] = temp [ i ] . snippet . channelId ;
35
+ channelTitle [ i ] = temp [ i ] . snippet . title ;
36
+ channelThumbnail [ i ] = temp [ i ] . snippet . thumbnails . default . url ;
37
+ }
38
+ } ) ;
39
+ designHTML ( ) ;
40
+ }
41
+
42
+ function buttonClicked ( ) {
43
+ var keyword = document . getElementById ( 'searchBar' ) . value ;
44
+ searchCode ( keyword ) ;
45
+
46
+ }
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
You can’t perform that action at this time.
0 commit comments