Mudanças entre as edições de "MediaWiki:Common.js"
Ir para navegação
Ir para pesquisar
Etiqueta: Revertido |
|||
| Linha 12: | Linha 12: | ||
$(element).html(newhtml); | $(element).html(newhtml); | ||
}); | }); | ||
function | 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; | |||
// 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); | |||
} | |||
); | |||
}); | |||
} | |||
} | } | ||
Edição das 02h45min de 10 de dezembro de 2022
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
// Navi Copy JQuery Code by Kaddy!
$('.navi-copy').each(function(index, element) {
if ($("#navi-copy-textarea").attr('exists') != "true") {
txtdiv = '<textarea style="height:1px;width:1px; position:absolute;left:-1000px;" id="navi-copy-textarea" exists="true">Filler Text</textarea><style>.navi-copy-text { cursor:pointer; color:#2899e8; padding:1px; display:inline-block; } .navi-copy-text:hover { color:#c1a1f1; } .navi-copied { text-align:center; border:1px dotted #2899e8; border-radius:3px; color:#2899e8; display:inline-block; } .navi-copy { display:inline-block; } </style>';
$("body").append(txtdiv);
}
var map = $(element).children().get(0).innerHTML;
var x = $(element).children().get(1).innerHTML;
var y = $(element).children().get(2).innerHTML;
var newhtml = "<div class=\"navi-copy-text\" title=\"Click here to copy to the clipboard, then paste in game\" onclick=\"CopyNaviLink(this, '"+map+"','"+x+"','"+y+"');\">("+map+" "+x+", "+y+")</div><div class=\"navi-copied\" style=\"display:none;\">Copiado!</div>";
$(element).html(newhtml);
});
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;
// 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);
}
);
});
}
}