No edit summary |
No edit summary |
||
Line 28: | Line 28: | ||
function toggleSection(header) { | function toggleSection(header) { | ||
var submenu = header.nextElementSibling; | var submenu = header.nextElementSibling; | ||
var menuState = JSON.parse(localStorage.getItem('menuState') || '{}'); | |||
var menuKey = header.innerText.trim(); | |||
if (submenu.style.display === "none" || submenu.style.display === "") { | if (submenu.style.display === "none" || submenu.style.display === "") { | ||
submenu.style.display = "block"; | submenu.style.display = "block"; | ||
menuState[menuKey] = 'block'; | |||
} else { | } else { | ||
submenu.style.display = "none"; | submenu.style.display = "none"; | ||
menuState[menuKey] = 'none'; | |||
} | } | ||
localStorage.setItem('menuState', JSON.stringify(menuState)); | |||
} | } | ||
Line 40: | Line 43: | ||
window.onload = function() { | window.onload = function() { | ||
var | var menuState = JSON.parse(localStorage.getItem('menuState') || '{}'); | ||
var headers = document.querySelectorAll('.menu-header'); | |||
headers.forEach(function(header, index) { | |||
var menuKey = header.innerText.trim(); | |||
var submenu = header.nextElementSibling; | |||
if (menuState.hasOwnProperty(menuKey)) { | |||
submenu.style.display = menuState[menuKey]; | |||
} | } | ||
} | }); | ||
}; | }; | ||
})(); | })(); |
Revision as of 20:31, 26 October 2023
/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function () {
$.get(mw.util.wikiScript('api'), {
action: 'query',
meta: 'userinfo',
format: 'json'
}).done(function (data) {
if (data.query.userinfo.id !== 0) {
var username = data.query.userinfo.name;
var userLink = mw.util.getUrl('User:' + username);
$('#user-info').html('<a href="' + userLink + '" class="text-white">' + username + '</a>');
}
});
});
document.getElementById('offcanvas-toggler').addEventListener('click', function() {
var sidebar = document.getElementById('offcanvas-menu');
if (sidebar.classList.contains('show')) {
sidebar.classList.remove('show');
} else {
sidebar.classList.add('show');
}
});
(function() {
function toggleSection(header) {
var submenu = header.nextElementSibling;
var menuState = JSON.parse(localStorage.getItem('menuState') || '{}');
var menuKey = header.innerText.trim();
if (submenu.style.display === "none" || submenu.style.display === "") {
submenu.style.display = "block";
menuState[menuKey] = 'block';
} else {
submenu.style.display = "none";
menuState[menuKey] = 'none';
}
localStorage.setItem('menuState', JSON.stringify(menuState));
}
window.toggleSection = toggleSection;
window.onload = function() {
var menuState = JSON.parse(localStorage.getItem('menuState') || '{}');
var headers = document.querySelectorAll('.menu-header');
headers.forEach(function(header, index) {
var menuKey = header.innerText.trim();
var submenu = header.nextElementSibling;
if (menuState.hasOwnProperty(menuKey)) {
submenu.style.display = menuState[menuKey];
}
});
};
})();
$(document).ready(function() {
$('#offcanvas-close').on('click', function() {
$('#offcanvas-menu').removeClass('show');
});
});
This page was edited 146 days ago on 08/26/2024. What links here