Select Git revision
mediarack.js
mediarack.js 9.17 KiB
var showLimit = 5;
var showOffset = 0;
var loadShows = true;
var movieLimit = 5;
var movieOffset = 0;
var loadMovies = true;
$(document).ready(function() {
getLatest();
getShows();
getMovies();
$(".nav a").on('click',function(e) {
e.preventDefault();
$('.content').hide();
$(".nav li").removeClass('active');
$(this).parent().addClass('active');
window.scrollTo(0, 0);
$($(this).attr('href')).show();
});
$(window).scroll(function(){
if ($(window).scrollTop()+200 >= ($(document).height() - ($(window).height()))){
if ($("#shows").is(":visible") && loadShows == true) {
loadShows = false;
getShows();
}
if ($("#movies").is(":visible") && loadMovies == true) {
loadMovies = false;
getMovies();
}
}
});
});
function getLatest() {
$.getJSON('api.php', {
'type': 'shows',
'get': 'latest'
}, function(data) {
$.each(data, function (key, ep) {
var ulLatestContainer = $("#latestShows");
var liLatestItem = $('<li><img src="api.php?get=poster&show='+escape(ep.show)+'" /><div class="epLabel">'+ep.show+'<br />'+ep.episode+'<br />'+ep.name+'<br />'+ep.airdate+'</div></li>');
ulLatestContainer.append(liLatestItem);
});
$('.jcarousel')
.on('jcarousel:create jcarousel:reload', function() {
var element = $(this),
width = element.innerWidth();
if (width > 1000) {
width = width / 5;
} else if (width > 800) {
width = width / 4;
} else if (width > 590) {
width = width / 3;
} else if (width < 590) {
width = width / 2;
}
element.jcarousel('items').css('width', width + 'px');
})
.jcarousel({
wrap: 'both'
});
$('.jcarousel-control-prev')
.on('jcarouselcontrol:active', function() {
$(this).removeClass('inactive');