Jump to content

MediaWiki:Common.js: Difference between revisions

From Continuum Universes Wiki
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
mw.hook('ext.popups').add(function() {
$(function() {
    $('.mwe-popups-extract .portable-infobox').each(function() {
  fetch('/api.php?action=query&meta=siteinfo&siprop=statistics&format=json')
        var $infobox = $(this);
    .then(res => res.json())
        var $firstParagraph = $('.mwe-popups-extract p:first');
    .then(data => {
 
      const current = data.query.statistics.articles;
        // If there is a paragraph, move the infobox after it
      const goal = 500;
        if ($firstParagraph.length) {
      const left = goal - current;
            $infobox.insertAfter($firstParagraph);
      const el = document.getElementById("article-countdown");
        } else {
      if (el) {
            // If there's no paragraph, just hide the infobox
        el.innerHTML = left > 0
            $infobox.hide();
          ? `🚧 Only <strong>${left}</strong> articles to go until 500!`
        }
          : `🎯 We've reached 500 articles! Celebrate good times, c'mon!`;
      }
     });
     });
});
});
 
// MediaWiki:Common.js
<script>
mw.hook('rcfilters.ui.initialized').add(function () {
fetch('/api.php?action=query&meta=siteinfo&siprop=statistics&format=json')
   document.documentElement.classList.add('rcfilters-ready');
  .then(res => res.json())
});
   .then(data => {
    const current = data.query.statistics.articles;
    const goal = 200;
    const left = goal - current;
    const el = document.getElementById("article-countdown");
    el.innerHTML = left > 0
      ? `🚧 Only <strong>${left}</strong> articles to go until 200!`
      : `🎯 We've reached 200 articles! Celebrate good times, c'mon!`;
  });
</script>

Latest revision as of 02:36, 26 August 2025

$(function() {
  fetch('/api.php?action=query&meta=siteinfo&siprop=statistics&format=json')
    .then(res => res.json())
    .then(data => {
      const current = data.query.statistics.articles;
      const goal = 500;
      const left = goal - current;
      const el = document.getElementById("article-countdown");
      if (el) {
        el.innerHTML = left > 0
          ? `🚧 Only <strong>${left}</strong> articles to go until 500!`
          : `🎯 We've reached 500 articles! Celebrate good times, c'mon!`;
      }
    });
});
// MediaWiki:Common.js
mw.hook('rcfilters.ui.initialized').add(function () {
  document.documentElement.classList.add('rcfilters-ready');
});