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

De Wiki Gla
Ir para navegação Ir para pesquisar
 
(34 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:


<div class="boss-container-teste>
<main class = "boss-container-teste">
 
<h1 class = "boss-titulo"></h1>
<div class="boss-diff-buttons">
<div class="boss-diff-buttons">
     <button class="boss-diff-btn active" data-diff="normal">NORMAL</button>
     <button class="boss-diff-btn active" data-diff="normal">NORMAL</button>
     <button class="boss-diff-btn" data-diff="elite">ELITE</button>
     <button class="boss-diff-btn" data-diff="elite">ELITE</button>
     <button class="boss-diff-btn" data-diff="hard">HARD</button>
     <button class="boss-diff-btn" data-diff="hard">HARD</button>
    <h2>Teste</h2>
</div>
</div>


<div class="boss-content"></div>
<div class="boss-content"></div>


</div>
</main>
<script>
<script>
(function() {
(function() {
Linha 28: Linha 27:
         const d = data[diff];
         const d = data[diff];
         const content = root.querySelector(".boss-content");
         const content = root.querySelector(".boss-content");
          
         console.log(d.recompensasHTML);
 
         if (!content) return;
         if (!content) return;
          
          
Linha 35: Linha 35:
         // Nome do boss
         // Nome do boss
         if (data.nome) {
         if (data.nome) {
             html += `<h2>${escapeHtml(data.nome)}</h2>`;
             titulo = root.querySelector(".boss-titulo")
            titulo.innerHTML = escapeHtml(data.nome);
         }
         }


         // Introdução
         // Introdução
         if (data.introducao) {
         //if (data.introducao) {
            html += `<p><em>${escapeHtml(data.introducao)}</em></p>`;
        //    html += `<p><em>${escapeHtml(data.introducao)}</em></p>`;
         }
         //}


         // Localização
         /* Localização
         if (data.localizacao) {
         if (data.localizacao) {
             html += `<h3>Localização</h3>`;
             html += `<h3>Localização</h3>`;
             html += `<p>${escapeHtml(data.localizacao.descricao)}</p>`;
             html += `<p>${escapeHtml(data.localizacao.descricao)}</p>`;
         }
         }*/
       
        //Grid de requisitos e recompensas
        html += `<div class = "boss-content-grid">`


         // Requisitos
         // Requisitos
         html += `<h3>Requisitos</h3><ul>`;
         html += `<div class = "boss-content-requisitos"><h3>Requisitos</h3><ul>`;
         if (d.requisitos && d.requisitos.length) {
         if (d.requisitos && d.requisitos.length) {
             d.requisitos.forEach(r => html += `<li>${escapeHtml(r)}</li>`);
             d.requisitos.forEach(r => html += `<li>${escapeHtml(r)}</li>`);
Linha 56: Linha 60:
             html += `<li>Nenhum requisito</li>`;
             html += `<li>Nenhum requisito</li>`;
         }
         }
         html += `</ul>`;
         html += `</ul></div>`;
       
        //Grid recompensas
        html += `<div class = "boss-content-grid-recompensas">`


         // Recompensas Garantidas
         // Recompensas Garantidas
Linha 70: Linha 77:
         html += `<h3>Possíveis Recompensas</h3><ul>`;
         html += `<h3>Possíveis Recompensas</h3><ul>`;
         if (d.recompensasPossiveis && d.recompensasPossiveis.length) {
         if (d.recompensasPossiveis && d.recompensasPossiveis.length) {
             d.recompensasPossiveis.forEach(r => html += `<li>${escapeHtml(r)}</li>`);
             html += await processReward(d.recompensasPossiveis);
         } else {
         } else {
             html += `<li>Nenhuma recompensa possível</li>`;
             html += `<li>Nenhuma recompensa possível</li>`;
         }
         }
         html += `</ul>`;
         html += `</ul>`;
        html += `</div>`;
 
        //Fim da grid
        html += `</div>`;


         content.innerHTML = html;
         content.innerHTML = html;
Linha 124: Linha 135:
         mw.hook('wikipage.content').add(init);
         mw.hook('wikipage.content').add(init);
     }
     }
   
    async function processReward(itemString) {
    const wikiText = `{{Reward|itens=${itemString};1}}`;
    const apiUrl = `https://wiki.gla.com.br/api.php?action=parse&text=${encodeURIComponent(wikiText)}&format=json&origin=*`;
    //expandtemplates
    try {
        const response = await fetch(apiUrl);
        const data = await response.json();
        return data.parse.text['*'].replace(/<p[^>]*>[\s\S]*?<\/p>/g, '');
    } catch(e) {
        console.error('Erro ao processar reward:', e);
        return '';
    }
    }
})();
})();
</script>
</script>
Linha 130: Linha 156:
.boss-container-teste {
.boss-container-teste {
     font-family: 'Segoe UI', Roboto, Arial, sans-serif;
     font-family: 'Segoe UI', Roboto, Arial, sans-serif;
     max-width: 800px;
     max-width: 900px;
     margin: 0 auto;
     margin: 0 auto;
     background: #3a3a3c;
     background-color: #3a3a3c;
     border-radius: 16px;
     border-radius: 12px;
     overflow: hidden;
     overflow: hidden;
     color: #e8e8e8;
     color: #e0e0e0;
    display: flex;
    text-align: center;
    justify-content: center;
    flex-direction: column;
}
 
/* Título do boss */
.boss-titulo {
    font-size: 42px;
    font-weight: bold;
    color: #5488ad;
    margin: 0 0 12px 0;
    letter-spacing: 1px;
}
}


Linha 141: Linha 180:
.boss-diff-buttons {
.boss-diff-buttons {
     display: flex;
     display: flex;
     gap: 8px;
     justify-content: center;
     background: #11161f;
    text-align: center;
     padding: 12px 20px;
     gap: 4px;
     border-bottom: 1px solid #2a2e3a;
     padding: 16px 20px;
     border-bottom: 2px solid #3a3a3c;
}
}


.boss-diff-btn {
.boss-diff-btn {
     background: #1a1f2b;
     background: #3a3a3c;
     border: none;
     border: none;
     color: #a0a5b0;
     color: #e0e0e0;
     padding: 8px 24px;
     padding: 10px 28px;
     border-radius: 24px;
     border-radius: 8px;
     font-weight: bold;
     font-weight: bold;
     cursor: pointer;
     cursor: pointer;
     transition: all 0.2s;
     transition: all 0.2s;
     font-size: 14px;
     font-size: 14px;
    letter-spacing: 1px;
}
}


.boss-diff-btn:hover {
.boss-diff-btn:hover {
     background: #2a2e3a;
     background: #5488ad;
     color: #ddd;
     color: white;
}
}


.boss-diff-btn.active {
.boss-diff-btn.active {
     background: #7c3aed;
     background: #5488ad;
     color: white;
     color: white;
     box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
     box-shadow: 0 2px 8px rgba(84, 136, 173, 0.3);
}
}


/* Conteúdo principal */
/* Conteúdo principal */
.boss-content {
.boss-content {
     padding: 24px;
     padding: 24px 28px;
}
}


/* Títulos */
/* Introdução */
.boss-content h2 {
.boss-content em {
     font-size: 28px;
     color: #a0a0a0;
     font-weight: bold;
     display: block;
     color: #ffd700;
     margin-bottom: 28px;
     margin-bottom: 8px;
     padding-bottom: 16px;
     display: flex;
     border-bottom: 1px solid #3a3a3c;
     align-items: center;
     font-style: italic;
     gap: 12px;
     font-size: 14px;
}
}


/* Subtítulos (Localização, Requisitos, etc) */
.boss-content h3 {
.boss-content h3 {
     color: #7c3aed;
     color: #5488ad;
     margin: 20px 0 12px 0;
     margin: 24px 0 12px 0;
     font-size: 18px;
     font-size: 16px;
    font-weight: bold;
     text-transform: uppercase;
     text-transform: uppercase;
     letter-spacing: 1px;
     letter-spacing: 1.5px;
}
}


Linha 198: Linha 241:
}
}


/* Introdução */
/* Grid */
.boss-content em {
.boss-content-grid {
     color: #a0a5b0;
     display: flex;
     display: block;
     text-align: center;
     margin-bottom: 24px;
     justify-content: center;
     padding-bottom: 16px;
     gap: 10px;
     border-bottom: 1px solid #2a2e3a;
}
     font-style: italic;
 
/* Requisitos */
.boss-content-requisitos{
     background-color: #1f1f20;
     padding: 6px;
}
}
/* Recompensas */


/* Listas */
/* Listas */
.boss-content ul {
.boss-content ul {
     margin: 0;
     margin: 0;
    padding-left: 24px;
    list-style-type: none;
}
.boss-content li {
    margin: 10px 0;
    color: #d0d0d0;
    position: relative;
     padding-left: 20px;
     padding-left: 20px;
}
}


.boss-content li {
.boss-content li::before {
     margin: 8px 0;
     content: "▸";
     color: #e0e0e0;
     color: #5488ad;
    position: absolute;
    left: 0;
}
}


/* Localização */
/* Linha divisória entre seções */
.boss-content p {
.boss-content hr {
     color: #c0c0c0;
     border: none;
     line-height: 1.5;
    border-top: 1px solid #3a3a3c;
     margin: 20px 0;
}
}


Linha 229: Linha 289:
     .boss-diff-buttons {
     .boss-diff-buttons {
         justify-content: center;
         justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
     }
     }
      
      
     .boss-diff-btn {
     .boss-diff-btn {
         padding: 6px 16px;
         padding: 8px 20px;
         font-size: 12px;
         font-size: 12px;
     }
     }
      
      
     .boss-content {
     .boss-content {
         padding: 16px;
         padding: 20px;
     }
     }
      
      
     .boss-content h2 {
     .boss-content h2 {
         font-size: 22px;
         font-size: 24px;
     }
     }
      
      
     .boss-content h3 {
     .boss-content h3 {
         font-size: 16px;
         font-size: 14px;
     }
     }
}
}
</style>
</style>

Edição atual tal como às 23h00min de 9 de abril de 2026

<main class = "boss-container-teste">

   <button class="boss-diff-btn active" data-diff="normal">NORMAL</button>
   <button class="boss-diff-btn" data-diff="elite">ELITE</button>
   <button class="boss-diff-btn" data-diff="hard">HARD</button>

</main> <script> (function() {

   function escapeHtml(str) {
       if (!str) return ;
       return str.replace(/[&<>]/g, function(m) {
           if (m === '&') return '&';
           if (m === '<') return '<';
           if (m === '>') return '>';
           return m;
       });
   }
   async function bossRender(root, diff) {
       const data = JSON.parse(root.dataset.json);
       const d = data[diff];
       const content = root.querySelector(".boss-content");
       console.log(d.recompensasHTML);
       if (!content) return;
       
       let html = ;
       // Nome do boss
       if (data.nome) {
           titulo = root.querySelector(".boss-titulo")
           titulo.innerHTML = escapeHtml(data.nome);
       }
       // Introdução
       //if (data.introducao) {

// html += `

${escapeHtml(data.introducao)}

`;

       //}
       /* Localização
       if (data.localizacao) {

html += `

Localização

`; html += `

${escapeHtml(data.localizacao.descricao)}

`;

       }*/
       
       //Grid de requisitos e recompensas

html += `

`
       // Requisitos
html += `

Requisitos

    `;
           if (d.requisitos && d.requisitos.length) {
    
    d.requisitos.forEach(r => html += `
  • ${escapeHtml(r)}
  • `); } else { html += `
  • Nenhum requisito
  • `; } html += `
`;
       //Grid recompensas
html += `
`
       // Recompensas Garantidas
html += `

Recompensas Garantidas

    `;
           if (d.recompensas && d.recompensas.length) {
    
    d.recompensas.forEach(r => html += `
  • ${escapeHtml(r)}
  • `); } else { html += `
  • Nenhuma recompensa garantida
  • `; } html += `
`;
       // Possíveis Recompensas
html += `

Possíveis Recompensas

    `;
           if (d.recompensasPossiveis && d.recompensasPossiveis.length) {
               html += await processReward(d.recompensasPossiveis);
           } else {
    
    html += `
  • Nenhuma recompensa possível
  • `; } html += `
`; html += `
`;
       //Fim da grid
html += `

`;

       content.innerHTML = html;
       
       // Atualiza botão ativo
       root.querySelectorAll('.boss-diff-btn').forEach(btn => {
           const diffBtn = btn.dataset.diff;
           if (diffBtn === diff) {
               btn.classList.add('active');
           } else {
               btn.classList.remove('active');
           }
       });
   }
   function init() {
       document.querySelectorAll('.boss-component').forEach(root => {
           if (root.dataset.initialized === 'true') return;
           root.dataset.initialized = 'true';
           
           // Adiciona event listeners nos botões
           const buttons = root.querySelectorAll('.boss-diff-btn');
           buttons.forEach(btn => {
               btn.removeEventListener('click', handleClick);
               btn.addEventListener('click', handleClick);
           });
           
           // Renderiza dificuldade normal
           bossRender(root, 'normal');
       });
   }
   function handleClick(e) {
       const btn = e.currentTarget;
       const root = btn.closest('.boss-component');
       const diff = btn.dataset.diff;
       if (root && diff) {
           bossRender(root, diff);
       }
   }
   if (document.readyState === 'loading') {
       document.addEventListener('DOMContentLoaded', init);
   } else {
       init();
   }
   if (typeof mw !== 'undefined' && mw.hook) {
       mw.hook('wikipage.content').add(init);
   }
   
   async function processReward(itemString) {

const wikiText = `

[[Arquivo:${itemString}.png|32x32px|link=]]x1
${itemString}

`;

   const apiUrl = `https://wiki.gla.com.br/api.php?action=parse&text=${encodeURIComponent(wikiText)}&format=json&origin=*`;
   //expandtemplates
   try {
       const response = await fetch(apiUrl);
       const data = await response.json();
       return data.parse.text['*'].replace(/<p[^>]*>[\s\S]*?<\/p>/g, );
   } catch(e) {
       console.error('Erro ao processar reward:', e);
       return ;
   }
   }

})(); </script>

<style> .boss-container-teste {

   font-family: 'Segoe UI', Roboto, Arial, sans-serif;
   max-width: 900px;
   margin: 0 auto;
   background-color: #3a3a3c;
   border-radius: 12px;
   overflow: hidden;
   color: #e0e0e0;
   display: flex;
   text-align: center;
   justify-content: center;
   flex-direction: column;

}

/* Título do boss */ .boss-titulo {

   font-size: 42px;
   font-weight: bold;
   color: #5488ad;
   margin: 0 0 12px 0;
   letter-spacing: 1px;

}

/* Botões de dificuldade */ .boss-diff-buttons {

   display: flex;
   justify-content: center;
   text-align: center;
   gap: 4px;
   padding: 16px 20px;
   border-bottom: 2px solid #3a3a3c;

}

.boss-diff-btn {

   background: #3a3a3c;
   border: none;
   color: #e0e0e0;
   padding: 10px 28px;
   border-radius: 8px;
   font-weight: bold;
   cursor: pointer;
   transition: all 0.2s;
   font-size: 14px;
   letter-spacing: 1px;

}

.boss-diff-btn:hover {

   background: #5488ad;
   color: white;

}

.boss-diff-btn.active {

   background: #5488ad;
   color: white;
   box-shadow: 0 2px 8px rgba(84, 136, 173, 0.3);

}

/* Conteúdo principal */ .boss-content {

   padding: 24px 28px;

}

/* Introdução */ .boss-content em {

   color: #a0a0a0;
   display: block;
   margin-bottom: 28px;
   padding-bottom: 16px;
   border-bottom: 1px solid #3a3a3c;
   font-style: italic;
   font-size: 14px;

}

/* Subtítulos (Localização, Requisitos, etc) */ .boss-content h3 {

   color: #5488ad;
   margin: 24px 0 12px 0;
   font-size: 16px;
   font-weight: bold;
   text-transform: uppercase;
   letter-spacing: 1.5px;

}

.boss-content h3:first-of-type {

   margin-top: 0;

}

/* Grid */ .boss-content-grid {

   display: flex;
   text-align: center;
   justify-content: center;
   gap: 10px;

}

/* Requisitos */ .boss-content-requisitos{

   background-color: #1f1f20;
   padding: 6px;

}

/* Recompensas */

/* Listas */ .boss-content ul {

   margin: 0;
   padding-left: 24px;
   list-style-type: none;

}

.boss-content li {

   margin: 10px 0;
   color: #d0d0d0;
   position: relative;
   padding-left: 20px;

}

.boss-content li::before {

   content: "▸";
   color: #5488ad;
   position: absolute;
   left: 0;

}

/* Linha divisória entre seções */ .boss-content hr {

   border: none;
   border-top: 1px solid #3a3a3c;
   margin: 20px 0;

}

/* Responsivo */ @media (max-width: 600px) {

   .boss-diff-buttons {
       justify-content: center;
       flex-wrap: wrap;
       gap: 8px;
   }
   
   .boss-diff-btn {
       padding: 8px 20px;
       font-size: 12px;
   }
   
   .boss-content {
       padding: 20px;
   }
   
   .boss-content h2 {
       font-size: 24px;
   }
   
   .boss-content h3 {
       font-size: 14px;
   }

} </style>