MediaWiki:Common.js

De SimplesWiki
Revisão de 13h10min de 9 de janeiro de 2025 por Simplesdev (discussão | contribs)
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)

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)
  • Internet Explorer/Edge: PressioneCtrl enquanto clica Recarregar, ou Pressione Ctrl-F5
  • Opera: Pressione Ctrl-F5.
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
// Adiciona função para voltar ao topo
// Adiciona função para voltar ao topo
function addScrollToTopButton() {
    // Cria o botão
    var button = document.createElement('span');
    button.id = 'scrollToTopButton';
    button.textContent = '↑';
    button.style.display = 'inline-block';
    button.style.width = '30px';
    button.style.height = '30px';
    button.style.backgroundColor = '#007BFF';
    button.style.color = 'white';
    button.style.fontSize = '20px';
    button.style.borderRadius = '50%';
    button.style.cursor = 'pointer';
    button.style.textAlign = 'center';
    button.style.lineHeight = '30px';
    button.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.2)';
    button.style.position = 'fixed';
    button.style.bottom = '20px';
    button.style.right = '20px';
    button.style.zIndex = '1000';

    // Adiciona o evento de clique
    button.onclick = function () {
        window.scrollTo(0, 0);
    };

    // Adiciona o botão ao corpo da página
    document.body.appendChild(button);
}

// Executa a função quando a página é carregada
if (typeof document.addEventListener === 'function') {
    document.addEventListener('DOMContentLoaded', addScrollToTopButton, false);
} else if (typeof document.attachEvent === 'function') {
    document.attachEvent('onreadystatechange', function () {
        if (document.readyState === 'complete') {
            addScrollToTopButton();
        }
    });
}