Mudanças entre as edições de "MediaWiki:Common.js"

De Wiki PrimeRO
Ir para navegação Ir para pesquisar
(Criou página com '→‎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; dis...')
 
 
(4 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 Copy JQuery Code by Kaddy!
 
$('.navi-copy').each(function(index, element) {
 
if ($("#navi-copy-textarea").attr('exists') != "true") {
// This function is used to automatically copy the Navi information to the user clipboard.
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>';
// The data parameters are received from the Template:NaviLink.
$("body").append(txtdiv);
function copyNaviLink() {
}
    if ($('.naviText').length > 0) {
var map = $(element).children().get(0).innerHTML;
        $('.naviText').each(function () {
var x = $(element).children().get(1).innerHTML;
            var naviLink = $(this);
var y = $(element).children().get(2).innerHTML;
            var copiedMessage = naviLink.next();
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;\">Copied!</div>";
 
    $(element).html(newhtml);
            var map = naviLink.attr('data-map');
});
            var x = naviLink.attr('data-x');
function CopyNaviLink(ele, map, x, y) {
            var y = naviLink.attr('data-y');
element = $(ele);
 
sibling = element.siblings();
            naviLink.click({ map: map, x: x, y: y }, function () {
width = element.width();
                // Context is used to keep the right 'this' reference, it's needed for setTimeOut to work properly.
height = element.height()+0;
                var context = $(this);
sibling.css('width',width);
var copiedText = ["/navi "+map+" "+x+"/"+y].filter(Boolean).join(" ");
sibling.css('height',height);
                // Temporary input used to select the text and copy, it's removed after the copy is done.
element.css('display','none');
                var inputTemp = document.createElement("input");
sibling.css('display','inline-block');
                inputTemp.setAttribute("value", copiedText);
setTimeout(function() {  
                document.body.appendChild(inputTemp);
    sibling.fadeOut().delay(300).css('display','none');
                inputTemp.select();
element.css('display','inline-block');
                document.execCommand("copy");
}, 1400);
                inputTemp.remove();
var ClipBoardText = "/navi "+map+" "+x+"/"+y;
                // Switches the text to indicate that the navi was copied and timesout after 2 seconds getting back to normal.
var textarea = document.getElementById('navi-copy-textarea');
                context.css("display", "none");
$('#navi-copy-textarea').text(ClipBoardText);
                context.next().css("display", "inline-block");
$("#navi-copy-textarea").select();
                setTimeout(function () {
document.execCommand('copy');
                    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();
})