|
| 1 | +var commentRepliedId = [], |
| 2 | + commentRepliedAuthorDisplayName=[],commentRepliedAuthorProfileImageUrl=[], |
| 3 | + commentRepliedAuthorChannelId=[],commentRepliedTextDisplay=[], |
| 4 | + commentRepliedLikeCount=[], |
| 5 | + commentRepliedPublishedAt=[],commentRepliedUpdatedAt=[]; |
| 6 | + |
| 7 | +function buttonClickedSearchCommentRepliesByVideoId(){ |
| 8 | + var keyword = document.getElementById('searchBar').value; |
| 9 | + document.getElementById('display').innerHTML = 'Video Keyword/Title/Id: <input id="searchBar"><br>\ |
| 10 | + Max Results to be Displayed: <input id="maxResults" value="25"><br>\ |
| 11 | + <button onClick="buttonClickedSearchCommentsByVideoId()">submit</button>'; |
| 12 | + searchVideosCode(keyword); |
| 13 | + var i = 0,j = 0; |
| 14 | + //for(i=0;i<videoId.length;i++){ |
| 15 | + commentsOnAVideoCode(videoId[i]); |
| 16 | + videosCountCode(videoId[i]); |
| 17 | + displayVideosCount(i); |
| 18 | + for(j=0;j<commentedId.length;j++){ |
| 19 | + if(commentedTotalReplyCount[j]>0){ |
| 20 | + document.getElementById(videoTitle[i]).outerHTML = '<h1 id="'+videoTitle[i]+'">'+videoTitle[i]+'</h1>'; |
| 21 | + commentRepliesOnAVideoCode(commentedId[j]); |
| 22 | + commentRepliesOnAVideoDisplay(videoId[i],commentedId[j],j); |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 26 | + //} |
| 27 | +}; |
| 28 | + |
| 29 | +function commentRepliesOnAVideoCode(YouTubeCommentId,max=10){ |
| 30 | + var API_KEY = API(); |
| 31 | + |
| 32 | + $.ajax({ |
| 33 | + url:'https://www.googleapis.com/youtube/v3/comments', |
| 34 | + data:{ |
| 35 | + key:API_KEY, |
| 36 | + parentId:YouTubeCommentId, |
| 37 | + part:'snippet', |
| 38 | + maxResults:max |
| 39 | + }, |
| 40 | + async:false, |
| 41 | + success:function(data){ |
| 42 | + temp = data.items; |
| 43 | + |
| 44 | + for(var i=0;i<temp.length;i++){ |
| 45 | + |
| 46 | + commentRepliedId[i] = temp[i].id; |
| 47 | + |
| 48 | + commentRepliedAuthorDisplayName[i] = temp[i].snippet.authorDisplayName; |
| 49 | + commentRepliedAuthorProfileImageUrl[i] = temp[i].snippet.authorProfileImageUrl; |
| 50 | + commentRepliedAuthorChannelId[i] = temp[i].snippet.authorChannelId.value; |
| 51 | + commentRepliedTextDisplay[i] = temp[i].snippet.textDisplay; |
| 52 | + |
| 53 | + commentRepliedLikeCount[i] = temp[i].snippet.likeCount; |
| 54 | + commentRepliedPublishedAt[i] = temp[i].snippet.publishedAt; |
| 55 | + commentRepliedUpdatedAt[i] = temp[i].snippet.updatedAt; |
| 56 | + } |
| 57 | + } |
| 58 | + }); |
| 59 | +}; |
| 60 | + |
| 61 | +function commentRepliesOnAVideoDisplay(YouTubeVideoId,YouTubeCommentedId,i=0){ |
| 62 | + $('#video'+YouTubeVideoId).append('\ |
| 63 | + <div id="comment'+commentedId[i]+'" style="border:5px solid red">\ |
| 64 | + <img src="'+commentedAuthorProfileImageUrl[i]+'">\ |
| 65 | + <a href="https://youtube.com/channel/'+commentdAuthorChannelId[i]+'" target="_blank">\ |
| 66 | + <h1 id="'+commentdAuthorChannelId+commentedId[i]+'">"'+commentedAuthorDisplayName[i]+'"</h1>\ |
| 67 | + </a>\ |
| 68 | + <h2 id="'+commentedId[i]+'">\ |
| 69 | + Comment:'+commentedTextDisplay[i]+'<br>\ |
| 70 | + Replies:'+commentedTotalReplyCount[i]+'<br>\ |
| 71 | + Likes for Comment:'+commentedLikeCount[i]+'<br>\ |
| 72 | + Commented At:'+commentedPublishedAt[i]+'<br>\ |
| 73 | + Last Edited:'+commentedUpdatedAt[i]+'<br></h2>\ |
| 74 | + <br><br></div>\ |
| 75 | + '); |
| 76 | + for(i=0;i<temp.length;i++){ |
| 77 | + $('#comment'+YouTubeCommentedId).append('\ |
| 78 | + <div id="reply'+commentRepliedId[i]+'">\ |
| 79 | + <img src="'+commentRepliedAuthorProfileImageUrl[i]+'">\ |
| 80 | + <a href="https://youtube.com/channel/'+commentRepliedAuthorChannelId[i]+'" target="_blank">\ |
| 81 | + <h1 id="'+commentRepliedAuthorChannelId+commentRepliedId[i]+'">"'+commentRepliedAuthorDisplayName[i]+'"</h1>\ |
| 82 | + </a>\ |
| 83 | + <h2 id="'+commentedId[i]+'">\ |
| 84 | + Reply:'+commentRepliedTextDisplay[i]+'<br>\ |
| 85 | + Likes for Reply:'+commentRepliedLikeCount[i]+'<br>\ |
| 86 | + Commented At:'+commentRepliedPublishedAt[i]+'<br>\ |
| 87 | + Last Edited:'+commentRepliedUpdatedAt[i]+'<br></h2>\ |
| 88 | + </div>\ |
| 89 | + '); |
| 90 | + } |
| 91 | +}; |
| 92 | + |
0 commit comments