MediaWiki:Common.js
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', function () {
$(function () {
if ($('#handwiki-topnav').length) {
return;
}
var sidebarLinks = [];
$('#mw-panel a').each(function () {
var text = $(this).text().trim();
var href = $(this).attr('href');
if (text && href) {
sidebarLinks.push({
text: text,
href: href
});
}
});
var topnav = $('<div>', {
id: 'handwiki-topnav'
});
var sidebarMenu = $('<div>', {
class: 'handwiki-dropdown'
});
var sidebarButton = $('<div>', {
class: 'handwiki-dropdown-button',
text: 'Sidebar ▾'
});
var sidebarContent = $('<div>', {
class: 'handwiki-dropdown-content'
});
sidebarLinks.forEach(function (link) {
sidebarContent.append(
$('<a>', {
href: link.href,
text: link.text
})
);
});
sidebarMenu.append(sidebarButton);
sidebarMenu.append(sidebarContent);
var secondMenu = $('<div>', {
class: 'handwiki-dropdown'
});
var secondButton = $('<div>', {
class: 'handwiki-dropdown-button',
text: 'Quantum ▾'
});
var secondContent = $('<div>', {
class: 'handwiki-dropdown-content'
});
secondContent.append($('<a>', {
href: '/index.php/Book:Quantum_Collection',
text: 'Quantum Collection'
}));
secondContent.append($('<a>', {
href: '/index.php/Book:Quantum_Collection/Matter_(by_scale)',
text: 'Matter by scale'
}));
secondContent.append($('<a>', {
href: '/index.php/Book:Quantum_Collection/Methods_and_tools',
text: 'Methods and tools'
}));
secondContent.append($('<a>', {
href: '/index.php/Special:RecentChanges',
text: 'Recent changes'
}));
secondContent.append($('<a>', {
href: '/index.php/Special:SpecialPages',
text: 'Special pages'
}));
secondMenu.append(secondButton);
secondMenu.append(secondContent);
topnav.append(sidebarMenu);
topnav.append(secondMenu);
$('body').append(topnav);
});
});