Team:NYU Gallatin/
From 2012.igem.org
(Difference between revisions)
m |
|||
Line 37: | Line 37: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
<!--//--><![CDATA[// ><!-- | <!--//--><![CDATA[// ><!-- | ||
+ | |||
+ | |||
+ | (function() { | ||
+ | function createPlayer(jqe, video, options) { | ||
+ | var ifr = $('iframe', jqe); | ||
+ | if (ifr.length === 0) { | ||
+ | ifr = $('<iframe scrolling="no" frameborder="no">'); | ||
+ | ifr.addClass('player'); | ||
+ | if (options.playeropts) | ||
+ | ifr.attr(options.playeropts); | ||
+ | } | ||
+ | var src = 'http://www.youtube.com/embed/' + video; | ||
+ | if (options.playopts) { | ||
+ | src += '?'; | ||
+ | for (var k in options.playopts) { | ||
+ | src+= k + '=' + options.playopts[k] + '&'; | ||
+ | } | ||
+ | } | ||
+ | ifr.attr('src', src); | ||
+ | jqe.append(ifr); | ||
+ | } | ||
+ | |||
+ | var defoptions = { | ||
+ | autoplay: false, | ||
+ | user: null, | ||
+ | player: createPlayer, | ||
+ | playeropts: {}, | ||
+ | loaded: function() {}, | ||
+ | playopts: { | ||
+ | fs: 1, | ||
+ | showinfo: 1, | ||
+ | modestbranding: 1 | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | $.fn.extend({ | ||
+ | youTubeChannel: function(options) { | ||
+ | var md = $(this); | ||
+ | var allopts = $.extend(true, {}, defoptions, options); | ||
+ | $.getJSON('http://gdata.youtube.com/feeds/api/users/' + allopts.user + '/uploads?alt=jsonc&v=2', null, function(data) { | ||
+ | var videos = []; | ||
+ | var playlist = ''; | ||
+ | $.each(data.data.items, function(i, item) { | ||
+ | videos.push(item.id); | ||
+ | if (i > 0) | ||
+ | playlist += item.id + ','; | ||
+ | }); | ||
+ | allopts.playopts.playlist = playlist; | ||
+ | allopts.player(md, videos[0], allopts); | ||
+ | }); | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | })(); | ||
$(function() { | $(function() { | ||
Line 93: | Line 147: | ||
<div id="images"></div> | <div id="images"></div> | ||
<p><a href="/Team:NYU_Gallatin/Notebook/Photos" class="more-link">More Photos</a></p> | <p><a href="/Team:NYU_Gallatin/Notebook/Photos" class="more-link">More Photos</a></p> | ||
- | + | </div> | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
</div> | </div> | ||
<div id="block-block-5" class="block block-block"> | <div id="block-block-5" class="block block-block"> | ||
Line 137: | Line 156: | ||
<div id="featured_video"></div> | <div id="featured_video"></div> | ||
<p><a href="/Notebook/Videos" class="more-link">More Videos</a></p> | <p><a href="/Notebook/Videos" class="more-link">More Videos</a></p> | ||
- | + | </div> | |
</div> | </div> | ||
<div id="block-block-6" class="block block-block"> | <div id="block-block-6" class="block block-block"> |
Revision as of 21:08, 26 September 2012