Jump to content
Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
Add accessible book shortcut to 10th Edition Changelog in Citizen navigation
 
Add open-book Rules shortcut above the Changelog icon
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */


/* BEGIN NERO CHANGELOG NAVIGATION 2026-10-16 */
/* BEGIN NERO RULES NAVIGATION 2026-10-16 */
/* NERO: direct Changelog link in Citizen's navigation rail. */
/* NERO: direct Rules and Changelog links in Citizen's navigation rail. */
(function () {
(function () {
   'use strict';
   'use strict';


   function addChangelogLink() {
   function createRailLink(id, href, title, path) {
    if (!document.body || !document.body.classList.contains('skin-citizen') || document.getElementById('nero-changelog-nav')) {
      return;
    }
 
    var rail = document.querySelector('.citizen-header__start');
    if (!rail) {
      return;
    }
 
     var link = document.createElement('a');
     var link = document.createElement('a');
     link.id = 'nero-changelog-nav';
     link.id = id;
     link.className = 'citizen-header__item citizen-cdx-button--size-large cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet';
     link.className = 'citizen-header__item citizen-cdx-button--size-large cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet';
     link.href = '/index.php/10th_Edition_Changelog';
     link.href = href;
     link.title = '10th Edition Changelog';
     link.title = title;
     link.setAttribute('aria-label', '10th Edition Changelog');
     link.setAttribute('aria-label', title);


     var icon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
     var icon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
Line 36: Line 27:


     var outline = document.createElementNS('http://www.w3.org/2000/svg', 'path');
     var outline = document.createElementNS('http://www.w3.org/2000/svg', 'path');
     outline.setAttribute('d', 'M6 3h13v18H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm-2 16a2 2 0 0 1 2-2h13M14 3v8l-3-2-3 2V3');
     outline.setAttribute('d', path);
     icon.appendChild(outline);
     icon.appendChild(outline);
     link.appendChild(icon);
     link.appendChild(icon);
     rail.appendChild(link);
    return link;
  }
 
  function addRulesAndChangelogLinks() {
    if (!document.body || !document.body.classList.contains('skin-citizen')) {
      return;
    }
 
    var rail = document.querySelector('.citizen-header__start');
    if (!rail) {
      return;
    }
 
    var changelog = document.getElementById('nero-changelog-nav');
    if (!changelog) {
      changelog = createRailLink(
        'nero-changelog-nav',
        '/index.php/10th_Edition_Changelog',
        '10th Edition Changelog',
        'M6 3h13v18H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm-2 16a2 2 0 0 1 2-2h13M14 3v8l-3-2-3 2V3'
      );
    }
 
    var rules = document.getElementById('nero-rules-nav');
    if (!rules) {
      rules = createRailLink(
        'nero-rules-nav',
        '/index.php/NERO_10th_Edition_Rules',
        'NERO 10th Edition Rules',
        'M12 5C9 3 5.5 3 2 4v15c3.5-1 7-1 10 1 3-2 6.5-2 10-1V4c-3.5-1-7-1-10 1zm0 0v15M5 8c1.3-.2 2.7 0 4 .5M5 12c1.3-.2 2.7 0 4 .5M15 8.5c1.3-.5 2.7-.7 4-.5M15 12.5c1.3-.5 2.7-.7 4-.5'
      );
    }
 
     rail.appendChild(changelog);
    rail.insertBefore(rules, changelog);
   }
   }


   if (document.readyState === 'loading') {
   if (document.readyState === 'loading') {
     document.addEventListener('DOMContentLoaded', addChangelogLink, { once: true });
     document.addEventListener('DOMContentLoaded', addRulesAndChangelogLinks, { once: true });
   } else {
   } else {
     addChangelogLink();
     addRulesAndChangelogLinks();
   }
   }
}());
}());


/* END NERO CHANGELOG NAVIGATION */
/* END NERO RULES NAVIGATION */

Revision as of 22:51, 16 October 2026

/* Any JavaScript here will be loaded for all users on every page load. */

/* BEGIN NERO RULES NAVIGATION 2026-10-16 */
/* NERO: direct Rules and Changelog links in Citizen's navigation rail. */
(function () {
  'use strict';

  function createRailLink(id, href, title, path) {
    var link = document.createElement('a');
    link.id = id;
    link.className = 'citizen-header__item citizen-cdx-button--size-large cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--icon-only cdx-button--weight-quiet';
    link.href = href;
    link.title = title;
    link.setAttribute('aria-label', title);

    var icon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
    icon.setAttribute('viewBox', '0 0 24 24');
    icon.setAttribute('width', '20');
    icon.setAttribute('height', '20');
    icon.setAttribute('fill', 'none');
    icon.setAttribute('stroke', 'currentColor');
    icon.setAttribute('stroke-width', '1.7');
    icon.setAttribute('stroke-linecap', 'round');
    icon.setAttribute('stroke-linejoin', 'round');
    icon.setAttribute('aria-hidden', 'true');
    icon.setAttribute('focusable', 'false');

    var outline = document.createElementNS('http://www.w3.org/2000/svg', 'path');
    outline.setAttribute('d', path);
    icon.appendChild(outline);
    link.appendChild(icon);
    return link;
  }

  function addRulesAndChangelogLinks() {
    if (!document.body || !document.body.classList.contains('skin-citizen')) {
      return;
    }

    var rail = document.querySelector('.citizen-header__start');
    if (!rail) {
      return;
    }

    var changelog = document.getElementById('nero-changelog-nav');
    if (!changelog) {
      changelog = createRailLink(
        'nero-changelog-nav',
        '/index.php/10th_Edition_Changelog',
        '10th Edition Changelog',
        'M6 3h13v18H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm-2 16a2 2 0 0 1 2-2h13M14 3v8l-3-2-3 2V3'
      );
    }

    var rules = document.getElementById('nero-rules-nav');
    if (!rules) {
      rules = createRailLink(
        'nero-rules-nav',
        '/index.php/NERO_10th_Edition_Rules',
        'NERO 10th Edition Rules',
        'M12 5C9 3 5.5 3 2 4v15c3.5-1 7-1 10 1 3-2 6.5-2 10-1V4c-3.5-1-7-1-10 1zm0 0v15M5 8c1.3-.2 2.7 0 4 .5M5 12c1.3-.2 2.7 0 4 .5M15 8.5c1.3-.5 2.7-.7 4-.5M15 12.5c1.3-.5 2.7-.7 4-.5'
      );
    }

    rail.appendChild(changelog);
    rail.insertBefore(rules, changelog);
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', addRulesAndChangelogLinks, { once: true });
  } else {
    addRulesAndChangelogLinks();
  }
}());

/* END NERO RULES NAVIGATION */