// Current Date
var content_creator_dateEl = document.getElementById('date');
if ( content_creator_dateEl ) {
  content_creator_dateEl.innerHTML = new Date().toLocaleDateString('en-US', {
    year: 'numeric',
    month: 'long',
    day: 'numeric'
  });
}

// Youtuber Slider
jQuery(document).ready(function() {
  jQuery('.youtuber-section .owl-carousel').owlCarousel({
    loop: true,
    margin: 30,
    nav: true,
    navText: ["<i class='fas fa-chevron-left'></i>", "<i class='fas fa-chevron-right'></i>"],
    dots: false,
    rtl: false,
    responsive: {
      0: {
        items: 1,
      },
      600: {
        items: 2
      },
      992: {
        items: 3,
      },
      1200: {
        items: 4,
      }
    },
    autoplay: true,
  });
});

// Category Slider
jQuery(document).ready(function($) {
  var content_creator_slideNames = ['#1', '#2', '#3', '#4', '#5', '#6'];
  var $content_creator_carousel = $('.trending-section .grid-row');
  $content_creator_carousel.addClass('owl-carousel');
  $content_creator_carousel.owlCarousel({
    loop: true,
    margin: 30,
    nav: true,
    navText: [
      "<i class='fas fa-chevron-left'></i>",
      "<i class='fas fa-chevron-right'></i>"
    ],
    dots: false,
    rtl: false,
    autoplay: true,
    responsive: {
      0: { items: 1 },
      768: { items: 2 },
      992: { items: 3 },
      1400: { items: 4 }
    },
    onInitialized: content_creator_addSlideNumbers,
    onTranslated: content_creator_addSlideNumbers
  });

  function content_creator_addSlideNumbers(event) {
    var $content_creator_items = $content_creator_carousel.find('.owl-item');
    $content_creator_items.each(function(index) {
      var $content_creator_gtfItem = $(this).find('.gtf-item');
      $content_creator_gtfItem.find('.custom-slide-num').remove();
      var content_creator_slideIndex = (index % content_creator_slideNames.length) + 1;
      var content_creator_name = content_creator_slideNames[index % content_creator_slideNames.length];

      // Append with unique class
      $content_creator_gtfItem.append(
        '<div class="custom-slide-num custom-slide-num-' + content_creator_slideIndex + '">' + content_creator_name + '</div>'
      );
    });
  }
});

// Category SLider
jQuery(document).ready(function() {
  jQuery('.trending-section .owl-carousel').owlCarousel({
    loop: true,
    margin: 30,
    nav: true,
    navText: ["<i class='fas fa-chevron-left'></i>", "<i class='fas fa-chevron-right'></i>"],
    dots: false,
    rtl: false,
    responsive: {
      0: {
        items: 1,
      },
      768: {
        items: 2
      },
      992: {
        items: 3,
      },
      1400: {
        items: 4,
      }
    },
    autoplay: true,
  });
});

// Scroll to Top
var content_creator_scrollBtn = document.querySelector('.scroll-top-btn');
var content_creator_scrollBtnLink = document.querySelector('.scroll-top-btn a');

if ( content_creator_scrollBtn ) {
  window.onscroll = function() {
    if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
      content_creator_scrollBtn.style.display = 'block';
    } else {
      content_creator_scrollBtn.style.display = 'none';
    }
  };
}

if ( content_creator_scrollBtnLink ) {
  content_creator_scrollBtnLink.onclick = function(event) {
    event.preventDefault();
    window.scrollTo({top: 0, behavior: 'smooth'});
  };
}