MediaWiki:Common.js
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.
$(function () {
// adiciona evento de clique em elementos com classe naviCopy
document.querySelectorAll(".naviCopy").forEach(el => {
el.addEventListener("click", function () {
const mapa = el.getAttribute("data-mapa");
const x = el.getAttribute("data-x");
const y = el.getAttribute("data-y");
const text = "/navi " + mapa + "," + x + "," + y;
// copiar para clipboard
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(text).then(() => {
mw.notify("Copiado: " + text);
});
} else {
const ta = document.createElement("textarea");
ta.value = text;
document.body.appendChild(ta);
ta.select();
document.execCommand("copy");
document.body.removeChild(ta);
mw.notify("Copiado: " + text);
}
});
});
});