MediaWiki:Common.js: Difference between revisions
Created page with "→Any JavaScript here will be loaded for all users on every page load.: function copiarNavi(mapa, y, x) { const texto = `/navi ${mapa},${y},${x}`; if (navigator.clipboard) { navigator.clipboard.writeText(texto).then(() => { mw.notify(`Copiado: ${texto}`); }); } else { // fallback antigo const temp = document.createElement("textarea"); temp.value = texto; document.body.appendChild(temp); t..." |
No edit summary |
||
| Line 1: | Line 1: | ||
/ | // Copiar /navi mapa,x,y pro clipboard | ||
function | function naviCopy(map, x, y) { | ||
const | const text = "/navi " + map + "," + x + "," + y; | ||
if (navigator.clipboard) { | // tenta API Clipboard | ||
navigator.clipboard.writeText( | if (navigator.clipboard && window.isSecureContext) { | ||
mw.notify( | navigator.clipboard.writeText(text).then(function() { | ||
mw.notify("Copiado: " + text); | |||
}); | }); | ||
} else { | } else { | ||
// fallback | // fallback | ||
const | const ta = document.createElement("textarea"); | ||
ta.value = text; | |||
document.body.appendChild( | document.body.appendChild(ta); | ||
ta.select(); | |||
document.execCommand("copy"); | document.execCommand("copy"); | ||
document.body.removeChild( | document.body.removeChild(ta); | ||
mw.notify( | mw.notify("Copiado: " + text); | ||
} | } | ||
} | } | ||
Revision as of 14:52, 26 January 2026
// Copiar /navi mapa,x,y pro clipboard
function naviCopy(map, x, y) {
const text = "/navi " + map + "," + x + "," + y;
// tenta API Clipboard
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(text).then(function() {
mw.notify("Copiado: " + text);
});
} else {
// fallback
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);
}
}