Jump to content

MediaWiki:Common.js: Difference between revisions

From Continuum Universes Wiki
Line 1: Line 1:
$(function() {
mw.hook('wikipage.content').add(function () {
   fetch('/api.php?action=query&meta=siteinfo&siprop=statistics&format=json')
   const el = document.getElementById("article-countdown");
  if (!el) return;
 
  el.textContent = "Loading article count…";
 
  const apiUrl =
    mw.util.wikiScript('api') +
    "?action=query&meta=siteinfo&siprop=statistics&format=json&origin=*";
 
  fetch(apiUrl)
     .then(res => res.json())
     .then(res => res.json())
     .then(data => {
     .then(data => {
Line 6: Line 15:
       const goal = 1000;
       const goal = 1000;
       const left = goal - current;
       const left = goal - current;
      const el = document.getElementById("article-countdown");
 
       if (el) {
       el.innerHTML = left > 0
        el.innerHTML = left > 0
        ? `🚧 Only <strong>${left}</strong> articles to go until 1000!`
          ? `🚧 Only <strong>${left}</strong> articles to go until 1000!`
        : `🎯 We've reached 1000 articles! Let's Go Boyz and Girlz!`;
          : `🎯 We've reached 1000 articles! Let's Go Boyz and Girlz!`;
    })
       }
    .catch(err => {
      el.textContent = "API request failed (check console).";
       console.error(err);
     });
     });
});
});
// MediaWiki:Common.js
// MediaWiki:Common.js
mw.hook('rcfilters.ui.initialized').add(function () {
mw.hook('rcfilters.ui.initialized').add(function () {
   document.documentElement.classList.add('rcfilters-ready');
   document.documentElement.classList.add('rcfilters-ready');
});
});

Revision as of 22:29, 28 December 2025

mw.hook('wikipage.content').add(function () {
  const el = document.getElementById("article-countdown");
  if (!el) return;

  el.textContent = "Loading article count…";

  const apiUrl =
    mw.util.wikiScript('api') +
    "?action=query&meta=siteinfo&siprop=statistics&format=json&origin=*";

  fetch(apiUrl)
    .then(res => res.json())
    .then(data => {
      const current = data.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 (check console).";
      console.error(err);
    });
});

// MediaWiki:Common.js
mw.hook('rcfilters.ui.initialized').add(function () {
  document.documentElement.classList.add('rcfilters-ready');
});