Mudanças entre as edições de "Widget:VisnoTeste"

De Wiki Gla
Ir para navegação Ir para pesquisar
 
(78 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:
<!DOCTYPE html>
<!-- WEAPON TOGGLE SYSTEM - Estado global + popup -->
<html lang="pt-BR">
<script>
<head>
    (() => {
  <meta charset="UTF-8">
        let modalListenersBound = false;
  <title>Teste GIF Hover</title>
 
  <style>
        const bindModalEvents = () => {
    .personagem {
            if (modalListenersBound) return;
      width: 200px;
            modalListenersBound = true;
      height: 100px;
            document.addEventListener('click', (ev) => {
      border-radius: 10px;
                if (ev.target.closest('.weapon-modal-close') || ev.target.closest('.weapon-modal-btn')) {
      background-color: #414c5c;
                    const checkbox = document.getElementById('weapon-dont-show');
      background-image: url('https://postimg.cc/CZ0K6WjF');
                    if (checkbox && checkbox.checked) {
      background-size: 150%;
                        try { localStorage.setItem('glaWeaponPopupDismissed', '1'); } catch (x) { }
      background-position: center -30px;
                    }
      transition: transform 0.3s;
                    hidePopup();
      display: flex;
                    return;
      align-items: flex-end;
                }
      justify-content: flex-end;
                if (ev.target.classList.contains('weapon-modal-overlay')) {
      padding: 5px;
                    hidePopup();
      font-weight: bold;
                }
      font-family: sans-serif;
            });
      color: white;
        };
      text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
 
      position: relative;
const applyWeaponState = (enabled) => {
      cursor: pointer;
    const first = document.querySelector('.skill-icon');
      border: 2px solid #58aaff;
    const selected = document.querySelector('.skill-icon.selected');
      overflow: hidden;
    if (first) {
        if (selected) selected.classList.remove('selected');
        first.classList.add('selected');
    }
 
    if (typeof window.__setGlobalWeaponEnabled === 'function') {
        window.__setGlobalWeaponEnabled(enabled);
     }
     }


     .personagem span {
     try {
      z-index: 2;
        localStorage.setItem('glaWeaponEnabled', enabled ? '1' : '0');
    } catch (x) { }
 
    document.querySelectorAll('.skill-icon[data-weapon]').forEach(el => {
        if (enabled) {
            el.classList.add('has-weapon-available');
            let ind = el.querySelector('.weapon-indicator');
            if (!ind) {
                ind = document.createElement('div');
                ind.className = 'weapon-indicator';
                el.appendChild(ind);
            }
        } else {
            el.classList.remove('has-weapon-available');
            el.classList.remove('weapon-equipped');
            el.style.removeProperty('--weapon-badge-url');
            const ind = el.querySelector('.weapon-indicator');
            if (ind) ind.remove();
        }
    });
 
    const sel = document.querySelector('.skill-icon.selected');
    if (sel) {
        sel.dispatchEvent(new Event('click', { bubbles: true }));
    }
};
 
 
        const ensureModal = () => {
            let modal = document.getElementById('weapon-info-modal');
            if (modal) return modal;
            modal = document.createElement('div');
            modal.id = 'weapon-info-modal';
            modal.className = 'weapon-modal';
            modal.innerHTML = `
            <div class="weapon-modal-overlay"></div>
            <div class="weapon-modal-content">
                <div class="weapon-modal-header">
                    <h3>Visualização com Arma Especial</h3>
                    <button class="weapon-modal-close">&times;</button>
                </div>
                <div class="weapon-modal-body">
                    <p>Este modo ativa a visualização do personagem equipado com sua <strong>arma especial</strong>.</p>
                    <p>As habilidades melhoradas ficam <strong>destacadas com borda e brilho azul</strong>, mesmo quando não selecionadas.</p>
                    <p class="weapon-info-link" style="margin-top:8px;display:none"></p>
                </div>
                <div class="weapon-modal-footer">
                    <label class="weapon-modal-checkbox">
                        <input type="checkbox" id="weapon-dont-show">
                        <span>Não mostrar novamente</span>
                    </label>
                    <button class="weapon-modal-btn">Entendi</button>
                </div>
            </div>
        `;
            document.body.appendChild(modal);
            try {
                const firstWithWeapon = document.querySelector('.skill-icon[data-weapon]');
                if (firstWithWeapon) {
                    const raw = firstWithWeapon.getAttribute('data-weapon');
                    const obj = JSON.parse(raw || '{}');
                    const nm = (obj && obj.name) ? String(obj.name).trim() : '';
                    if (nm) {
                        const linkHost = (window.mw && mw.util && typeof mw.util.getUrl === 'function') ? mw.util.getUrl(nm) : ('/index.php?title=' + encodeURIComponent(nm));
                        const holder = modal.querySelector('.weapon-info-link');
                        if (holder) {
                            holder.style.display = 'block';
                            holder.innerHTML = `<a href="${linkHost}" style="color:#6BB3FF;text-decoration:none;font-weight:600">Ver página da arma: ${nm}</a>`;
                        }
                    }
                }
            } catch (_) { }
            bindModalEvents();
            return modal;
        };
 
        const showPopup = () => {
            const modal = ensureModal();
            if (modal) modal.classList.add('show');
        };
 
        const hidePopup = () => {
            const m = document.getElementById('weapon-info-modal');
            if (m) m.classList.remove('show');
        };
 
        window.__applyWeaponState = applyWeaponState;
        window.__glaWeaponShowPopup = showPopup;
        window.__glaWeaponHidePopup = hidePopup;
        try {
            window.dispatchEvent(new CustomEvent('weapon:ready', { detail: { applyWeaponState, showPopup, hidePopup } }));
        } catch (err) {
        }
 
        const boot = () => {
            // Verificar se existe alguma skill com arma
            const hasAnyWeapon = document.querySelectorAll('.skill-icon[data-weapon]').length > 0;
            if (!hasAnyWeapon) return;
 
            ensureModal();
 
            // Estado inicial do toggle
            let init = false;
            try {
                if (localStorage.getItem('glaWeaponEnabled') === '1') init = true;
            } catch (x) { }
            setTimeout(() => applyWeaponState(init), 150);
        };
 
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', boot);
        } else {
            boot();
        }
    })();
</script>
<style>
    .weapon-modal {
        position: fixed;
        inset: 0;
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        pointer-events: none;
        transition: opacity .3s;
     }
     }


     .gif-overlay {
     .weapon-modal.show {
      position: absolute;
        opacity: 1;
      inset: 0;
        pointer-events: all;
      background-repeat: no-repeat;
      background-size: 150%;
      background-position: center -30px;
      opacity: 0;
      transition: opacity 0.4s ease;
      z-index: 1;
      pointer-events: none;
     }
     }


     .personagem:hover {
     .weapon-modal-overlay {
      transform: scale(1.05);
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, .75);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
     }
     }


     .personagem:hover .gif-overlay {
     .weapon-modal-content {
      opacity: 1;
        position: relative;
     }  
        background: linear-gradient(135deg, #1f1f1f, #2a2a2a);
        border: 1px solid rgba(255, 255, 255, .12);
        border-radius: 12px;
        max-width: 420px;
        width: 90%;
        box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
        animation: modalIn .3s;
     }


     .container {
     @keyframes modalIn {
  display: flex;
        from {
  gap: 10px; /* espaçamento entre os botões */
            transform: translateY(-20px);
  flex-wrap: wrap; /* para quebrar linha se não couber */
            opacity: 0;
  justify-content: center; /* opcional: centraliza */
        }
}


        to {
            transform: translateY(0);
            opacity: 1;
        }
    }


.personagem.luffy .gif-overlay {
    .weapon-modal-header {
  background-position: center 0px; /* ajuste aqui para mover para baixo (ex: 10px, 20px...) */
        display: flex;
}
        align-items: center;
  </style>
        justify-content: space-between;
</head>
        padding: 16px 20px;
<body>
        border-bottom: 1px solid rgba(255, 255, 255, .08);
    }


<div class="container">
    .weapon-modal-header h3 {
  <div class="personagem"
        margin: 0;
      data-static="https://i.postimg.cc/0NMJrvjJ/fundoaokiji.png"
        font-size: 16px;
      data-gif="https://i.postimg.cc/nzKrQhJM/aokijiemotecard2.gif">
        font-weight: 600;
    <span>Aokiji</span>
        color: #fff;
     <div class="gif-overlay"></div>
     }
  </div>


     <div class="personagem luffy"
     .weapon-modal-close {
      data-static="https://i.postimg.cc/L8hJ0Sz0/luffycard.png"
        background: transparent;
      data-gif="https://i.postimg.cc/G2n92s6Z/luffytsemotecard.gif">
        border: none;
     <span>Monkey D. Luffy (TS)</span>
        color: rgba(255, 255, 255, .5);
     <div class="gif-overlay"></div>
        font-size: 24px;
  </div>
        cursor: pointer;
</div>
        padding: 0;
<script>
        width: 28px;
const cards = document.querySelectorAll('.personagem');
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
        transition: background .15s, color .15s;
    }
 
    .weapon-modal-close:hover {
        background: rgba(255, 255, 255, .1);
        color: #fff;
    }
 
    .weapon-modal-body {
        padding: 20px;
        color: rgba(255, 255, 255, .8);
        line-height: 1.6;
        font-size: 14px;
    }
 
    .weapon-modal-body p {
        margin: 0 0 12px;
    }
 
    .weapon-modal-body p:last-child {
        margin: 0;
    }
 
    .weapon-modal-body strong {
        color: #6BB3FF;
    }
 
     .weapon-modal-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 20px;
        border-top: 1px solid rgba(255, 255, 255, .08);
        gap: 12px;
    }
 
     .weapon-modal-checkbox {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 12px;
        color: rgba(255, 255, 255, .6);
        cursor: pointer;
    }


cards.forEach(card => {
    .weapon-modal-checkbox input[type="checkbox"] {
  const staticImg = card.getAttribute('data-static');
        accent-color: #4A9EFF;
  const gifImg = card.getAttribute('data-gif');
    }
  const overlay = card.querySelector('.gif-overlay');


  // Define o fundo estático
    .weapon-modal-btn {
  card.style.backgroundImage = `url('${staticImg}')`;
        background: #4A9EFF;
        border: none;
        color: #fff;
        padding: 10px 24px;
        border-radius: 6px;
        font-weight: 600;
        font-size: 13px;
        cursor: pointer;
        transition: background .15s;
    }


  card.addEventListener('mouseenter', () => {
    .weapon-modal-btn:hover {
    const uniqueGifUrl = `${gifImg}?t=${new Date().getTime()}`;
        background: #3A8EEF;
     overlay.style.backgroundImage = `url('${uniqueGifUrl}')`;
     }
  });


  card.addEventListener('mouseleave', () => {
    @media (max-width: 600px) {
    overlay.style.backgroundImage = '';
        .weapon-modal-content {
  });
            width: 95%;
});
        }


</script>
        .weapon-modal-header,
        .weapon-modal-body,
        .weapon-modal-footer {
            padding: 12px 16px;
        }


</body>
        .weapon-modal-footer {
</html>
            flex-direction: column;
        }
    }
</style>

Edição atual tal como às 16h34min de 2 de dezembro de 2025

<script>

   (() => {
       let modalListenersBound = false;
       const bindModalEvents = () => {
           if (modalListenersBound) return;
           modalListenersBound = true;
           document.addEventListener('click', (ev) => {
               if (ev.target.closest('.weapon-modal-close') || ev.target.closest('.weapon-modal-btn')) {
                   const checkbox = document.getElementById('weapon-dont-show');
                   if (checkbox && checkbox.checked) {
                       try { localStorage.setItem('glaWeaponPopupDismissed', '1'); } catch (x) { }
                   }
                   hidePopup();
                   return;
               }
               if (ev.target.classList.contains('weapon-modal-overlay')) {
                   hidePopup();
               }
           });
       };

const applyWeaponState = (enabled) => {

   const first = document.querySelector('.skill-icon');
   const selected = document.querySelector('.skill-icon.selected');
   if (first) {
       if (selected) selected.classList.remove('selected');
       first.classList.add('selected');
   }
   if (typeof window.__setGlobalWeaponEnabled === 'function') {
       window.__setGlobalWeaponEnabled(enabled);
   }
   try {
       localStorage.setItem('glaWeaponEnabled', enabled ? '1' : '0');
   } catch (x) { }
   document.querySelectorAll('.skill-icon[data-weapon]').forEach(el => {
       if (enabled) {
           el.classList.add('has-weapon-available');
           let ind = el.querySelector('.weapon-indicator');
           if (!ind) {
               ind = document.createElement('div');
               ind.className = 'weapon-indicator';
               el.appendChild(ind);
           }
       } else {
           el.classList.remove('has-weapon-available');
           el.classList.remove('weapon-equipped');
           el.style.removeProperty('--weapon-badge-url');
           const ind = el.querySelector('.weapon-indicator');
           if (ind) ind.remove();
       }
   });
   const sel = document.querySelector('.skill-icon.selected');
   if (sel) {
       sel.dispatchEvent(new Event('click', { bubbles: true }));
   }

};


       const ensureModal = () => {
           let modal = document.getElementById('weapon-info-modal');
           if (modal) return modal;
           modal = document.createElement('div');
           modal.id = 'weapon-info-modal';
           modal.className = 'weapon-modal';
           modal.innerHTML = `

Visualização com Arma Especial

                   <button class="weapon-modal-close">×</button>

Este modo ativa a visualização do personagem equipado com sua arma especial.

As habilidades melhoradas ficam destacadas com borda e brilho azul, mesmo quando não selecionadas.

       `;
           document.body.appendChild(modal);
           try {
               const firstWithWeapon = document.querySelector('.skill-icon[data-weapon]');
               if (firstWithWeapon) {
                   const raw = firstWithWeapon.getAttribute('data-weapon');
                   const obj = JSON.parse(raw || '{}');
                   const nm = (obj && obj.name) ? String(obj.name).trim() : ;
                   if (nm) {
                       const linkHost = (window.mw && mw.util && typeof mw.util.getUrl === 'function') ? mw.util.getUrl(nm) : ('/index.php?title=' + encodeURIComponent(nm));
                       const holder = modal.querySelector('.weapon-info-link');
                       if (holder) {
                           holder.style.display = 'block';
                           holder.innerHTML = `<a href="${linkHost}" style="color:#6BB3FF;text-decoration:none;font-weight:600">Ver página da arma: ${nm}</a>`;
                       }
                   }
               }
           } catch (_) { }
           bindModalEvents();
           return modal;
       };
       const showPopup = () => {
           const modal = ensureModal();
           if (modal) modal.classList.add('show');
       };
       const hidePopup = () => {
           const m = document.getElementById('weapon-info-modal');
           if (m) m.classList.remove('show');
       };
       window.__applyWeaponState = applyWeaponState;
       window.__glaWeaponShowPopup = showPopup;
       window.__glaWeaponHidePopup = hidePopup;
       try {
           window.dispatchEvent(new CustomEvent('weapon:ready', { detail: { applyWeaponState, showPopup, hidePopup } }));
       } catch (err) {
       }
       const boot = () => {
           // Verificar se existe alguma skill com arma
           const hasAnyWeapon = document.querySelectorAll('.skill-icon[data-weapon]').length > 0;
           if (!hasAnyWeapon) return;
           ensureModal();
           // Estado inicial do toggle
           let init = false;
           try {
               if (localStorage.getItem('glaWeaponEnabled') === '1') init = true;
           } catch (x) { }
           setTimeout(() => applyWeaponState(init), 150);
       };
       if (document.readyState === 'loading') {
           document.addEventListener('DOMContentLoaded', boot);
       } else {
           boot();
       }
   })();

</script> <style>

   .weapon-modal {
       position: fixed;
       inset: 0;
       z-index: 9999;
       display: flex;
       align-items: center;
       justify-content: center;
       opacity: 0;
       pointer-events: none;
       transition: opacity .3s;
   }
   .weapon-modal.show {
       opacity: 1;
       pointer-events: all;
   }
   .weapon-modal-overlay {
       position: absolute;
       inset: 0;
       background: rgba(0, 0, 0, .75);
       -webkit-backdrop-filter: blur(4px);
       backdrop-filter: blur(4px);
   }
   .weapon-modal-content {
       position: relative;
       background: linear-gradient(135deg, #1f1f1f, #2a2a2a);
       border: 1px solid rgba(255, 255, 255, .12);
       border-radius: 12px;
       max-width: 420px;
       width: 90%;
       box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
       animation: modalIn .3s;
   }
   @keyframes modalIn {
       from {
           transform: translateY(-20px);
           opacity: 0;
       }
       to {
           transform: translateY(0);
           opacity: 1;
       }
   }
   .weapon-modal-header {
       display: flex;
       align-items: center;
       justify-content: space-between;
       padding: 16px 20px;
       border-bottom: 1px solid rgba(255, 255, 255, .08);
   }
   .weapon-modal-header h3 {
       margin: 0;
       font-size: 16px;
       font-weight: 600;
       color: #fff;
   }
   .weapon-modal-close {
       background: transparent;
       border: none;
       color: rgba(255, 255, 255, .5);
       font-size: 24px;
       cursor: pointer;
       padding: 0;
       width: 28px;
       height: 28px;
       display: flex;
       align-items: center;
       justify-content: center;
       border-radius: 4px;
       transition: background .15s, color .15s;
   }
   .weapon-modal-close:hover {
       background: rgba(255, 255, 255, .1);
       color: #fff;
   }
   .weapon-modal-body {
       padding: 20px;
       color: rgba(255, 255, 255, .8);
       line-height: 1.6;
       font-size: 14px;
   }
   .weapon-modal-body p {
       margin: 0 0 12px;
   }
   .weapon-modal-body p:last-child {
       margin: 0;
   }
   .weapon-modal-body strong {
       color: #6BB3FF;
   }
   .weapon-modal-footer {
       display: flex;
       align-items: center;
       justify-content: space-between;
       padding: 14px 20px;
       border-top: 1px solid rgba(255, 255, 255, .08);
       gap: 12px;
   }
   .weapon-modal-checkbox {
       display: flex;
       align-items: center;
       gap: 8px;
       font-size: 12px;
       color: rgba(255, 255, 255, .6);
       cursor: pointer;
   }
   .weapon-modal-checkbox input[type="checkbox"] {
       accent-color: #4A9EFF;
   }
   .weapon-modal-btn {
       background: #4A9EFF;
       border: none;
       color: #fff;
       padding: 10px 24px;
       border-radius: 6px;
       font-weight: 600;
       font-size: 13px;
       cursor: pointer;
       transition: background .15s;
   }
   .weapon-modal-btn:hover {
       background: #3A8EEF;
   }
   @media (max-width: 600px) {
       .weapon-modal-content {
           width: 95%;
       }
       .weapon-modal-header,
       .weapon-modal-body,
       .weapon-modal-footer {
           padding: 12px 16px;
       }
       .weapon-modal-footer {
           flex-direction: column;
       }
   }

</style>