Jump to content

MediaWiki:Common.js

From EthernalRO Wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Script para copiar navegação */
$(function() {
    // Usa 'body' para garantir que funcione mesmo em elementos carregados dinamicamente
    $('body').on('click', '.navi-link', function(e) {
        e.preventDefault();
        var $this = $(this);
        var map = $this.data('map');
        var x = $this.data('x');
        var y = $this.data('y');
        
        // Remove espaços extras caso existam
        if(map) map = map.trim();
        
        var command = '/navi ' + map + ' ' + x + '/' + y;
        
        // Cria elemento invisível para copiar
        var $temp = $("<input>");
        $("body").append($temp);
        $temp.val(command).select();
        document.execCommand("copy");
        $temp.remove();
        
        // Feedback visual
        var $msg = $this.find('.navi-msg');
        $msg.show().fadeOut(2000);
    });
});