Jump to content

MediaWiki:Common.js: Difference between revisions

 
(30 intermediate revisions by the same user not shown)
Line 1: Line 1:
mw.loader.load('https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js');
mw.hook('wikipage.content').add(function () {
mw.loader.load('https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.css', 'text/css');
  const el = document.getElementById('article-countdown');
mw.loader.load('https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.css', 'text/css');
  console.log('countdown hook fired; element is:', el);


mw.hook('wikipage.content').add(function($content) {
  if (!el) return;
    $content.find('.mw-jsslideshow .slideshow').each(function() {
  el.textContent = '✅ Countdown JS is running…';
        const $slideshow = $(this);


        $slideshow.slick({
  const apiUrl = mw.util.wikiScript('api') +
            infinite: true,
    '?action=query&meta=siteinfo&siprop=statistics&format=json&origin=*';
            slidesToShow: 1,
            slidesToScroll: 1,
            autoplay: true,
            autoplaySpeed: 5000,
            arrows: true,
            dots: true,
            adaptiveHeight: true
        });


        // Keep the slideshow fresh if the window resizes
  fetch(apiUrl)
        $(window).on('resize', function() {
    .then(r => r.json())
            $slideshow.slick('setPosition');
    .then(d => {
        });
      const current = d.query.statistics.articles;
      const goal = 1000;
      const left = goal - current;
 
      el.innerHTML = left > 0
        ? `🚧 Only <strong>${left}</strong> articles to go until 1000!`
        : `🎯 We've reached 1000 articles! Let's Go Boyz and Girlz!`;
    })
    .catch(err => {
      el.textContent = 'API request failed (see console).';
      console.error(err);
     });
     });
});
// MediaWiki:Common.js
mw.hook('rcfilters.ui.initialized').add(function () {
  document.documentElement.classList.add('rcfilters-ready');
});
});