MediaWiki:Timeless.js
From Ghost Theory Wiki
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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
```
mw.loader.using('mediawiki.util').then(function () {
/* Add arrows to all custom portlets */
document.querySelectorAll('#mw-panel .mw-portlet').forEach(portlet => {
const header = portlet.querySelector('h3');
if (!header) return;
header.classList.add('portlet-header');
const arrow = document.createElement('span');
arrow.className = 'portlet-arrow';
arrow.textContent = '▼';
header.appendChild(arrow);
header.addEventListener('click', () => {
const body = portlet.querySelector('.mw-portlet-body');
body.classList.toggle('collapsed');
arrow.classList.toggle('collapsed');
});
});
/* Year collapsible logic */
document.querySelectorAll('#mw-panel .mw-portlet-body > ul > li').forEach(yearItem => {
const header = yearItem.querySelector(':scope > a');
const sublist = yearItem.querySelector(':scope > ul');
if (!header || !sublist) return;
header.classList.add('year-header');
const arrow = document.createElement('span');
arrow.className = 'year-arrow';
arrow.textContent = '▼';
header.appendChild(arrow);
sublist.classList.add('year-content');
sublist.style.display = 'none';
header.addEventListener('click', e => {
e.preventDefault();
sublist.classList.toggle('expanded');
arrow.classList.toggle('collapsed');
sublist.style.display = sublist.classList.contains('expanded') ? 'block' : 'none';
});
});
});
```
