1/* 2 === Advanced Youtube Channel Pagination === 3 Contributors: Balasaheb Bhise 4 5 6 */ 7$ = jQuery.noConflict(); 8 9$(document).ready(function () { 10 11 var channelIdValue = $("#youtube_channel_id_field_name").val(); 12 var apiKeyValue = $("#youtube_channel_api_key_field_name").val(); 13 var maxResultsVideo = $("#youtube_channel_result_per_page_field_name").val(); 14 var gridPreRowList = $("#youtube_channel_grid_on_page_field_name").val(); 15 16 $("#pageTokenNext").on("click", function (event) { 17 $("#pageToken").val($("#pageTokenNext").val()); 18 youtubeChannelVedioApiCallPlayListId(); 19 }); 20 21 $("#pageTokenPrev").on("click", function (event) { 22 $("#pageToken").val($("#pageTokenPrev").val()); 23 youtubeChannelVedioApiCallPlayListId(); 24 }); 25 26 youtubeChannelVedioApiCallPlayListId(); 27 // Get Playlist 28 function youtubeChannelVedioApiCallPlayListId() { 29 $.get( 30 "https://www.googleapis.com/youtube/v3/channels", { 31 part: 'contentDetails', 32 id: channelIdValue, 33 key: apiKeyValue 34 }, function (data) { 35 $.each(data.items, function (i, item) { 36 var playListId = item.contentDetails.relatedPlaylists.uploads; 37 youtubeChannelVedioApiCall(playListId); 38 }); 39 }); 40 } 41 42 function youtubeChannelVedioApiCall(playListId) { 43 $.ajax({ 44 cache: false, 45 data: $.extend({ 46 key: apiKeyValue, 47 part: 'snippet', 48 playlistId: playListId, 49 }, {maxResults: maxResultsVideo, order: 'date', type: 'video', pageToken: $("#pageToken").val()}), 50 dataType: 'json', 51 type: 'GET', 52 timeout: 5000, 53 url: 'https://www.googleapis.com/youtube/v3/playlistItems' 54 }).done(function (channelData) { 55 56 var items = channelData.items; 57 total_video_count = Object.keys(items).length; 58 59 if (typeof channelData.prevPageToken === "undefined") { 60 $("#pageTokenPrev").hide(); 61 } else { 62 $("#pageTokenPrev").show(); 63 } 64 if (typeof channelData.nextPageToken === "undefined" || total_video_count < maxResultsVideo) { 65 $("#pageTokenNext").hide(); 66 } else { 67 $("#pageTokenNext").show(); 68 } 69 70 $("#pageTokenPrev").val(channelData.prevPageToken); 71 72 $("#pageTokenNext").val(channelData.nextPageToken); 73 74 if (items[0]) { 75 var current_videoId = items[0].snippet.resourceId.videoId; 76 $("#youtube-channel-video .display-watch-video").html('<div class="col-sm-12"><iframe width="100%" height="619" src="https://www.youtube.com/embed/' + current_videoId + '" frameborder="0" allowfullscreen=""></iframe><h2> ' + items[0].snippet.title + '</h2></div>'); 77 } 78 79 grid_video_list = 0; 80 videoList = ''; 81 $.each(items, function (index, e) { 82 videoList = videoList + '<div class="col-sm-' + gridPreRowList + ' ycv-list-snippet"><div class="item-list-box"><div class="ycv-simple-thumb-wrap"><img class="img-responsive" alt="' + e.snippet.title + '" src="' + e.snippet.thumbnails.medium.url + '"></div><div class="current-video-id" style="display:none">' + e.snippet.resourceId.videoId + '</div><div class="title">' + e.snippet.title + '</div></div></div>'; 83 }); 84 $("#yc-pagination-watch").html(videoList); 85 videoList = ''; 86 }); 87 } 88 $('#youtube-channel-pagination #yc-pagination-watch').on('click', '.ycv-list-snippet', function () { 89 var currentVideoId = $(this).find(".current-video-id").text(); 90 var video_snippet = $(this).find(".title").text(); 91 $("#youtube-channel-video .display-watch-video").html('<div class="col-sm-12"><iframe width="100%" height="619" src="https://www.youtube.com/embed/' + currentVideoId + '" frameborder="0" allowfullscreen=""></iframe><h2> ' + video_snippet + '</h2></div>'); 92 }); 93 94});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.