Ativa o menu
Alternar menu de preferências
Alternar menu pessoal
Não autenticado(a)
Your IP address will be publicly visible if you make any edits.

MediaWiki:Citizen.js: mudanças entre as edições

Página de Interface do MediaWiki
Sem resumo de edição
Sem resumo de edição
Linha 1: Linha 1:
/**
/* =======================================================
* MediaWikiCitizen.js
  1. GOOGLE ANALYTICS 4 (GA4) - PRIORIDADE MÁXIMA
* Adds a functional "Copy" button to code blocks (pre, .mw-highlight, .mw-code).
  ======================================================= */
*/
(function() {
    var gaId = 'G-EMV99DJ8V4';
 
    // Carrega a biblioteca externa do Google
    var script = document.createElement('script');
    script.async = true;
    script.src = 'https://www.googletagmanager.com/gtag/js?id=' + gaId;
    document.head.appendChild(script);
 
    // Inicializa o Gtag
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', gaId);
})();


/* =======================================================
  2. BOTÃO "COPIAR" PARA BLOCOS DE CÓDIGO
  ======================================================= */
(function () {
(function () {
   'use strict';
   'use strict';


   function addCopyButtons() {
   function addCopyButtons() {
     // Select all code block containers
     // Seleciona blocos de código
     const codeBlocks = document.querySelectorAll('pre, .mw-highlight, .mw-code');
     const codeBlocks = document.querySelectorAll('pre, .mw-highlight, .mw-code');


     codeBlocks.forEach(function (block) {
     codeBlocks.forEach(function (block) {
      // Check if button already exists to prevent duplicates
       if (block.querySelector('.mw-copy-btn')) return;
       if (block.querySelector('.mw-copy-btn')) return;


      // Create the button
       const button = document.createElement('button');
       const button = document.createElement('button');
       button.className = 'mw-copy-btn';
       button.className = 'mw-copy-btn';
       button.type = 'button';
       button.type = 'button';
       button.ariaLabel = 'Copiar código';
       button.ariaLabel = 'Copiar código';
     
      // Ícone Copiar (SVG)
      button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>';


      // Icon (SVG)
      button.innerHTML = `
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
          <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
        </svg>
      `;
      // Add click event
       button.addEventListener('click', function () {
       button.addEventListener('click', function () {
        // Get text content
         const code = block.innerText || block.textContent;
         const code = block.innerText || block.textContent;
        // Copy to clipboard
         navigator.clipboard.writeText(code).then(function () {
         navigator.clipboard.writeText(code).then(function () {
          // Success feedback
           button.classList.add('copied');
           button.classList.add('copied');
           const originalHTML = button.innerHTML;
           const originalHTML = button.innerHTML;
 
           // Ícone Check
           // Change icon to checkmark temporarily
           button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>';
           button.innerHTML = `
            
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
              <polyline points="20 6 9 17 4 12"></polyline>
            </svg>
           `;
 
           setTimeout(function () {
           setTimeout(function () {
             button.classList.remove('copied');
             button.classList.remove('copied');
             button.innerHTML = originalHTML;
             button.innerHTML = originalHTML;
           }, 2000);
           }, 2000);
        }).catch(function (err) {
          console.error('Failed to copy: ', err);
         });
         });
       });
       });


      // Append button to the block
      // Ensure relative positioning on block so button positions correctly
       if (getComputedStyle(block).position === 'static') {
       if (getComputedStyle(block).position === 'static') {
         block.style.position = 'relative';
         block.style.position = 'relative';
Linha 65: Linha 62:
   }
   }


   // Run on load
   // Carregamento e Observador
   if (document.readyState === 'loading') {
   if (document.readyState === 'loading') {
     document.addEventListener('DOMContentLoaded', addCopyButtons);
     document.addEventListener('DOMContentLoaded', addCopyButtons);
Linha 72: Linha 69:
   }
   }


  // Optional: Observer for dynamic content (if MediaWiki loads content via AJAX)
   const observer = new MutationObserver(function (mutations) {
   const observer = new MutationObserver(function (mutations) {
     mutations.forEach(function (mutation) {
     mutations.forEach(function (mutation) {
Linha 80: Linha 76:
     });
     });
   });
   });
 
 
   observer.observe(document.body, { childList: true, subtree: true });
   observer.observe(document.body, { childList: true, subtree: true });
})();


})();


/* --- JAVASCRIPT SUBMENUS --- */
/* =======================================================
  3. MENUS DO SIMULADOR ERP (jQuery)
  ======================================================= */
$(function() {
$(function() {
    // Lógica de abertura dos submenus
     $('body').on('click', '[class*="erp-click-"]', function(e) {
     $('body').on('click', '[class*="erp-click-"]', function(e) {
         e.preventDefault();
         e.preventDefault();
Linha 94: Linha 93:
         var targetId = '';
         var targetId = '';


        // Mapeamento COMPLETO
         if (botao.hasClass('erp-click-principal')) targetId = '#submenu-principal';
         if (botao.hasClass('erp-click-principal')) targetId = '#submenu-principal';
         else if (botao.hasClass('erp-click-estoque')) targetId = '#submenu-estoque';
         else if (botao.hasClass('erp-click-estoque')) targetId = '#submenu-estoque';
Linha 120: Linha 118:
     });
     });


    // Fechar ao clicar fora
     $('body').on('click', '.erp-content-stage, .erp-bg-logo', function() {
     $('body').on('click', '.erp-content-stage, .erp-bg-logo', function() {
         $('.erp-submenu-overlay').hide();
         $('.erp-submenu-overlay').hide();
Linha 125: Linha 124:
     });
     });
});
});
/* =======================================================
  GOOGLE ANALYTICS 4 (GA4) - RASTREAMENTO
  ID da Métrica: G-EMV99DJ8V4 (CeltaWiki)
  ======================================================= */
(function() {
    var gaId = 'G-EMV99DJ8V4';
    // 1. Carrega a biblioteca externa do Google
    var script = document.createElement('script');
    script.async = true;
    script.src = 'https://www.googletagmanager.com/gtag/js?id=' + gaId;
    document.head.appendChild(script);
    // 2. Inicializa o Gtag
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', gaId);
})();

Edição das 12h04min de 10 de dezembro de 2025

/* =======================================================
   1. GOOGLE ANALYTICS 4 (GA4) - PRIORIDADE MÁXIMA
   ======================================================= */
(function() {
    var gaId = 'G-EMV99DJ8V4'; 

    // Carrega a biblioteca externa do Google
    var script = document.createElement('script');
    script.async = true;
    script.src = 'https://www.googletagmanager.com/gtag/js?id=' + gaId;
    document.head.appendChild(script);

    // Inicializa o Gtag
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', gaId);
})();


/* =======================================================
   2. BOTÃO "COPIAR" PARA BLOCOS DE CÓDIGO
   ======================================================= */
(function () {
  'use strict';

  function addCopyButtons() {
    // Seleciona blocos de código
    const codeBlocks = document.querySelectorAll('pre, .mw-highlight, .mw-code');

    codeBlocks.forEach(function (block) {
      if (block.querySelector('.mw-copy-btn')) return;

      const button = document.createElement('button');
      button.className = 'mw-copy-btn';
      button.type = 'button';
      button.ariaLabel = 'Copiar código';
      
      // Ícone Copiar (SVG)
      button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>';

      button.addEventListener('click', function () {
        const code = block.innerText || block.textContent;
        navigator.clipboard.writeText(code).then(function () {
          button.classList.add('copied');
          const originalHTML = button.innerHTML;
          // Ícone Check
          button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>';
          
          setTimeout(function () {
            button.classList.remove('copied');
            button.innerHTML = originalHTML;
          }, 2000);
        });
      });

      if (getComputedStyle(block).position === 'static') {
        block.style.position = 'relative';
      }
      block.appendChild(button);
    });
  }

  // Carregamento e Observador
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', addCopyButtons);
  } else {
    addCopyButtons();
  }

  const observer = new MutationObserver(function (mutations) {
    mutations.forEach(function (mutation) {
      if (mutation.addedNodes.length) {
        addCopyButtons();
      }
    });
  });
  
  observer.observe(document.body, { childList: true, subtree: true });
})();


/* =======================================================
   3. MENUS DO SIMULADOR ERP (jQuery)
   ======================================================= */
$(function() {
    // Lógica de abertura dos submenus
    $('body').on('click', '[class*="erp-click-"]', function(e) {
        e.preventDefault();
        e.stopPropagation();

        var botao = $(this);
        var targetId = '';

        if (botao.hasClass('erp-click-principal')) targetId = '#submenu-principal';
        else if (botao.hasClass('erp-click-estoque')) targetId = '#submenu-estoque';
        else if (botao.hasClass('erp-click-financeiro')) targetId = '#submenu-financeiro';
        else if (botao.hasClass('erp-click-vendas')) targetId = '#submenu-vendas';
        else if (botao.hasClass('erp-click-compras')) targetId = '#submenu-compras';
        else if (botao.hasClass('erp-click-gerencial')) targetId = '#submenu-gerencial';
        else if (botao.hasClass('erp-click-pessoal')) targetId = '#submenu-pessoal';
        else if (botao.hasClass('erp-click-supermercado')) targetId = '#submenu-supermercado';
        else if (botao.hasClass('erp-click-ferramentas')) targetId = '#submenu-ferramentas';

        if (!targetId) return;

        var submenu = $(targetId);

        if (submenu.is(':visible')) {
            submenu.hide();
            botao.removeClass('active');
        } else {
            $('.erp-submenu-overlay').hide();
            $('.erp-menu-item').removeClass('active');
            submenu.show();
            botao.addClass('active');
        }
    });

    // Fechar ao clicar fora
    $('body').on('click', '.erp-content-stage, .erp-bg-logo', function() {
        $('.erp-submenu-overlay').hide();
        $('.erp-menu-item').removeClass('active');
    });
});