Mudanças entre as edições de "MediaWiki:Common.js"
Ir para navegação
Ir para pesquisar
| (3 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
| Linha 1: | Linha 1: | ||
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */ | /* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */ | ||
// Navi | |||
// This function is used to automatically copy the Navi information to the user clipboard. | |||
// The data parameters are received from the Template:NaviLink. | |||
function copyNaviLink() { | |||
if ($('.naviText').length > 0) { | |||
$('.naviText').each(function () { | |||
var naviLink = $(this); | |||
var copiedMessage = naviLink.next(); | |||
var map = naviLink.attr('data-map'); | |||
var x = naviLink.attr('data-x'); | |||
var y = naviLink.attr('data-y'); | |||
naviLink.click({ map: map, x: x, y: y }, function () { | |||
// Context is used to keep the right 'this' reference, it's needed for setTimeOut to work properly. | |||
var context = $(this); | |||
var copiedText = ["/navi "+map+" "+x+"/"+y].filter(Boolean).join(" "); | |||
// Temporary input used to select the text and copy, it's removed after the copy is done. | |||
var inputTemp = document.createElement("input"); | |||
inputTemp.setAttribute("value", copiedText); | |||
document.body.appendChild(inputTemp); | |||
inputTemp.select(); | |||
document.execCommand("copy"); | |||
inputTemp.remove(); | |||
// Switches the text to indicate that the navi was copied and timesout after 2 seconds getting back to normal. | |||
context.css("display", "none"); | |||
context.next().css("display", "inline-block"); | |||
setTimeout(function () { | |||
context.css("display", "inline-block"); | |||
} | context.next().css("display", "none"); | ||
}, 2000); | |||
} | |||
); | |||
}); | |||
} | |||
}; | |||
$(document).ready(function() { | |||
//novaMarketPrices(); | |||
copyNaviLink(); | |||
}) | |||
Edição atual tal como às 16h45min de 23 de junho de 2023
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
// This function is used to automatically copy the Navi information to the user clipboard.
// The data parameters are received from the Template:NaviLink.
function copyNaviLink() {
if ($('.naviText').length > 0) {
$('.naviText').each(function () {
var naviLink = $(this);
var copiedMessage = naviLink.next();
var map = naviLink.attr('data-map');
var x = naviLink.attr('data-x');
var y = naviLink.attr('data-y');
naviLink.click({ map: map, x: x, y: y }, function () {
// Context is used to keep the right 'this' reference, it's needed for setTimeOut to work properly.
var context = $(this);
var copiedText = ["/navi "+map+" "+x+"/"+y].filter(Boolean).join(" ");
// Temporary input used to select the text and copy, it's removed after the copy is done.
var inputTemp = document.createElement("input");
inputTemp.setAttribute("value", copiedText);
document.body.appendChild(inputTemp);
inputTemp.select();
document.execCommand("copy");
inputTemp.remove();
// Switches the text to indicate that the navi was copied and timesout after 2 seconds getting back to normal.
context.css("display", "none");
context.next().css("display", "inline-block");
setTimeout(function () {
context.css("display", "inline-block");
context.next().css("display", "none");
}, 2000);
}
);
});
}
};
$(document).ready(function() {
//novaMarketPrices();
copyNaviLink();
})