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

De Micropedia
Ir para navegação Ir para pesquisar
(limpeza)
(ajuste)
Linha 1: Linha 1:
 
/* =========================================================
 
/* =========================================================
  Micropédia — Common.js otimizado
+
Micropédia — Common.js otimizado
  ========================================================= */
+
========================================================= */
  
 
jQuery(document).ready(function ($) {
 
jQuery(document).ready(function ($) {
  
    /* =====================================================
+
/* =====================================================
      1. BOTÃO "VOLTAR AO TOPO" (único e otimizado)
+
1. BOTÃO "VOLTAR AO TOPO" (único e otimizado)
      ===================================================== */
+
===================================================== */
    let $topo = $('#botaoTopo');
+
let $topo = $('#botaoTopo');
  
    if ($topo.length === 0) {
+
if ($topo.length === 0) {
        $topo = $('<div id="botaoTopo">⬆ Topo</div>').css({
+
$topo = $('<div id="botaoTopo">⬆ Topo</div>').css({
            position: 'fixed',
+
position: 'fixed',
            bottom: '20px',
+
bottom: '20px',
            right: '20px',
+
right: '20px',
            padding: '8px 14px',
+
padding: '8px 14px',
            background: '#9bbeab',
+
background: '#9bbeab',
            color: '#1a3a28',
+
color: '#1a3a28',
            borderRadius: '8px',
+
borderRadius: '8px',
            cursor: 'pointer',
+
cursor: 'pointer',
            boxShadow: '0 2px 6px rgba(0,0,0,0.25)',
+
boxShadow: '0 2px 6px rgba(0,0,0,0.25)',
            fontWeight: 'bold',
+
fontWeight: 'bold',
            fontSize: '13px',
+
fontSize: '13px',
            zIndex: 9999,
+
zIndex: 9999,
            display: 'none'
+
display: 'none'
        });
+
});
        $('body').append($topo);
+
$('body').append($topo);
    }
+
}
  
    $(window).on('scroll.mph', function () {
+
$(window).on('scroll.mph', function () {
        $topo.toggle($(this).scrollTop() > 400);
+
$topo.toggle($(this).scrollTop() > 400);
    });
+
});
  
    $topo.on('click', function () {
+
$topo.on('click', function () {
        $('html, body').animate({ scrollTop: 0 }, 300);
+
$('html, body').animate({ scrollTop: 0 }, 300);
    });
+
});
  
  
Linha 41: Linha 41:
 
       2. APLICAÇÕES VISUAIS (APENAS NA PÁGINA PRINCIPAL)
 
       2. APLICAÇÕES VISUAIS (APENAS NA PÁGINA PRINCIPAL)
 
       ===================================================== */
 
       ===================================================== */
    if (mw.config.get("wgPageName") !== "Página_principal") return;
+
if (mw.config.get("wgPageName") !== "Página_principal") return;
  
    /* Cards com borda arredondada correta */
+
/* Cards com borda arredondada correta */
    $('table.mph-card').css({
+
$('table.mph-card').css({
        borderRadius: '10px',
+
borderRadius: '10px',
        borderCollapse: 'separate',
+
borderCollapse: 'separate',
        overflow: 'hidden'
+
overflow: 'hidden'
    });
+
});
  
    /* Links externos abrem em nova aba */
+
/* Links externos abrem em nova aba */
    $('.mph-card a[href^="http"]')
+
$('.mph-card a[href^="http"]')
        .not('a[href*="' + window.location.hostname + '"]')
+
.not('a[href*="' + window.location.hostname + '"]')
        .attr({ target: '_blank', rel: 'noopener noreferrer' });
+
.attr({ target: '_blank', rel: 'noopener noreferrer' });
  
    /* Hover suave nas imagens */
+
/* Hover suave nas imagens */
    $('.mph-card li img').css({
+
$('.mph-card li img').css({
        verticalAlign: 'middle',
+
verticalAlign: 'middle',
        transition: 'transform 0.15s ease'
+
transition: 'transform 0.15s ease'
    }).on('mouseenter', function () {
+
}).on('mouseenter', function () {
        $(this).css('transform', 'scale(1.06)');
+
$(this).css('transform', 'scale(1.06)');
    }).on('mouseleave', function () {
+
}).on('mouseleave', function () {
        $(this).css('transform', 'scale(1)');
+
$(this).css('transform', 'scale(1)');
    });
+
});
  
    /* Oculta título redundante */
+
/* Oculta título redundante */
    $('#firstHeading').hide();
+
$('#firstHeading').hide();
  
 
});
 
});
Linha 77: Linha 77:
 
mw.hook('wikipage.editform').add(function () {
 
mw.hook('wikipage.editform').add(function () {
  
    /* Não aplicar para administradores */
+
/* Não aplicar para administradores */
    if (mw.config.get("wgUserGroups").includes("sysop")) return;
+
if (mw.config.get("wgUserGroups").includes("sysop")) return;
  
    const form = document.getElementById('editform');
+
const form = document.getElementById('editform');
    if (!form) return;
+
if (!form) return;
  
    form.addEventListener('submit', function (e) {
+
form.addEventListener('submit', function (e) {
  
        const answer = prompt("Verificação rápida: quanto é 7 + 3?");
+
const answer = prompt("Verificação rápida: quanto é 7 + 3?");
  
        if (answer !== "10") {
+
if (answer !== "10") {
            alert("Resposta incorreta. Tente novamente.");
+
alert("Resposta incorreta. Tente novamente.");
            e.preventDefault();
+
e.preventDefault();
        }
+
}
  
    });
+
});
 
});
 
});

Edição das 00h55min de 14 de abril de 2026

/* =========================================================
Micropédia — Common.js otimizado
========================================================= */

jQuery(document).ready(function ($) {

/* =====================================================
1. BOTÃO "VOLTAR AO TOPO" (único e otimizado)
===================================================== */
let $topo = $('#botaoTopo');

if ($topo.length === 0) {
$topo = $('<div id="botaoTopo">⬆ Topo</div>').css({
position: 'fixed',
bottom: '20px',
right: '20px',
padding: '8px 14px',
background: '#9bbeab',
color: '#1a3a28',
borderRadius: '8px',
cursor: 'pointer',
boxShadow: '0 2px 6px rgba(0,0,0,0.25)',
fontWeight: 'bold',
fontSize: '13px',
zIndex: 9999,
display: 'none'
});
$('body').append($topo);
}

$(window).on('scroll.mph', function () {
$topo.toggle($(this).scrollTop() > 400);
});

$topo.on('click', function () {
$('html, body').animate({ scrollTop: 0 }, 300);
});


    /* =====================================================
       2. APLICAÇÕES VISUAIS (APENAS NA PÁGINA PRINCIPAL)
       ===================================================== */
if (mw.config.get("wgPageName") !== "Página_principal") return;

/* Cards com borda arredondada correta */
$('table.mph-card').css({
borderRadius: '10px',
borderCollapse: 'separate',
overflow: 'hidden'
});

/* Links externos abrem em nova aba */
$('.mph-card a[href^="http"]')
.not('a[href*="' + window.location.hostname + '"]')
.attr({ target: '_blank', rel: 'noopener noreferrer' });

/* Hover suave nas imagens */
$('.mph-card li img').css({
verticalAlign: 'middle',
transition: 'transform 0.15s ease'
}).on('mouseenter', function () {
$(this).css('transform', 'scale(1.06)');
}).on('mouseleave', function () {
$(this).css('transform', 'scale(1)');
});

/* Oculta título redundante */
$('#firstHeading').hide();

});


/* =========================================================
   3. ANTI-SPAM (CAPTCHA SIMPLES)
   ========================================================= */

mw.hook('wikipage.editform').add(function () {

/* Não aplicar para administradores */
if (mw.config.get("wgUserGroups").includes("sysop")) return;

const form = document.getElementById('editform');
if (!form) return;

form.addEventListener('submit', function (e) {

const answer = prompt("Verificação rápida: quanto é 7 + 3?");

if (answer !== "10") {
alert("Resposta incorreta. Tente novamente.");
e.preventDefault();
}

});
});