From 78f3c0e9893d36e0ce039c2b79ede8a92ebe468a Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 1 Oct 2017 00:24:20 -0400 Subject: Adding the code --- apps/youtube/js/youtubeapi.js | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 apps/youtube/js/youtubeapi.js (limited to 'apps/youtube/js') diff --git a/apps/youtube/js/youtubeapi.js b/apps/youtube/js/youtubeapi.js new file mode 100644 index 0000000..e2c63e4 --- /dev/null +++ b/apps/youtube/js/youtubeapi.js @@ -0,0 +1,51 @@ +$(document).ready(function() + { + $(".search_input").focus(); + $(".search_input").keyup(function() + { + + $("#video").html(''); + var search_input = $(this).val(); + var keyword= encodeURIComponent(search_input); + + var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&max-results=12&v=2&alt=jsonc'; + + + $.ajax({ + type: "GET", + url: yt_url, + dataType:"jsonp", + success: function(response) + { + if(response.data.items) + { + + + + $.each(response.data.items, function(i,data) + { + var video_id=data.id; + var video_title=data.title; + var video_viewCount=data.viewCount; + + + + var video_frame=""; + var final="
"+video_frame+"
"+video_title+"
"; + + $("#video").append(final); + + }); + + + } + else + { + $("#video").html("
No video found.
"); + } + } + + }); + }); + }); + \ No newline at end of file -- cgit v1.2.3