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

De Wiki Gla
Ir para navegação Ir para pesquisar
 
(92 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:
<div class="full-receitas">
<!-- WEAPON TOGGLE SYSTEM - Estado global + popup -->
<div class="receitas-wrapper">
  <div style="font-size: 180%; font-weight: bold; border-bottom: 1px solid #aaa; margin-bottom: 0.5em;">» <span style="color:#4393ff">Receitas Aliança</span></div>
  <div id="receitas-alianca" class="receitas-container"></div>
 
  <div style="font-size: 180%; font-weight: bold; border-bottom: 1px solid #aaa; margin-bottom: 0.5em;">» <span style="color:#4393ff">Receitas Baratie</span></div>
  <div id="receitas-baratie" class="receitas-container"></div>
</div>
<div id="carrinho-container"></div>
</div>
 
 
<script>
<script>
let receitasSelecionadas = {
    (() => {
  0: null,
        let modalListenersBound = false;
  1: null
};
let receitas = {};
const berryGif = "/images/thumb/d/d1/Berrynewgif.gif/32px-Berrynewgif.gif";


function selecionarReceita(id) {
        const bindModalEvents = () => {
  const receita = encontrarReceita(id);
            if (modalListenersBound) return;
  if (!receita) 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();
                }
            });
        };


  if (Object.values(receitasSelecionadas).some(r => r && r.id === id)) return;
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');
    }


  for (let i = 0; i < 2; i++) {
     if (typeof window.__setGlobalWeaponEnabled === 'function') {
     if (!receitasSelecionadas[i]) {
         window.__setGlobalWeaponEnabled(enabled);
      receitasSelecionadas[i] = {
         id: receita.id,
        nome: receita.nome,
        preco: receita.preco,
        img: receita.img,
        ingredientes: receita.ingredientes,
        lvl: receita.lvl,
        tempo: receita.tempo,
        descricao: receita.descricao,
        quantidade: 1
      };
      break;
     }
     }
  }
  renderizarSelecao();
}
// Função para carregar as receitas a partir do JSON
async function cargarReceitas() {
  try {
    const response = await fetch('https://wiki.gla.com.br/index.php?title=Receitas.json&action=raw');
    const data = await response.json();
   
    receitas = {
      baratie: Object.entries(data.baratie).map(([id, item]) => ({
        id,
        nome: item.nome,
        preco: item.cost,
        img: item.thumb,
        ingredientes: item.ingredients || [],
        lvl: item.lvl,
        tempo: item.time,
        descricao: item.description
      })),
      alianca: Object.entries(data.alianca).map(([id, item]) => ({
        id,
        nome: item.nome,
        preco: item.cost,
        img: item.thumb,
        ingredientes: item.ingredients || [],
        lvl: item.lvl,
        tempo: item.time,
        descricao: item.description
      }))
    };
   
    renderizarReceitas();
  } catch (error) {
    console.error('Error al cargar las receitas:', error);
    alert('No se pudieron cargar las receitas. Por favor, inténtalo más tarde.');
  }
}
function renderizarReceitas() {
  renderizarSecao('baratie');
  renderizarSecao('alianca');
}
function renderizarSecao(secao) {
  const container = document.getElementById(`receitas-${secao}`);
  if (!container) return;
  container.innerHTML = '';
  receitas[secao].forEach(receita => {
    const card = document.createElement('div');
    card.className = 'receita-card';
    card.setAttribute('data-id', receita.id);
    card.innerHTML = `
      <button class="info-btn" onclick="mostrarModalReceita(this)"
        data-descricao="${encodeURIComponent(receita.descricao)}"
        data-lvl="${receita.lvl}"
        data-tempo="${receita.tempo}">i</button>
      <img src="${receita.img}" width="48" height="48" />
      <div class="receita-nome">${receita.nome}</div>
      <div class="receita-preco">${receita.preco.toLocaleString()} <img src="${berryGif}" alt="Berry" width="25" height="25" style="transform: translateY(-1px);"/></div>
      <button class="add-to-cart-btn" onclick="selecionarReceita('${receita.id}')">Selecionar</button>
    `;
    container.appendChild(card);
  });
}
function mostrarModalReceita(button) {
  const descricao = decodeURIComponent(button.getAttribute('data-descricao'));
  const lvl = button.getAttribute('data-lvl');
  const tempo = button.getAttribute('data-tempo');
  const descricaoFormatada = descricao
    .replace(/\n/g, '<br>')
    .replace(/Tempo de recarga/g, '<br><strong>Tempo de recarga</strong>');
  const modalHTML = `
    <div class="modal-overlay active" onclick="cerrarModal(event)">
      <div class="modal-content" onclick="event.stopPropagation()">
        <button class="close-modal" onclick="cerrarModal(event)">×</button>
        <p><strong>Nível:</strong> ${lvl}</p>
        <p><strong>Tempo de preparo:</strong> ${tempo} min</p>
        <p><strong>Descrição:</strong><br>${descricaoFormatada}</p>
      </div>
    </div>
  `;
 
  document.body.insertAdjacentHTML('beforeend', modalHTML);
  document.addEventListener('keydown', (e) => e.key === 'Escape' && cerrarModal(e));
}
function cerrarModal(event) {
  event.preventDefault();
  const modal = document.querySelector('.modal-overlay');
  if (modal) {
    modal.classList.remove('active');
    setTimeout(() => modal.remove(), 300);
  }
}
function encontrarReceita(id) {
  for (const secao in receitas) {
    const receita = receitas[secao].find(r => r.id === id);
    if (receita) return receita;
  }
  return null;
}
function renderizarSelecao() {
  const container = document.getElementById('carrinho-container');
  container.innerHTML = '';
  let totalSlots = 2;
  for (let i = 0; i < totalSlots; i++) {
    const receita = receitasSelecionadas[i];


     const itemDiv = document.createElement('div');
     try {
     itemDiv.className = 'item-carrinho';
        localStorage.setItem('glaWeaponEnabled', enabled ? '1' : '0');
     } catch (x) { }


     if (receita) {
     document.querySelectorAll('.skill-icon[data-weapon]').forEach(el => {
      const subtotal = receita.preco * receita.quantidade;
        if (enabled) {
      tempo = formatarTempo(receita.tempo * receita.quantidade);
            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 ingredientesHtml = receita.ingredientes.map(([nome, qtd]) => {
    const sel = document.querySelector('.skill-icon.selected');
        const totalIngrediente = qtd * receita.quantidade;
    if (sel) {
        return `<div><img class="ingrediente-img" src="URL_DA_IMAGEM" alt="${nome}"/>${nome}: ${totalIngrediente}</div>`;
         sel.dispatchEvent(new Event('click', { bubbles: true }));
      }).join('');
 
      itemDiv.innerHTML = `
        <img src="${receita.img}" width="40" height="40" />
         <div class="info-carrinho">
          <div class="nome-item">${receita.nome}</div>
          <div class="atributes">
            <div class="">Level: ${receita.lvl}</div>
            <div class="">Time: ${tempo}</div>
            <p class="texto-centrado">${receita.descricao}</p>
          </div>
          <div class="controle-quantidade">
            <button onclick="alterarQuantidadeSelecionada(${i}, -1)">−</button>
            <input type="number" value="${receita.quantidade}" min="1"
                  onchange="atualizarQuantidadeManualSelecionada(${i}, event)">
            <button onclick="alterarQuantidadeSelecionada(${i}, 1)">+</button>
            <button class="btn-100" onclick="definir100Selecionada(${i})">x100</button>
          </div>
          <div class="ingredientes">
            ${ingredientesHtml}
          </div>
        </div>
        <div class="subtotal">${subtotal.toLocaleString()} <img src="${berryGif}" alt="Berry" width="25" height="25" style="transform: translateY(-1px);" /></div>
        <button class="remover-item" onclick="removerReceitaSelecionada(${i})">🗑️</button>
      `;
    } else {
      itemDiv.innerHTML = `<div class="placeholder">Selecione uma receita</div>`;
     }
     }
};


    container.appendChild(itemDiv);
  }
}


function alterarQuantidadeSelecionada(index, alteracao) {
        const ensureModal = () => {
  const receita = receitasSelecionadas[index];
            let modal = document.getElementById('weapon-info-modal');
  if (!receita) return;
            if (modal) return modal;
  receita.quantidade += alteracao;
            modal = document.createElement('div');
  if (receita.quantidade < 1) receita.quantidade = 1;
            modal.id = 'weapon-info-modal';
  renderizarSelecao();
            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;
        };


function atualizarQuantidadeManualSelecionada(index, event) {
        const showPopup = () => {
  const valor = parseInt(event.target.value);
            const modal = ensureModal();
  if (valor && valor >= 1) {
            if (modal) modal.classList.add('show');
    receitasSelecionadas[index].quantidade = valor;
        };
    renderizarSelecao();
  }
}


function definir100Selecionada(index) {
        const hidePopup = () => {
  if (receitasSelecionadas[index]) {
            const m = document.getElementById('weapon-info-modal');
    receitasSelecionadas[index].quantidade = 100;
            if (m) m.classList.remove('show');
    renderizarSelecao();
        };
  }
}


function removerReceitaSelecionada(index) {
        window.__applyWeaponState = applyWeaponState;
  receitasSelecionadas[index] = null;
        window.__glaWeaponShowPopup = showPopup;
  renderizarSelecao();
        window.__glaWeaponHidePopup = hidePopup;
}
        try {
            window.dispatchEvent(new CustomEvent('weapon:ready', { detail: { applyWeaponState, showPopup, hidePopup } }));
        } catch (err) {
        }


function formatarTempo(minutosDecimal) {
        const boot = () => {
  const minutosInt = Math.floor(minutosDecimal);
            // Verificar se existe alguma skill com arma
  const segundos = Math.round((minutosDecimal % 1) * 60);
            const hasAnyWeapon = document.querySelectorAll('.skill-icon[data-weapon]').length > 0;
            if (!hasAnyWeapon) return;


  if (minutosInt < 1) {
            ensureModal();
    return `${segundos}seg`;
  } else if (segundos === 0) {
    return `${minutosInt}min`;
  } else {
    return `${minutosInt}min ${segundos.toString().padStart(2, '0')}seg`;
  }
}


document.addEventListener('DOMContentLoaded', () => {
            // Estado inicial do toggle
  renderizarSelecao();
            let init = false;
});
            try {
                if (localStorage.getItem('glaWeaponEnabled') === '1') init = true;
            } catch (x) { }
            setTimeout(() => applyWeaponState(init), 150);
        };


// CSS
        if (document.readyState === 'loading') {
document.head.insertAdjacentHTML('beforeend', `
            document.addEventListener('DOMContentLoaded', boot);
        } else {
            boot();
        }
    })();
</script>
<style>
<style>
  @import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap');
    .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;
    }


body, html {
    .weapon-modal.show {
  font-family: 'Noto Sans', Arial, Helvetica, sans-serif;
        opacity: 1;
}
        pointer-events: all;
    }


  .receitas-container {
     .weapon-modal-overlay {
     display: flex;
        position: absolute;
    flex-wrap: wrap;
        inset: 0;
    gap: 18px;
        background: rgba(0, 0, 0, .75);
    margin-bottom: 24px;
        -webkit-backdrop-filter: blur(4px);
    justify-content: center;
        backdrop-filter: blur(4px);
    background: #f6f7fa;
     }
    border-radius: 10px;
    padding: 10px 0;
  }
  .nome-item, .subtotal{
    user-select: none;
  }
 
  .receita-card {
    width: 150px;          /* aumente a largura */
    text-align: center;
    border: 1.5px solid #e0e0e0;
    border-radius: 12px;
    padding: 12px 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(180,180,180,0.10);
    transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
    user-select: none;
    position: relative;
  }
  .receita-card:hover {
    transform: translateY(-4px) scale(1.06);
    box-shadow: 0 8px 24px rgba(180,180,180,0.18);
     background: #f2f2f2;
  }


  .modal-overlay {
    .weapon-modal-content {
    position: fixed;
        position: relative;
    top: 0; left: 0; right: 0; bottom: 0;
        background: linear-gradient(135deg, #1f1f1f, #2a2a2a);
    background-color: rgba(80, 80, 80, 0.18);
        border: 1px solid rgba(255, 255, 255, .12);
    display: flex;
        border-radius: 12px;
    justify-content: center;
        max-width: 420px;
    align-items: center;
        width: 90%;
    z-index: 1000;
        box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
    opacity: 0;
        animation: modalIn .3s;
    visibility: hidden;
    }
    transition: all 0.3s ease;
  }


  .modal-overlay.active {
    @keyframes modalIn {
    opacity: 1;
        from {
    visibility: visible;
            transform: translateY(-20px);
  }
            opacity: 0;
        }


  .modal-content {
        to {
    background: #fff;
            transform: translateY(0);
    padding: 22px;
            opacity: 1;
    border-radius: 10px;
        }
    width: 320px;
     }
     position: relative;
    box-shadow: 0 4px 16px rgba(120,120,120,0.18);
  }


  .close-modal {
    .weapon-modal-header {
    position: absolute;
        display: flex;
    top: 10px;
        align-items: center;
    right: 10px;
        justify-content: space-between;
    font-size: 20px;
        padding: 16px 20px;
    cursor: pointer;
        border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: none;
     }
    border: none;
     color: #888;
  }


  .info-btn {
    .weapon-modal-header h3 {
    position: absolute;
        margin: 0;
    top: 5px;
        font-size: 16px;
    right: 5px;
        font-weight: 600;
    background: #e0e0e0;
        color: #fff;
    color: #333;
     }
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
     transition: background 0.2s;
  }
  .info-btn:hover {
    background: #bdbdbd;
  }


  .receita-nome {
    .weapon-modal-close {
    font-weight: bold;
        background: transparent;
    margin: 4px 0;
        border: none;
    min-height: 3em;
        color: rgba(255, 255, 255, .5);
    max-height: 3em;
        font-size: 24px;
    line-height: 1.5em;
        cursor: pointer;
    display: -webkit-box;
        padding: 0;
    -webkit-line-clamp: 2;
        width: 28px;
    -webkit-box-orient: vertical;
        height: 28px;
    align-items: center;
        display: flex;
    justify-content: center;
        align-items: center;
    text-align: center;
        justify-content: center;
    font-size: 80%;        /* pode aumentar ou diminuir conforme preferir */
        border-radius: 4px;
    color: #222;
        transition: background .15s, color .15s;
    overflow: hidden;
     }
    text-overflow: ellipsis;
    word-break: break-word;
  }
  .nome-item{
    font-weight: bold;
     color: #222;
  }


  .ingredientes{
    .weapon-modal-close:hover {
    display: grid;
        background: rgba(255, 255, 255, .1);
    grid-template-columns: repeat(2, 1fr);
        color: #fff;
    gap: 8px;
     }
    margin-top: 5px;
     margin-bottom: 10px;
  }


  .ingredientes div {
    .weapon-modal-body {
    background-color: #f3f3f3;
        padding: 20px;
    border: 1px solid #e0e0e0;
        color: rgba(255, 255, 255, .8);
    border-radius: 4px;
        line-height: 1.6;
    padding: 5px 7px 5px 32px; /* espaço à esquerda para a imagem */
        font-size: 14px;
    font-size: 13px;
     }
    text-align: left;
    color: #444;
    white-space: normal;
    overflow: hidden;
    text-overflow: unset;
    overflow-wrap: break-word;
     align-content: center;
    position: relative;
    min-height: 32px;
    display: flex;
    align-items: center;
  }


  /* Espaço reservado para a imagem do ingrediente */
    .weapon-modal-body p {
.ingrediente-img {
        margin: 0 0 12px;
  width: 24px;
    }
  height: 24px;
  object-fit: contain;
  margin-right: 6px;
  margin-left: -24px;
  flex-shrink: 0;
  background: transparent;
  display: inline-block;
}


  .receita-preco {
    .weapon-modal-body p:last-child {
    margin-bottom: 2px;
        margin: 0;
    color: #555;
     }
  }
 
  .item-carrinho {
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 12px;
    width: 44.5%;
    margin-inline: 1%;
    flex-direction: column;
    align-items: center;
    background: #fafbfc;
    box-shadow: 0 2px 8px rgba(180,180,180,0.08);
     height: fit-content;
    min-height: 97%;
    transition: box-shadow 0.18s, background 0.18s;
  }
  .item-carrinho:hover {
    background: #f2f2f2;
    box-shadow: 0 8px 24px rgba(180,180,180,0.13);
  }


  .info-carrinho {
     .weapon-modal-body strong {
    flex: 1;
        color: #6BB3FF;
    justify-items: center;
     }
  }
 
  .controle-quantidade {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2%;
     margin-bottom: 5%;
  }
 
  .controle-quantidade input {
    width: 44px;
    text-align: center;
    padding: 2px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #f7f7f7;
    color: #333;
  }
 
  .controle-quantidade button {
    width: 24px;
    height: 24px;
    background: #e0e0e0;
    border: none;
    border-radius: 4px;
    color: #222;
    cursor: pointer;
    transition: background 0.2s;
  }
  .controle-quantidade button:hover {
     background: #bdbdbd;
  }
 
  .btn-100 {
    width: auto !important;
    padding: 0 4px;
    margin-left: 4px;
    font-size: 12px;
    background: #d1d5db !important;
    color: #222;
  }
 
  .remover-item {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #888;
    transition: color 0.2s;
  }
  .remover-item:hover {
    color: #d32f2f;
  }
 
  .acao-carrinho {
    padding: 8px 16px;
    background-color: #4393ff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }
 
  .acao-carrinho:hover {
    background-color: #3275c7;
  }


  #carrinho-container {
    .weapon-modal-footer {
    display: flex;
        display: flex;
    flex-direction: row;
        align-items: center;
    flex-wrap: nowrap;
        justify-content: space-between;
    justify-content: center;
        padding: 14px 20px;
    width: 69%;
        border-top: 1px solid rgba(255, 255, 255, .08);
  }
        gap: 12px;
    }


  .receita-card.highlighted {
    .weapon-modal-checkbox {
    background-color: #e8f5e9;
        display: flex;
  }
        align-items: center;
        gap: 8px;
        font-size: 12px;
        color: rgba(255, 255, 255, .6);
        cursor: pointer;
    }


  .detalhe-receita ul {
    .weapon-modal-checkbox input[type="checkbox"] {
    padding-left: 20px;
        accent-color: #4A9EFF;
  }
    }


  .detalhe-receita li {
    .weapon-modal-btn {
    margin-bottom: 3px;
        background: #4A9EFF;
  }
        border: none;
        color: #fff;
        padding: 10px 24px;
        border-radius: 6px;
        font-weight: 600;
        font-size: 13px;
        cursor: pointer;
        transition: background .15s;
    }


  .detalhe-receita {
    .weapon-modal-btn:hover {
    width: 16%;
        background: #3A8EEF;
     justify-items: anchor-center;
     }
  }


  .receitas-wrapper{
     @media (max-width: 600px) {
     display: flex;
        .weapon-modal-content {
    flex-direction: column;
            width: 95%;
    width: 32.5%;
        }
    position: static;
    max-height: 620px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1.5px solid #e0e0e0;
    padding: 10px;
    border-radius: 12px;
    background: #fafbfc;
  }


  .full-receitas {
        .weapon-modal-header,
    display: flex;
        .weapon-modal-body,
    flex-direction: row;
        .weapon-modal-footer {
    flex-wrap: nowrap;
            padding: 12px 16px;
    background: #f6f7fa;
        }
  }


  @media screen and (max-width: 1366px) {
        .weapon-modal-footer {
    .item-carrinho {
            flex-direction: column;
      width: 45%;
        }
     }
     }
    .receitas-wrapper{
      display: flex;
      flex-direction: column;
      width: 35.5vw;
    }
  }
  .atributes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 5px;
    margin-bottom: 10px;
    width: 80%;
    justify-items: center;
  }
  .texto-centrado {
    text-align: center;
    grid-column: 1 / -1;
  }
  @media (max-width: 768px) {
    .item-carrinho {
      width: 43%;
    }
  }
  @media only screen and (min-width: 1280px) and (max-width: 1280px) and (min-height: 1024px) and (max-height: 1024px) {
    .item-carrinho {
      width: 32%;
    }
  }
</style>
</style>
`);
// Carregar as receitas ao iniciar
document.addEventListener('DOMContentLoaded', cargarReceitas);
</script>

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>