// Adds alt+shift+? as an access key to show a list of all default access keys
$(() => {
let dialog;
$('<a>').attr('accesskey', '?').text('This access keys cheat sheet').hide().click(() => {
if (dialog) {
if (dialog.isOpened()) {
dialog.close();
} else {
dialog.open({
actions: [], size: 'medium'
});
}
return false;
}
mw.loader.using('oojs-ui-windows', () => {
let winMan = new OO.ui.WindowManager();
winMan.$element.css('width', '35em').appendTo(document.body);
dialog = new OO.ui.MessageDialog();
winMan.addWindows([dialog]);
$('<table>').addClass('wikitable').css('width', '100%').append(
$('[accesskey]').map(function () {
return $('<tr>').append(
$('<th>').text(this.accessKey.toUpperCase()),
$('<td>').text(
this.getAttribute('aria-label') ||
this.title.replace(/ \[.+?\]/, '') ||
this.textContent ||
this.value ||
$(`label[for="${this.id}"]`).text()
)
);
}).get()
).appendTo(dialog.text.$element);
dialog.open({
actions: [], size: 'medium'
});
});
return false;
}).appendTo(document.body);
});