MediaWiki:Common.js

De Ragna4th
Revisão de 01h24min de 15 de janeiro de 2022 por Nameless (discussão | contribs)
Ir para navegação Ir para pesquisar

Nota: Após salvar, 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)
  • Internet Explorer: PressioneCtrl enquanto clica Recarregar, ou Pressione Ctrl-F5
  • Opera: Vá para Menu → Configurações (Opera → Preferencias no Mac) e depois para Privacidade e Segurança → Limpar dados de navegação → Imagens e arquivos em cache.
/* 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;
                // 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);
            }
            );
        });
    }
}