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

De Wiki PrimeRO
Ir para navegação Ir para pesquisar
Etiqueta: Revertido
 
(2 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);
}
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() {
function copyNaviLink() {
     if ($('.naviText').length > 0) {
     if ($('.naviText').length > 0) {
Linha 25: Linha 17:
                 // Context is used to keep the right 'this' reference, it's needed for setTimeOut to work properly.  
                 // Context is used to keep the right 'this' reference, it's needed for setTimeOut to work properly.  
                 var context = $(this);
                 var context = $(this);
                var copiedText = "/navi " + map + " " + x + "/" + y;
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.
                 // Temporary input used to select the text and copy, it's removed after the copy is done.
                 var inputTemp = document.createElement("input");
                 var inputTemp = document.createElement("input");
Linha 44: Linha 36:
         });
         });
     }
     }
}
};
 
$(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();
})