MediaWiki:Mobile.js

MediaWiki interface page
Revision as of 12:43, 24 August 2022 by WikiSysop (talk | contribs) (Created page with "→‎All JavaScript here will be loaded for users of the mobile site: →‎Testing table improvements suggested here: https://medium.com/allenhwkim/mobile-friendly-table-b0cb066dbc0e: window.setMobileTable = function(selector) { // if (window.innerWidth > 600) return false; const tableEl = document.querySelector(selector); const thEls = tableEl.querySelectorAll('thead th'); const tdLabels = Array.from(thEls).map(el => el.innerText); tableEl.querySelectorAll('...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* All JavaScript here will be loaded for users of the mobile site */

/* Testing table improvements suggested here: https://medium.com/allenhwkim/mobile-friendly-table-b0cb066dbc0e */

window.setMobileTable = function(selector) {
  // if (window.innerWidth > 600) return false;
  const tableEl = document.querySelector(selector);
  const thEls = tableEl.querySelectorAll('thead th');
  const tdLabels = Array.from(thEls).map(el => el.innerText);
  tableEl.querySelectorAll('tbody tr').forEach( tr => {
    Array.from(tr.children).forEach( 
      (td, ndx) =>  td.setAttribute('label', tdLabels[ndx])
    );
  });
}