MediaWiki:Common.js

Jump to navigation Jump to search
No edit summary
No edit summary
 
(12 intermediate revisions by the same user not shown)
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. */


var toc, toggleLink;
var ts_alternate_row_colors = true;
try {
 
  toc = document.getElementById('toc').getElementsByTagName('ul')[0];
// collapss the TOC by default
  toggleLink = document.getElementById('toctogglecheckbox');
function hideToc() {  
  // if (tocIsHidden()) {
    document.getElementById('toctogglecheckbox').click();
  toggleToc();
  // }
} catch (error) {
  console.log('erred', error);
}
function tocIsHidden () {
    return !toc || !toggleLink || window.getComputedStyle(toc).display !== 'block';
}
}


function toggleToc() {
hideToc();
  var hidden = tocIsHidden();
  if (hidden && document.cookie.indexOf('hidetoc=0') > -1) {
    toggleLink.click();
    // changeText(toggleLink, tocShowText);
    // toc.style.display = 'none';
  } else if (!hidden && document.cookie.indexOf('hidetoc=1') > -1) {
    toggleLink.click();
    // changeText(toggleLink, tocHideText);
    // toc.style.display = 'block';
  }
}
toggleLink && toggleLink.addEventListener('click', function () {
  var isHidden = tocIsHidden();
  document.cookie = isHidden
    ? "hidetoc=1"
    : "hidetoc=0";
});

Latest revision as of 14:43, 21 June 2021

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

var ts_alternate_row_colors = true;

// collapss the TOC by default 
function hideToc() { 
    document.getElementById('toctogglecheckbox').click();
}

hideToc();