MediaWiki:Common.js

De Farmland
Revisão de 17h41min de 15 de maio de 2026 por Adm.mayuka (discussão | contribs)
Ir para navegação Ir para pesquisar

Nota: Após publicar, 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)
  • Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5.
  • Opera: Pressione Ctrl-F5.
/* =======================================================
   CARROSSEL UNIFICADO - WIKI EVERLIGHT
   ======================================================= */
mw.loader.using(['jquery', 'mediawiki.util'], function () {
    $(function() {
        const $wrapper = $('.carousel-wrapper');
        const $items = $('.carousel-item');
        const $next = $('.right-btn');
        const $prev = $('.left-btn');
        
        if (!$wrapper.length) return; // Só executa se o carrossel existir na página

        let current = 0;
        let autoPlayTimer;

        function updateCarousel() {
            // Atualiza a classe ativa para o efeito visual de destaque
            $items.removeClass('active').eq(current).addClass('active');

            const activeItem = $items.get(current);
            const scrollPosition = 
                activeItem.offsetLeft - 
                ($wrapper.width() / 2) + 
                ($(activeItem).outerWidth() / 2);

            $wrapper.stop().animate({
                scrollLeft: scrollPosition
            }, 500);
        }

        // Funções de Navegação
        function moveNext() {
            current = (current + 1) % $items.length;
            updateCarousel();
        }

        function movePrev() {
            current = (current - 1 + $items.length) % $items.length;
            updateCarousel();
        }

        // Eventos de Clique
        $next.on('click', function() {
            stopAutoPlay();
            moveNext();
        });

        $prev.on('click', function() {
            stopAutoPlay();
            movePrev();
        });

        // Auto-Play (4 segundos)
        function startAutoPlay() {
            autoPlayTimer = setInterval(moveNext, 4000);
        }

        function stopAutoPlay() {
            clearInterval(autoPlayTimer);
        }

        // Inicialização
        updateCarousel();
        startAutoPlay();

        // Pausa o carrossel se o mouse estiver em cima
        $wrapper.hover(stopAutoPlay, startAutoPlay);
    });
});


/* =======================================================
   ARVORE HABILIDADE - WIKI EVERLIGHT
   ======================================================= */


document.addEventListener('DOMContentLoaded', () => {
    const cards = document.querySelectorAll('.skill-card');

    cards.forEach(card => {
        card.addEventListener('click', () => {
            const skillName = card.querySelector('.skill-name').innerText;
            console.log(`Habilidade clicada: ${skillName}`);
            
            // Exemplo de efeito visual simples
            card.style.filter = "brightness(1.2)";
            setTimeout(() => {
                card.style.filter = "brightness(1)";
            }, 150);
        });
    });
});

document.querySelectorAll('.carousel-track').forEach(track => {
  track.addEventListener('mouseenter', () => {
    track.querySelectorAll('.carousel-item').forEach(item => {
      item.style.animationPlayState = 'paused';
    });
  });
  track.addEventListener('mouseleave', () => {
    track.querySelectorAll('.carousel-item').forEach(item => {
      item.style.animationPlayState = 'running';
    });
  });
});

/* =======================================================
   BOTAO SUBIR TOPO DA PAGINA
   ======================================================= */
$(function() {
    var $button = $('<button id="back-to-top" title="Voltar ao Topo">↑ Topo</button>');
    $('body').append($button);

    $(window).scroll(function() {
        // Verifica se a posição atual + altura da janela é maior que o tamanho total - 100px
        if ($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
            $button.fadeIn();
        } else {
            $button.fadeOut();
        }
    });

    $button.click(function() {
        $('html, body').animate({scrollTop: 0}, 'slow');
        return false;
    });
});


/* =======================================================
   clases testee
   ======================================================= */
document.addEventListener('DOMContentLoaded', function() {
    const cells = document.querySelectorAll('.ragnarok-tree td[class^="evo-"]');

    cells.forEach(cell => {
        // 1. Tornar a célula inteira clicável (redirecionar para o link de texto)
        const link = cell.querySelector('a');
        if (link) {
            cell.style.cursor = 'pointer';
            cell.addEventListener('click', () => { window.location.href = link.href; });
        }

        // 2. Lógica de Hover (Conexão Hierárquica)
        cell.addEventListener('mouseenter', function() {
            const familyClass = Array.from(this.classList).find(c => c.startsWith('evo-')); // ex: evo-sw
            if (!familyClass || familyClass === 'evo-all') return;

            const myPos = this.getAttribute('data-pos'); // Pega 0, 1 ou 2
            const isClass1 = this.closest('table').previousElementSibling?.innerText.includes('Classe 1');
            const isClass2 = this.closest('table').previousElementSibling?.innerText.includes('Classe 2');

            if (isClass1) {
                // Passou no Espadachim: Acende Cav/Temp e Lorde/Paladino
                document.querySelectorAll(`.${familyClass}`).forEach(el => el.classList.add('highlight-active'));
            } else if (isClass2) {
                // Passou no Cavaleiro (pos 0): Acende ele mesmo e o Lorde (pos 0 na Trans)
                this.classList.add('highlight-active'); // Acende si mesmo
                const transRelated = document.querySelector('table:nth-of-type(3)').querySelectorAll(`.${familyClass}`);
                
                // Procura na Transclasse quem tem a mesma posição
                transRelated.forEach(el => {
                    if(el.getAttribute('data-pos') === myPos) {
                        el.classList.add('highlight-active');
                    }
                });
            } else {
                // Passou na Trans: Acende apenas ela mesma
                this.classList.add('highlight-active');
            }
        });

        cell.addEventListener('mouseleave', function() {
            document.querySelectorAll('.highlight-active').forEach(el => el.classList.remove('highlight-active'));
        });
    });
});


$(document).ready(function() {
    // Evita duplicar se a página recarregar
    if ($('.sidebar-logo').length === 0) {
        var logoHtml = '<div class="sidebar-logo">' +
                       '<a href="/everlight/index.php/Página_principal">' +
                       '<img src="http://78.142.242.9/everlight/images/b/b0/Logo_Quadrada.png" alt="Logo Everlight">' +
                       '</a>' +
                       '</div>';
        
        // Coloca a logo no topo do painel lateral
        $('#mw-panel').prepend(logoHtml);
    }
});

document.addEventListener("DOMContentLoaded", function () {

    const carousel = document.querySelector("#farmlandCarousel");

    if (!carousel) return;

    const container = carousel.querySelector(".carousel-container");
    const slides = carousel.querySelectorAll(".carousel-slide");
    const dotsContainer = carousel.querySelector(".carousel-dots");

    const prevBtn = carousel.querySelector(".carousel-arrow.left");
    const nextBtn = carousel.querySelector(".carousel-arrow.right");

    let currentIndex = 0;
    let autoSlide;

    // CRIAR BOLINHAS
    slides.forEach((_, index) => {
        const dot = document.createElement("span");
        dot.classList.add("carousel-dot");

        if (index === 0) {
            dot.classList.add("active");
        }

        dot.addEventListener("click", () => {
            goToSlide(index);
        });

        dotsContainer.appendChild(dot);
    });

    const dots = carousel.querySelectorAll(".carousel-dot");

    function updateCarousel() {
        container.style.transform =
            `translateX(-${currentIndex * 100}%)`;

        dots.forEach(dot => dot.classList.remove("active"));
        dots[currentIndex].classList.add("active");
    }

    function goToSlide(index) {
        currentIndex = index;

        if (currentIndex >= slides.length) {
            currentIndex = 0;
        }

        if (currentIndex < 0) {
            currentIndex = slides.length - 1;
        }

        updateCarousel();
    }

    function nextSlide() {
        currentIndex++;
        goToSlide(currentIndex);
    }

    function prevSlide() {
        currentIndex--;
        goToSlide(currentIndex);
    }

    nextBtn.addEventListener("click", nextSlide);
    prevBtn.addEventListener("click", prevSlide);

    // AUTO SLIDE
    function startAutoSlide() {
        autoSlide = setInterval(nextSlide, 4000);
    }

    function stopAutoSlide() {
        clearInterval(autoSlide);
    }

    // PAUSAR AO PASSAR MOUSE
    carousel.addEventListener("mouseenter", stopAutoSlide);
    carousel.addEventListener("mouseleave", startAutoSlide);

    startAutoSlide();
});





document.addEventListener("DOMContentLoaded", function () {

    const carousel = document.getElementById("farmlandCarousel");

    if (!carousel) return;

    const container = carousel.querySelector(".carousel-container");
    const slides = carousel.querySelectorAll(".carousel-slide");

    const prev = carousel.querySelector(".left");
    const next = carousel.querySelector(".right");

    const dotsContainer = carousel.querySelector(".carousel-dots");

    let index = 0;
    let interval;

    // CRIAR DOTS
    slides.forEach((slide, i) => {

        const dot = document.createElement("span");

        dot.classList.add("carousel-dot");

        if (i === 0) {
            dot.classList.add("active");
        }

        dot.addEventListener("click", function () {
            index = i;
            updateCarousel();
        });

        dotsContainer.appendChild(dot);
    });

    const dots = carousel.querySelectorAll(".carousel-dot");

    function updateCarousel() {

        container.style.transform =
            `translateX(-${index * 100}%)`;

        dots.forEach(dot => {
            dot.classList.remove("active");
        });

        dots[index].classList.add("active");
    }

    function nextSlide() {

        index++;

        if (index >= slides.length) {
            index = 0;
        }

        updateCarousel();
    }

    function prevSlide() {

        index--;

        if (index < 0) {
            index = slides.length - 1;
        }

        updateCarousel();
    }

    next.addEventListener("click", nextSlide);
    prev.addEventListener("click", prevSlide);

    // AUTO
    function startCarousel() {
        interval = setInterval(nextSlide, 4000);
    }

    function stopCarousel() {
        clearInterval(interval);
    }

    carousel.addEventListener("mouseenter", stopCarousel);
    carousel.addEventListener("mouseleave", startCarousel);

    startCarousel();

});