mediawiki-skin-crystal/resources/main.js
2025-10-12 21:41:53 +11:00

24 lines
1.1 KiB
JavaScript

// This is the skin's only javascript file. If you want to add more JS files, you need to include them in skin.json's ResourceModules section, the way this one is.
// The wrapper function is needed to make sure all of the mediawiki JS is loaded before the page's is, and load relevant parts for use here.
mw.loader.using( [
'mediawiki.jqueryMsg'
] ).then( () => {
// This gets the user's current username, and puts it the user menu button.
const username = mw.user.getName();
const button = document.getElementById('site-header-user').children[0];
if (username) {
button.textContent = username;
} else {
button.textContent = mw.message( 'login' ).text();
}
// This replaces the text of the print link with the current 'print' system message.
const print = document.getElementById('page-action-print').children[0];
print.textContent = mw.message( 'print' ).text();
const toctitle = document.getElementById('site-nav-toc').children[0];
toctitle.textContent = mw.message( 'toc' ).text();
}
)