Skip to content

Instantly share code, notes, and snippets.

@chhumsina
Created October 9, 2014 06:01
Show Gist options
  • Save chhumsina/f83cbd38c93d7f5c3783 to your computer and use it in GitHub Desktop.
Save chhumsina/f83cbd38c93d7f5c3783 to your computer and use it in GitHub Desktop.
(function( $ ) {
$.fn.YoutubeVideo = function (pars) {
var feeddiv = $(this);
var pubdt;
$(this).html("<center>"+pars.loadingtext+"</center>");
$.ajax({type:"GET",url:pars.feedurl+"&max-results="+pars.count,dataType:"jsonp",success:function(yt_data){
feeddiv.html('');
$.each(yt_data.data.items,function(i,entry){
var video_id=entry.id;
var video_frame="<iframe width='"+pars.width+"' height='"+pars.height+"' src='http://www.youtube.com/embed/"+video_id+"' frameborder='0' type='text/html'></iframe>";
pubdt=new Date(entry.updated);
feeddiv.append('<div class="frame">');
feeddiv.append('<div class="ItemTitle">'+entry.title+' - <span class="ItemDate">'+pubdt.toLocaleDateString()+'</span></div>');
feeddiv.append('<div class="video">'+video_frame+'</div>');
feeddiv.append('</div>');
}) }
});
}})( jQuery );// JavaScript Document
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment