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

De Wiki Gla
Ir para navegação Ir para pesquisar
Linha 1: Linha 1:


  <tabber class="boss-diff">
<tabber class="boss-diff">
    <button onclick="bossSetDiff(this,'normal')">NORMAL</button>
  <button onclick="bossSetDiff(this,'normal')">NORMAL</button>
    <button onclick="bossSetDiff(this,'elite')">ELITE</button>
  <button onclick="bossSetDiff(this,'elite')">ELITE</button>
    <button onclick="bossSetDiff(this,'hard')">HARD</button>
  <button onclick="bossSetDiff(this,'hard')">HARD</button>
  </tabber>
</tabber>
 
 
  <div class="boss-content"></div>
<div class="boss-content">
</div>




<script>
<script>
(function() {
(function() {
  function init() {
    document.querySelectorAll(".boss-component").forEach(root => {
      bossRender(root, "normal");
    });
  }
   function bossRender(root, diff) {
   function bossRender(root, diff) {
     const data = JSON.parse(root.dataset.json);
     const data = JSON.parse(root.dataset.json);
     const d = data[diff];
     const d = data[diff];
     const content = root.querySelector(".boss-content");
     const content = root.querySelector(".boss-content");


     let html = "";
     let html = "";


     html += "<div class='box'><h3>REQUISITOS</h3>";
     // Nome do boss (se existir)
     d.requisitos.forEach(r => html += `<div>- ${r}</div>`);
    if (data.nome) {
     html += "</div>";
      html += `<h2>${data.nome}</h2>`;
    }
 
    // Introdução (se existir)
    if (data.introducao) {
      html += `<p><em>${data.introducao}</em></p>`;
    }
 
    // Localização (se existir)
    if (data.localizacao) {
      html += `<h3>Localização</h3>`;
      html += `<p>${data.localizacao.descricao}</p>`;
    }
 
    // Requisitos
    html += `<h3>Requisitos</h3><ul>`;
     d.requisitos.forEach(r => html += `<li>${r}</li>`);
     html += `</ul>`;
 
    // Recompensas
    html += `<h3>Recompensas</h3><ul>`;
    d.recompensas.forEach(r => html += `<li>${r}</li>`);
    html += `</ul>`;


     html += "<div class='box'><h3>RECOMPENSAS</h3>";
     // Skills
    d.recompensas.forEach(r => html += `<div>${r}</div>`);
    if (d.skills && d.skills.length > 0) {
    html += "</div>";
      html += `<h3>Skills</h3><ul>`;
      d.skills.forEach(s => html += `<li><strong>${s.nome}</strong>: ${s.desc}</li>`);
      html += `</ul>`;
    }


     content.innerHTML = html;
     content.innerHTML = html;
}  
  }
 
  function init() {
    document.querySelectorAll(".boss-component").forEach(root => {
      if (root.dataset.rendered === 'true') return;
      root.dataset.rendered = 'true';
      bossRender(root, "normal");
    });
  }


   window.bossSetDiff = function(el, diff){
   window.bossSetDiff = function(el, diff) {
     const root = el.closest(".boss-component");
     const root = el.closest(".boss-component");
     bossRender(root, diff);
     bossRender(root, diff);
   }
   };
 
  window.bikiSetSkill = function(el, index){
    // skill logic
  }


   if (document.readyState === 'loading') {
   if (document.readyState === 'loading') {
Linha 55: Linha 77:
     mw.hook('wikipage.content').add(init);
     mw.hook('wikipage.content').add(init);
   }
   }
})();
})();
</script>
</script>

Edição das 15h45min de 4 de abril de 2026

"bossSetDiff(this,'normal')">NORMAL</button>

 <button onclick="bossSetDiff(this,'elite')">ELITE</button>
 <button onclick="bossSetDiff(this,'hard')">HARD</button>


<script> (function() {

 function bossRender(root, diff) {
   const data = JSON.parse(root.dataset.json);
   const d = data[diff];
   const content = root.querySelector(".boss-content");
   let html = "";
   // Nome do boss (se existir)
   if (data.nome) {

html += `

${data.nome}

`;

   }
   // Introdução (se existir)
   if (data.introducao) {

html += `

${data.introducao}

`;

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

html += `

Localização

`; html += `

${data.localizacao.descricao}

`;

   }
   // Requisitos

html += `

Requisitos

    `; d.requisitos.forEach(r => html += `
  • ${r}
  • `); html += `

`;

   // Recompensas

html += `

Recompensas

    `; d.recompensas.forEach(r => html += `
  • ${r}
  • `); html += `

`;

   // Skills
   if (d.skills && d.skills.length > 0) {

html += `

Skills

    `; d.skills.forEach(s => html += `
  • ${s.nome}: ${s.desc}
  • `); html += `

`;

   }
   content.innerHTML = html;
 }
 function init() {
   document.querySelectorAll(".boss-component").forEach(root => {
     if (root.dataset.rendered === 'true') return;
     root.dataset.rendered = 'true';
     bossRender(root, "normal");
   });
 }
 window.bossSetDiff = function(el, diff) {
   const root = el.closest(".boss-component");
   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);
 }

})(); </script>

<style> .boss-component .box { ... } </style>