MediaWiki:Timeless.js: Difference between revisions

From Ephinea PSO Wiki
(Created page with "→‎All JavaScript here will be loaded for users of the Timeless skin: function toggleDarkMode() { const darkMode = localStorage.getItem("darkMode"); if (darkMode !== "tru...")
 
m (Protected "MediaWiki:Timeless.js" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the Timeless skin */
/* Any JavaScript here will be loaded for all users on every page load. */


function toggleDarkMode() {
/* Sets the top property for stickyHeader tables */
const darkMode = localStorage.getItem("darkMode");
function setStickyHeaderTop() {
if (darkMode !== "true") {
  const stickyTables = document.getElementsByClassName('stickyHeader');
    localStorage.setItem("darkMode", true);
  const headHeight = document.getElementById('mw-header-container').offsetHeight;
document.body.classList.add("darkMode");
  for (var i = 0; i < stickyTables.length; i++) {
} else {
    const firstRow = stickyTables[i].getElementsByClassName('headerRow-0');
    localStorage.setItem("darkMode", false);
    const secondRow = stickyTables[i].getElementsByClassName('headerRow-1');
document.body.classList.remove("darkMode");
    var firstHeight = 0;
}
    if (firstRow.length > 0) {
      firstHeight = firstRow[0].offsetHeight;
      const firstHeaders = firstRow[0].getElementsByTagName('th');
      for (var j = 0; j < firstHeaders.length; j++) {
        firstHeaders[j].style.top = headHeight + 'px';
      }
      if (secondRow.length > 0) {
        const secondHeaders = secondRow[0].getElementsByTagName('th');
        var secondHeight = headHeight + firstHeight;
        for (var j = 0; j < secondHeaders.length; j++) {
          secondHeaders[j].style.top = secondHeight + 'px';
        }
      }
    }
  }
}
}
/*$(".more_info").click(function () {
    var $title = $(this).find(".title");
    if (!$title.length) {
        $(this).append('<span class="title">' + $(this).attr("title") + '</span>');
    } else {
        $title.remove();
    }
});*/

Latest revision as of 20:40, 3 October 2022

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

/* Sets the top property for stickyHeader tables */
function setStickyHeaderTop() {
  const stickyTables = document.getElementsByClassName('stickyHeader');
  const headHeight = document.getElementById('mw-header-container').offsetHeight;
  for (var i = 0; i < stickyTables.length; i++) {
    const firstRow = stickyTables[i].getElementsByClassName('headerRow-0');
    const secondRow = stickyTables[i].getElementsByClassName('headerRow-1');
    var firstHeight = 0;
    if (firstRow.length > 0) {
      firstHeight = firstRow[0].offsetHeight;
      const firstHeaders = firstRow[0].getElementsByTagName('th');
      for (var j = 0; j < firstHeaders.length; j++) {
        firstHeaders[j].style.top = headHeight + 'px';
      }
      if (secondRow.length > 0) {
        const secondHeaders = secondRow[0].getElementsByTagName('th');
        var secondHeight = headHeight + firstHeight;
        for (var j = 0; j < secondHeaders.length; j++) {
          secondHeaders[j].style.top = secondHeight + 'px';
        }
      }
    }
  }
}

/*$(".more_info").click(function () {
    var $title = $(this).find(".title");
    if (!$title.length) {
        $(this).append('<span class="title">' + $(this).attr("title") + '</span>');
    } else {
        $title.remove();
    }
});*/