|
| 1 | +var channelActivitiesUpload=[],channelActivitiesVideoView=[],channelActivitiesSubscription=[], |
| 2 | + reference=[]; |
| 3 | + |
| 4 | +function buttonClickedSearchChannelActivities(){ |
| 5 | + var keyword = document.getElementById('searchBar').value; |
| 6 | + var max = document.getElementById('maxResults').value; |
| 7 | + document.getElementById('display').innerHTML='Channel Keyword/Title/Id: <input id="searchBar"><br>\ |
| 8 | + Max Results to be Displayed: <input id="maxResults" value="5"><br>\ |
| 9 | + <button onClick="buttonClickedSearchChannelActivities()">submit</button>'; |
| 10 | + searchChannelsCode(keyword); |
| 11 | + var YTCI = []; |
| 12 | + var i=0; |
| 13 | + channelActivitiesCode(channelId[i],max); |
| 14 | + YTCI = channelId; |
| 15 | + $('#display').append('<div id="'+channelId[i]+'"align="center"><img src="'+channelThumbnail[i]+'"/>\ |
| 16 | + <a href="https://youtube.com/channel/'+channelId[i]+'" target="_blank"><H3>'+channelTitle[i]+'</H3></a>\ |
| 17 | + </div>'); |
| 18 | + for(j=0;j<reference.length;j++){ |
| 19 | + channelActivitiesDisplay(YTCI[i],reference[j],j); |
| 20 | + } |
| 21 | +}; |
| 22 | + |
| 23 | +function channelActivitiesCode(YouTubeChannelId,max=5){ |
| 24 | + var API_KEY = API(); |
| 25 | + $.ajax({ |
| 26 | + url:'https://www.googleapis.com/youtube/v3/activities', |
| 27 | + data:{ |
| 28 | + key:API_KEY, |
| 29 | + part:'contentDetails', |
| 30 | + maxResults:max, |
| 31 | + channelId:YouTubeChannelId |
| 32 | + }, |
| 33 | + async:false, |
| 34 | + success:function(data){ |
| 35 | + temp = data.items; |
| 36 | + for(var i=0;i<temp.length;i++){ |
| 37 | + temp[i]=temp[i].contentDetails; |
| 38 | + if(temp[i].upload){ |
| 39 | + channelActivitiesUpload[i] = temp[i].upload.videoId; |
| 40 | + reference[i]='upload'; |
| 41 | + }else if(temp[i].bulletin){ |
| 42 | + channelActivitiesVideoView[i] = temp[i].bulletin.resourceId.videoId; |
| 43 | + reference[i]='videoView'; |
| 44 | + }else if(temp[i].subscription){ |
| 45 | + channelActivitiesSubscription[i] = temp[i].subscription.resourceId.channelId; |
| 46 | + reference[i]='subscription'; |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + }); |
| 51 | +}; |
| 52 | + |
| 53 | +function channelActivitiesDisplay(YouTubeChannelId,i='.',j=0,){ |
| 54 | + if(i=='upload'){ |
| 55 | + $('#'+YouTubeChannelId).append('<div id="'+channelActivitiesUpload[j]+'"><h2>VIDEO UPLOAD:</h2>\ |
| 56 | + <iframe src="https://youtube.com/embed/'+channelActivitiesUpload[j]+'"></iframe>\ |
| 57 | + </div><br>'); |
| 58 | + }else if(i=='videoView'){ |
| 59 | + $('#'+YouTubeChannelId).append('<div id="'+channelActivitiesVideoView[j]+'"><h2>VIDEO VIEW:</h2>\ |
| 60 | + <iframe src="https://youtube.com/embed/'+channelActivitiesVideoView[j]+'"></iframe>\ |
| 61 | + </div><br>'); |
| 62 | + }else if(i=='subscription'){ |
| 63 | + searchChannelsCode(channelActivitiesSubscription[j]); |
| 64 | + $('#'+YouTubeChannelId).append('<div id="'+channelActivitiesSubscription[j]+'"><h2>SUBSCRIPTION:</h2>\ |
| 65 | + <div id="'+channelId[0]+'"align="center"><img src="'+channelThumbnail[0]+'"/>\ |
| 66 | + <a href="https://youtube.com/channel/'+channelId[0]+'" target="_blank"><H3>'+channelTitle[0]+'</H3></a>\ |
| 67 | + </div>\ |
| 68 | + </div><br>'); |
| 69 | + } |
| 70 | + else $('#'+YouTubeChannelId).append('.<br>'); |
| 71 | + |
| 72 | +} |
| 73 | + |
0 commit comments