MediaWiki:Common.js: Difference between revisions

fixed the redirect not firing on its own on real phones
Tag: Reverted
gave the mobile menu some actual links
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
$(document).ready(function() {
    $('#ca-nstab-main a').text('Article');
    $('#ca-history a').text('History');
    $('#ca-view a').text('Read');
});
// ==========================================================================
// ==========================================================================
// Force the branded desktop (Vector) skin for everyone, including phones.
// Minerva (mobile skin) main menu only ships Home/Random by default; it does
// The site auto-switches to MediaWiki's generic Minerva mobile skin based
// not pull in MediaWiki:Sidebar the way Vector's portlets do. This injects
// on user-agent, which has none of the custom theme/nav and is a much
// the same section links (kept in sync with MediaWiki:Sidebar by hand) into
// worse experience than the (now mobile-responsive) desktop skin.
// the native menu markup so mobile visitors actually get real navigation
//
// instead of just Home/Random/Settings/About/Disclaimers.
// The server does set a loop-guard cookie on the toggle ("stopMobileRedirect"),
// but it's HttpOnly (confirmed by testing), so client-side JS can never
// actually read it - that check would always be dead code. sessionStorage
// is the only guard we can use here, wrapped in its own try/catch so a
// browser that blocks storage access doesn't cancel the whole redirect.
//
// This used to bail out permanently if document.body wasn't available yet
// ("if (!document.body) return"), with no retry. Real-device testing (real
// Safari/Chrome on iOS - NOT reproducible by spoofing the user-agent string
// in a desktop Electron/Chromium test, since that never runs WebKit at all)
// showed the redirect worked fine when triggered manually via URL, but never
// fired on its own: this script runs before <body> exists in some real
// mobile browsers, so it needs to wait for DOMContentLoaded instead of
// giving up on the first check.
(function () {
(function () {
   function tryForceDesktop() {
   function initMinervaNav() {
     try {
     try {
       if (!document.body || !document.body.classList.contains('skin-minerva')) return;
       if (!document.body || !document.body.classList.contains('skin-minerva')) return;
       var alreadyTried = false;
       var nav = document.getElementById('p-navigation');
       try { alreadyTried = !!sessionStorage.getItem('wovForcedDesktop'); } catch (e) {}
       if (!nav || document.getElementById('wov-minerva-extra-nav')) return;
       if (alreadyTried) return;
 
       try { sessionStorage.setItem('wovForcedDesktop', '1'); } catch (e) {}
      var sections = [
      var sep = window.location.search ? '&' : '?';
        { heading: 'Guides', items: [
      window.location.href = window.location.pathname + window.location.search + sep + 'mobileaction=toggle_view_desktop';
          ['Getting started', '/w/Getting_Started'],
    } catch (e) {
          ['Interactive Map (Fullscreen)', 'https://jxlife.github.io/WindsOfValenMap/'],
       // if even the basic checks are blocked, just leave the user on Minerva
          ['All skills', '/w/Skills'],
       // rather than risk breaking the rest of the site's scripts.
          ['All quests', '/w/Quests'],
     }
          ['Combat guide', '/w/Combat']
        ]},
        { heading: 'Database', items: [
          ['Item database', '/w/Items'],
          ['NPC database', '/w/NPCs'],
          ['Set bonuses', '/w/Set_bonuses']
        ]},
        { heading: 'Skills', items: [
          ['Skill Calculator', '/w/Calculators'],
          ['Mining', '/w/Mining'],
          ['Smithing', '/w/Smithing'],
          ['Fishing', '/w/Fishing'],
          ['Potion Making', '/w/Potion_Making']
        ]},
        { heading: 'Tools', items: [
          ['About this wiki', '/w/Project:About'],
          ['Random page', '/w/Special:Random'],
          ['New files', '/w/Special:NewFiles'],
          ['Wanted pages', '/w/Special:WantedPages'],
          ['Wiki statistics', '/w/Special:Statistics']
        ]},
        { heading: 'Updates', items: [
          ['Recent changes', '/w/Special:RecentChanges']
        ]}
       ];
 
      var container = document.createElement('div');
       container.id = 'wov-minerva-extra-nav';
 
      sections.forEach(function (section) {
        var heading = document.createElement('div');
        heading.className = 'wov-minerva-nav-heading';
        heading.textContent = section.heading;
        container.appendChild(heading);
 
        var ul = document.createElement('ul');
        ul.className = 'toggle-list__list';
        section.items.forEach(function (item) {
          var li = document.createElement('li');
          li.className = 'toggle-list-item';
          var a = document.createElement('a');
          a.className = 'toggle-list-item__anchor';
          a.href = item[1];
          var label = document.createElement('span');
          label.className = 'toggle-list-item__label';
          label.textContent = item[0];
          a.appendChild(label);
          li.appendChild(a);
          ul.appendChild(li);
        });
        container.appendChild(ul);
       });
 
       nav.parentNode.insertBefore(container, nav.nextSibling);
     } catch (e) {}
   }
   }
   if (document.body) {
   if (document.body) {
     tryForceDesktop();
     initMinervaNav();
   } else {
   } else {
     document.addEventListener('DOMContentLoaded', tryForceDesktop);
     document.addEventListener('DOMContentLoaded', initMinervaNav);
   }
   }
})();
})();
$(document).ready(function() {
    $('#ca-nstab-main a').text('Article');
    $('#ca-history a').text('History');
    $('#ca-view a').text('Read');
});
// ==========================================================================
// ==========================================================================
// Valen Ledger — Gathering & Combat XP Calculator
// Valen Ledger — Gathering & Combat XP Calculator