Jump to content

MediaWiki:Common.js

From ATRONIA Wiki
Revision as of 16:24, 28 April 2026 by WikiManagement (talk | contribs)

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.
/* Any JavaScript here will be loaded for all users on every page load. */








$(function() {
    var footerHTML = 
    '<div id="custom-atronia-footer" style="background-color: #121e1c; color: #ffffff; padding: 60px 40px; font-family: sans-serif; clear: both;">' +
        '<div class="atronia-footer-container" style="display: flex; flex-wrap: wrap; justify-content: space-between; max-width: 1400px; margin: 0 auto;">' +
            
            // COLUNA ESQUERDA: CONTACTOS
            '<div style="flex: 2; min-width: 300px; margin-bottom: 40px;">' +
                '<h4 style="font-size: 14px; font-weight: bold; margin-bottom: 20px;">Visit but keep in mind we\'re busy</h4>' +
                '<p style="font-size: 14px; color: #ccc; line-height: 1.6;">Rua do Norte 9,<br>Ílhavo, 3830-167<br>Portugal</p>' +
                '<h4 style="font-size: 14px; font-weight: bold; margin-top: 35px; margin-bottom: 20px;">Contact Us</h4>' +
                '<p style="font-size: 14px; color: #ccc; line-height: 1.6;">+351 934 886 253 (Custo de chamada para rede móvel nacional)<br>info@atronia.eu</p>' +
                '<div style="margin-top: 25px; display: flex; gap: 15px;">' +
                    '<a href="https://facebook.com/atroniatech" target="_blank"><img src="https://atronia.eu/wp-content/uploads/2023/04/facebook-white.png" width="30"></a>' +
                    '<a href="https://linkedin.com/company/atronia" target="_blank"><img src="https://atronia.eu/wp-content/uploads/2023/04/linkedin-white.png" width="30"></a>' +
                    '<a href="https://instagram.com/atroniatech" target="_blank"><img src="https://atronia.eu/wp-content/uploads/2023/04/instagram-white.png" width="30"></a>' +
                '</div>' +
            '</div>' +

            // COLUNAS DE LINKS (DIREITA)
            '<div style="flex: 3; display: flex; flex-wrap: wrap; justify-content: space-between;">' +
                // MENU
                '<div class="atronia-col"><h4>Menu</h4><a href="/">Home</a><a href="/about-us/">About us</a><a href="/hardware/">Hardware</a><a href="/solutions/">Solutions</a></div>' +
                // SOLUTIONS
                '<div class="atronia-col"><h4>Solutions</h4><a href="/solutions/aquaguard/">Aquaguard</a><a href="/solutions/firefly/">Firefly</a><a href="/solutions/melisafe/">Melisafe</a><a href="/solutions/prevent/">Prevent</a></div>' +
                // SHOP
                '<div class="atronia-col"><h4>Shop</h4><a href="/product/monarch-gateway/">Monarch</a><a href="/product/atlas-sbc/">Atlas</a><a href="/product-category/probes/">Probes</a><a href="/product-category/accessories/">Accessories</a></div>' +
                // SUPPORT
                '<div class="atronia-col"><h4>Support</h4><a href="https://wiki.atronia.eu/">Wiki</a></div>' +
            '</div>' +
        '</div>' +

        // LINHA SEPARADORA
        '<hr style="border: 0; border-top: 1px solid rgba(255,255,255,0.1); margin: 40px 0;">' +

        // LOGOS POWERED & SPONSORED
        '<div style="display: flex; flex-wrap: wrap; align-items: flex-start; max-width: 1400px; margin: 0 auto; gap: 40px;">' +
            '<div><p style="font-size: 11px; color: #888; text-transform: uppercase; margin-bottom: 15px;">Powered by:</p><img src="https://atronia.eu/wp-content/uploads/2023/04/logo-igus.png" width="140"></div>' +
            '<div style="flex: 1;"><p style="font-size: 11px; color: #888; text-transform: uppercase; margin-bottom: 15px;">Co-sponsored by:</p>' +
                '<img src="https://atronia.eu/wp-content/uploads/2024/11/Co-Sponsored-by-Atronia-1024x224.png" style="max-width: 100%; height: auto; opacity: 0.9;">' +
            '</div>' +
        '</div>' +

        // BARRA FINAL
        '<div style="max-width: 1400px; margin: 40px auto 0; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.05);">' +
            '<a href="/livro-de-reclamacoes/" style="color: #ffffff; font-weight: bold; text-decoration: underline; font-size: 13px;">Livro de Reclamações</a> | ' +
            '<a href="/privacy-policy/" style="color: #ffffff; font-weight: bold; text-decoration: underline; font-size: 13px;">Privacy Policy</a>' +
            '<p style="font-size: 11px; color: #555; margin-top: 20px;">This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.</p>' +
        '</div>' +
    '</div>';

    $('#footer').before(footerHTML);
});     '</div>' +
            '<div class="atronia-col">' +
                '<h4>MENU</h4>' +
                '<a href="https://atronia.eu/">Home</a>' +
                '<a href="https://atronia.eu/about-us/">About us</a>' +
                '<a href="https://atronia.eu/hardware/">Hardware</a>' +
                '<a href="https://atronia.eu/solutions/">Solutions</a>' +
            '</div>' +
            '<div class="atronia-col">' +
                '<h4>POWERED BY</h4>' +
                '<img src="https://atronia.eu/wp-content/uploads/2023/04/logo-igus.png" width="140" style="margin-bottom:20px;">' +
                '<h4>CO-SPONSORED BY</h4>' +
                '<div style="opacity:0.6; filter:grayscale(100%);">[Logos Aqui]</div>' +
            '</div>' +
        '</div>' +
        '<div class="atronia-bottom">© ATRONIA Wiki - Tech that makes sense</div>' +
    '</div>';

    // Esta linha coloca o footer logo acima do rodapé cinzento padrão da Wiki
    $('#footer').before(footerHTML);
});








/* Forçar links de "Buy Now" a abrir em novo separador */
$(document).ready(function() {
    $('.button-buy-now a').attr('target', '_blank').attr('rel', 'noopener');
});


$(document).ready(function() {
    var footerLinks = document.getElementById('footer-places');
    if (footerLinks && !document.getElementById('footer-custom-buttons-container')) {
        var container = document.createElement('li');
        container.id = 'footer-custom-buttons-container';
        container.style.display = 'flex';
        container.style.gap = '10px';
        container.style.alignItems = 'center';

        // Botão de Topo (Seta)
        var topBtn = '<a href="#" class="footer-top-button" title="Voltar ao topo">' +
             '<span class="material-symbols-outlined">arrow_upward</span></a>';
        
        // Teu botão atual da Atronia
        var siteBtn = '<a href="https://atronia.eu" class="footer-button-atronia-real" target="_blank" rel="noopener">atronia.eu</a>';
        
        container.innerHTML = topBtn + siteBtn;
        footerLinks.appendChild(container);
        
        // Função para scroll suave ao clicar na seta
        $('.footer-top-button').click(function(e) {
            e.preventDefault();
            $('html, body').animate({scrollTop: 0}, 'slow');
        });
    }
});





/*** GOOGLE ANALYTICS Injeção correta de script externo para evitar o erro de "Parse error" ***/

var gaScript = document.createElement('script');
gaScript.src = "https://www.googletagmanager.com/gtag/js?id=G-MX174P23PW";
gaScript.async = true;
document.head.appendChild(gaScript);

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-MX174P23PW');



/* Botão de Copiar Moderno com Ícone */
$(function() {
    $('.mw-highlight').each(function() {
        var $block = $(this);
        if ($block.find('.copy-btn').length > 0) return;

        // Ícone SVG de dois quadrados (estilo moderno)
        var copyIcon = '<svg fill="none" stroke-width="2.5" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" height="1.2em" width="1.2em" xmlns="http://www.w3.org/2000/svg" style="margin-right: 8px; vertical-align: middle; stroke: white !important;">' +
                       '<rect x="9" y="9" width="13" height="13" rx="2" ry="2" style="stroke: white !important;"></rect>' +
                       '<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" style="stroke: white !important;"></path>' +
                       '</svg>';

        var $button = $('<button>')
            .html(copyIcon + '<span>Copy</span>')
            .addClass('copy-btn')
            .css({
                'position': 'absolute',
                'top': '10px',
                'right': '10px',
                'z-index': '100',
                'display': 'flex',
                'align-items': 'center',
                'padding': '6px 12px',
                'background': '#343a40', // Cor cinza escuro moderna
                'color': '#f8f9fa',      // Texto quase branco
                'border': '1px solid #495057',
                'border-radius': '6px',  // Cantos ligeiramente arredondados
                'cursor': 'pointer',
                'font-size': '12px',
                'font-family': 'sans-serif',
                'transition': 'all 0.2s ease'
            });

        // Efeito Hover (passar o rato)
        $button.hover(
            function() { $(this).css({'background': '#495057', 'border-color': '#6c757d'}); },
            function() { $(this).css({'background': '#343a40', 'border-color': '#495057'}); }
        );

        $button.on('click', function(e) {
            e.preventDefault();
            var text = $block.find('pre').text();
            
            navigator.clipboard.writeText(text).then(function() {
                // Muda o ícone e texto para "Copiado!"
                $button.find('span').text('Copied!');
                $button.css({'background': '#28a745', 'border-color': '#28a745'});

                setTimeout(function() {
                    $button.find('span').text('Copy');
                    $button.css({'background': '#343a40', 'border-color': '#495057'});
                }, 2000);
            });
        });

        $block.css('position', 'relative').prepend($button);
    });
});

/* Variations toggle arrow rotation */
$(function () {
    $('.variations-toggle').on('click', function () {
        var $arrow = $(this).find('.arrow-icon');

        // small delay to let MediaWiki toggle first
        setTimeout(() => {
            var targetId = this.className.match(/mw-customtoggle-(\d+)/);

            if (!targetId) return;

            var collapsibleId = '#mw-customcollapsible-' + targetId[1];
            var $collapsible = $(collapsibleId);

            if ($collapsible.hasClass('mw-collapsed')) {
                $arrow.removeClass('rotated');
            } else {
                $arrow.addClass('rotated');
            }
        }, 50);
    });
});