Skip to content

Instantly share code, notes, and snippets.

@jakebellacera
Created August 30, 2011 17:58
Show Gist options
  • Save jakebellacera/1181533 to your computer and use it in GitHub Desktop.
Save jakebellacera/1181533 to your computer and use it in GitHub Desktop.
Slideshows for g(c)
/* Replace the below element with the Slideshow */
var $slideshow = $('#banner').html('');
/* Pull in the JSON feed, place into divs */
$(window).load(function() {
$.ajax({
url : '/api/json/features/HOME_SLIDESHOW',
dataType : 'json',
success : function(data) {
$.each(data, function(i, slide) {
var $slide = $('<div class="section slide_' + (i + 1) + '" />'),
$content = $('<div class="content" />');
$slide.append($content);
if(slide.source.match(/(flv|mp4|m4v)$/i)) {
// Video
var $video = $('<div id="video_player-' + i + '">').player(slide.source, {
mode : 'flash'
});
$content
.append($video);
} else if(slide.source.match(/(jpe?g|png|gif)$/i)) {
// Image
$content
.append('<img src="' + slide.source + '" alt="' + slide.title + '"/>');
if(slide.url !== '') {
$content.wrapInner('<a href="' + slide.url + '" />');
}
} else {
// Custom
$slide.find('.content').text('custom');
}
$slideshow.append($slide);
});
/* Do a simpleslider */
$slideshow.simpleslider({
transition : 'slide',
auto : true,
interval : 15000 /* 15 seconds. You might want to change this value */
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment