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.
/* === AureumRO Wiki JS ====================================== */
/**
* Copia comando /navi para o clipboard e mostra notificação toast.
* Uso: <button onclick="aurNaviCopy('prontera', '200/156')">Copiar /navi</button>
*/
function aurNaviCopy(mapa, coords) {
var cmd = '/navi ' + mapa + ' ' + coords;
var showToast = function (success) {
var t = document.createElement('div');
t.className = 'aur-toast';
if (success) {
t.innerHTML = '<span class="aur-toast-bar"></span>' +
'<span><strong>Comando copiado</strong><br>' +
'<small>' + cmd + '</small></span>';
} else {
t.innerHTML = '<span class="aur-toast-bar aur-toast-bar-err"></span>' +
'<span><strong>Não consegui copiar</strong><br>' +
'<small>' + cmd + '</small></span>';
}
document.body.appendChild(t);
requestAnimationFrame(function () { t.classList.add('aur-toast-show'); });
setTimeout(function () {
t.classList.add('aur-toast-out');
setTimeout(function () { t.remove(); }, 320);
}, 2200);
};
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(cmd).then(
function () { showToast(true); },
function () { showToast(false); }
);
} else {
// Fallback antigo
var ta = document.createElement('textarea');
ta.value = cmd;
ta.style.position = 'fixed';
ta.style.opacity = '0';
document.body.appendChild(ta);
ta.select();
try {
var ok = document.execCommand('copy');
showToast(!!ok);
} catch (e) {
showToast(false);
}
ta.remove();
}
}
window.aurNaviCopy = aurNaviCopy;
/**
* Copia um texto qualquer (comando, link) para o clipboard e mostra o mesmo toast.
* Uso: <span onclick="aurCopy('/verify')">/verify</span>
*/
function aurCopy(text) {
var showToast = function (success) {
var t = document.createElement('div');
t.className = 'aur-toast';
var label = success ? 'Copiado' : 'Não consegui copiar';
t.innerHTML = '<span class="aur-toast-bar' + (success ? '' : ' aur-toast-bar-err') + '"></span>' +
'<span><strong>' + label + '</strong><br><small>' + text + '</small></span>';
document.body.appendChild(t);
requestAnimationFrame(function () { t.classList.add('aur-toast-show'); });
setTimeout(function () {
t.classList.add('aur-toast-out');
setTimeout(function () { t.remove(); }, 320);
}, 2200);
};
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(
function () { showToast(true); },
function () { showToast(false); }
);
} else {
var ta = document.createElement('textarea');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
document.body.appendChild(ta);
ta.select();
try { showToast(!!document.execCommand('copy')); } catch (e) { showToast(false); }
ta.remove();
}
}
window.aurCopy = aurCopy;