MediaWiki:Common.js
Appearance
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.
/* HamWiki: Display color in Vector's Appearance menu (added 20 October 2026) */
( function () {
if ( mw.config.get( 'skin' ) !== 'vector-2022' ) {
return;
}
var KEY = 'hw-palette';
var pals = [ [ 'blue', 'Light blue' ], [ 'green', 'Light green' ], [ 'amber', 'Amber' ], [ 'neutral', 'Neutral' ] ];
var cur = 'blue';
try {
cur = window.localStorage.getItem( KEY ) || 'blue';
} catch ( e ) {}
function apply( p ) {
pals.forEach( function ( x ) {
document.documentElement.classList.toggle( 'hw-pal-' + x[ 0 ], x[ 0 ] === p );
} );
}
apply( cur );
$( function () {
var menu = document.getElementById( 'vector-appearance' );
if ( !menu || document.getElementById( 'hw-pal-portlet' ) ) {
return;
}
var h = '<div class="vector-menu-heading">Display color</div><div class="vector-menu-content"><ul class="vector-menu-content-list"><li class="mw-list-item"><form>';
pals.forEach( function ( x ) {
var id = 'hw-pal-' + x[ 0 ] + '-radio';
h += '<div class="cdx-radio"><input name="hw-pal-group" id="' + id + '" type="radio" value="' + x[ 0 ] + '" class="cdx-radio__input"' +
( cur === x[ 0 ] ? ' checked' : '' ) + '><span class="cdx-radio__icon"></span>' +
'<label class="cdx-label cdx-radio__label" for="' + id + '"><span class="cdx-label__label__text">' + x[ 1 ] + '</span></label></div>';
} );
h += '</form></li></ul></div>';
var box = document.createElement( 'div' );
box.className = 'mw-portlet vector-menu';
box.id = 'hw-pal-portlet';
box.innerHTML = h;
box.addEventListener( 'change', function ( e ) {
if ( e.target && e.target.name === 'hw-pal-group' ) {
cur = e.target.value;
try {
window.localStorage.setItem( KEY, cur );
} catch ( err ) {}
apply( cur );
}
} );
// Keep it last in the menu, after Text, Width and Color, even when Vector rebuilds its own settings
function place() {
if ( menu.lastElementChild !== box ) {
menu.appendChild( box );
}
}
place();
new MutationObserver( place ).observe( menu, { childList: true } );
} );
}() );
/* HamWiki: "Suggest a correction" link at the end of every article (added 22 October 2026) */
( function () {
var c = mw.config.get( [ 'wgNamespaceNumber', 'wgAction', 'wgIsMainPage', 'wgArticleId', 'wgTitle' ] );
if ( c.wgNamespaceNumber !== 0 || c.wgAction !== 'view' || c.wgIsMainPage || !c.wgArticleId ) {
return;
}
$( function () {
var out = document.querySelector( '#mw-content-text .mw-parser-output' );
if ( !out || document.getElementById( 'hw-correction' ) ) {
return;
}
var url = location.origin + mw.util.getUrl( c.wgTitle );
var href = 'mailto:info@hamwiki.org?subject=' + encodeURIComponent( 'Correction: ' + c.wgTitle ) +
'&body=' + encodeURIComponent( 'Article: ' + url + '\n\nWhat needs fixing (and a source, if you have one):\n\n' );
var p = document.createElement( 'p' );
p.id = 'hw-correction';
p.className = 'hw-correction';
p.appendChild( document.createTextNode( 'Spotted a mistake or something out of date? ' ) );
var a = document.createElement( 'a' );
a.href = href;
a.textContent = 'Suggest a correction';
p.appendChild( a );
p.appendChild( document.createTextNode( '.' ) );
out.appendChild( p );
} );
}() );