Skip to content
Snippets Groups Projects
Select Git revision
2 results Searching

mediarack.js

Blame
  • mediarack.js 5.90 KiB
    var showLimit = 5;
    var showOffset = 0;
    var killScroll = false;
    
    $(document).ready(function() {
    
    	getLatest();
    	getShows();
    	
    	$(".nav a").on('click',function(e) {
    		e.preventDefault();
    		$('.content').hide();
    		$(".nav li").removeClass('active');
    		$(this).parent().addClass('active');
    		$($(this).attr('href')).show();
    	});
    	
    	$(window).scroll(function(){
    		if  ($(window).scrollTop()+200 >= ($(document).height() - ($(window).height()))){
    			if (killScroll == false) {
    				killScroll = true;
    				getShows();
    			}
    		}
    	});
    
    });
    
    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').jcarousel({
    				wrap: 'both'
    			});
    			$('.jcarousel-control-prev')
    				.on('jcarouselcontrol:active', function() {
    					$(this).removeClass('inactive');
    				})
    				.on('jcarouselcontrol:inactive', function() {
    					$(this).addClass('inactive');
    				})
    				.jcarouselControl({
    					target: '-=1'
    				});
    
    			$('.jcarousel-control-next')
    				.on('jcarouselcontrol:active', function() {
    					$(this).removeClass('inactive');
    				})
    				.on('jcarouselcontrol:inactive', function() {
    					$(this).addClass('inactive');
    				})
    				.jcarouselControl({
    					target: '+=1'
    				});
    
    		}
    	);
    }
    
    function getShows() {
    	$.getJSON('api.php', {
    		'get': 'shows',