MediaWiki:Common.js
Nota: Após publicar, você pode ter que limpar o "cache" do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5.
- Opera: Pressione Ctrl-F5.
// Navi clicável: {{Navi|mapa|x|y}} -> copia /navi mapa x y
mw.loader.using('mediawiki.util').then(function () {
document.addEventListener('click', function (e) {
var el = e.target.closest('.navi-copy');
if (!el) return;
var map = el.getAttribute('data-map');
var x = el.getAttribute('data-x');
var y = el.getAttribute('data-y');
var text = '/navi ' + map + ' ' + x + ' ' + y;
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(function () {
mw.notify('Comando copiado: ' + text);
}, function () {
alert('Comando: ' + text);
});
} else {
var temp = document.createElement('textarea');
temp.value = text;
document.body.appendChild(temp);
temp.select();
document.execCommand('copy');
document.body.removeChild(temp);
mw.notify('Comando copiado: ' + text);
}
});
});