MediaWiki:Common.js: Difference between revisions

From Coral Island Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
var config = mw.config.values;
// Load personal JS if any
importScript('User:'+config.wgUserName+'/common.js');
// Load site JS
importScript('MediaWiki:BetterUpload.js');
// Add navigational keybinds
// Add navigational keybinds
mw.hook('wikipage.content').add(function(){
mw.hook('wikipage.content').add(function(){
var config = mw.config.get(['wgAction']);
var actions = {
var actions = {
e: 'edit',
e: 'edit',

Revision as of 03:51, 10 July 2024

var config = mw.config.values;

// Load personal JS if any
importScript('User:'+config.wgUserName+'/common.js');

// Load site JS
importScript('MediaWiki:BetterUpload.js');

// Add navigational keybinds
mw.hook('wikipage.content').add(function(){
	var actions = {
		e: 'edit',
		h: 'history',
		m: 'move',
		d: 'delete',
	};
	if (config.wgAction=='view') {
		var newUrl = new URL(document.location.href);
		$(document).on('keydown', function(e) {
			var key = e.key.toLocaleLowerCase();
			if (actions[key]) {
				newUrl.searchParams.set('action', actions[key]);
				document.location.href=newUrl.href;
			}
		});
	}
});