MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
(Blanked the page) Tag: Blanking |
No edit summary |
||
Line 1: | Line 1: | ||
// Add navigational keybinds | |||
mw.hook('wikipage.content').add(function(){ | |||
var config = mw.config.get(['wgAction']); | |||
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; | |||
} | |||
}); | |||
} | |||
}); |
Revision as of 03:35, 10 July 2024
// Add navigational keybinds
mw.hook('wikipage.content').add(function(){
var config = mw.config.get(['wgAction']);
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;
}
});
}
});