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

De Wiki Gla
Ir para navegação Ir para pesquisar
Linha 13: Linha 13:
<script>
<script>
(function () {
(function () {
   const raw = document.getElementById('infoboxboss-data')?.dataset?.habilidadesRaw;
   const dataEl = document.getElementById('infoboxboss-data');
   console.log(raw);
if (!dataEl) {
   if (!raw) return;
   console.error('Droflax widget: no se encontró #infoboxboss-data');
   return;
}


  const parts = raw.split('||').filter(p => p.trim());
let rawHabs = (dataEl.dataset.habilidadesRaw || '').trim();
  const habilidades = [];
// Limpia comentarios HTML
rawHabs = rawHabs.replace(/<!--[\s\S]*?-->/g, '').trim();


   for (let i = 0; i < parts.length; i += 3) {
const habilidades = [];
 
rawHabs.split('||').forEach(line => {
   if (!line.trim()) return;
 
  const habData = {};
  line.split('|').forEach(part => {
    const [key, ...rest] = part.split('=');
    if (key && rest.length) {
      habData[key.trim()] = rest.join('=').trim(); // conserva '=' dentro de valores
    }
  });
 
  const { nome, desc, video } = habData;
  if (nome && desc && video) {
     habilidades.push({
     habilidades.push({
       nome: parts[i],
       nome,
       descricao: parts[i + 1],
       descricao: desc,
       video: parts[i + 2]
       video
     });
     });
  } else {
    console.warn("Habilidade ignorada por falta de campos:", habData);
   }
   }
});


   const tabsContainer = document.getElementById('skill-tabs');
   const tabsContainer = document.getElementById('skill-tabs');

Edição das 00h47min de 21 de maio de 2025

<script> (function () {

 const dataEl = document.getElementById('infoboxboss-data');

if (!dataEl) {

 console.error('Droflax widget: no se encontró #infoboxboss-data');
 return;

}

let rawHabs = (dataEl.dataset.habilidadesRaw || ).trim(); // Limpia comentarios HTML rawHabs = rawHabs.replace(//g, ).trim();

const habilidades = [];

rawHabs.split('||').forEach(line => {

 if (!line.trim()) return;
 const habData = {};
 line.split('|').forEach(part => {
   const [key, ...rest] = part.split('=');
   if (key && rest.length) {
     habData[key.trim()] = rest.join('=').trim(); // conserva '=' dentro de valores
   }
 });
 const { nome, desc, video } = habData;
 if (nome && desc && video) {
   habilidades.push({
     nome,
     descricao: desc,
     video
   });
 } else {
   console.warn("Habilidade ignorada por falta de campos:", habData);
 }

});


 const tabsContainer = document.getElementById('skill-tabs');
 const videoContainer = document.getElementById('skill-videos');
 const descText = document.getElementById('desc-text');
 habilidades.forEach((hab, idx) => {
   const id = `video${idx + 1}`;
   // Botón
   const btn = document.createElement('button');
   btn.className = 'infobox-skill-tab' + (idx === 0 ? ' active' : );
   btn.dataset.video = id;
   btn.textContent = hab.nome;
   tabsContainer.appendChild(btn);
   // Video
   const vid = document.createElement('video');
   vid.id = id;
   vid.className = 'skill-video';
   vid.controls = true;
   vid.autoplay = true;
   vid.loop = true;
   vid.style.display = idx === 0 ?  : 'none';
   const source = document.createElement('source');
   source.src = hab.video;
   source.type = "video/mp4";
   vid.appendChild(source);
   videoContainer.appendChild(vid);
 });
 // Descripción inicial
 descText.textContent = `${habilidades[0].nome}: ${habilidades[0].descricao}`;
 // Lógica de tabs
 const tabs = document.querySelectorAll('.infobox-skill-tab');
 const videos = document.querySelectorAll('.skill-video');
 tabs.forEach((tab, idx) => {
   tab.addEventListener('click', () => {
     tabs.forEach(t => t.classList.remove('active'));
     tab.classList.add('active');
     const vidId = tab.dataset.video;
     descText.textContent = `${habilidades[idx].nome}: ${habilidades[idx].descricao}`;
     videos.forEach(v => {
       if (v.id === vidId) {
         v.style.display = ;
         v.load();
         v.play();
       } else {
         v.pause();
         v.style.display = 'none';
       }
     });
   });
 });
 // Limpia el div original
 document.getElementById('infoboxboss-data')?.remove();

})(); </script>


<style> .infobox-boss-wide {

 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: center;
 width: 100%;
 min-height: unset;
 background: none;
 border: none;
 border-radius: 12px;
 box-shadow: none;
 font-family: sans-serif;
 color: #222;
 overflow: hidden;

} .infobox-boss-right {

 width: 100%;
 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: center;

} .skill-box {

 background: none;;
 color: #222;
 border-radius: 12px;
 box-shadow: none;
 width: 100%;
 max-width: 700px;
 box-sizing: border-box;
 padding: 24px 24px 20px 24px;
 display: flex;
 flex-direction: column;
 align-items: center;
 gap: 18px;
 backdrop-filter: blur(2px);
 margin: 0 auto 24px auto;

} .infobox-skill-info-area {

 width: 100%;
 max-width: 900px;
 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: center;
 margin-bottom: 16px;
 margin-top: 24px;
 gap: 12px;

} .infobox-skill-tabs {

 display: flex;
 gap: 12px;
 justify-content: center;
 margin-bottom: 0;
 width: 100%;

} .infobox-skill-tab {

 cursor: pointer;
 background: #fff;
 color: #222;
 border: 2px solid #ffc107;
 border-radius: 8px;
 padding: 10px 24px;
 font-size: 1em;
 font-weight: bold;
 transition: 0.2s;
 box-shadow: 0 2px 8px rgba(0,0,0,0.08);
 opacity: 0.7;
 margin-bottom: 0;

} .infobox-skill-tab.active, .infobox-skill-tab:hover {

 opacity: 1;
 background: #ffc107;
 color: #181f2a;
 border-color: #ffc107;

} .skill-desc {

 font-size: 1.08em;
 width: 100%;
 text-align: center;
 font-weight: 500;
 line-height: 1.5;
 margin-top: 0;
 margin-bottom: 0;
 background: none;
 color: #222;
 box-shadow: none;
 border-radius: 0;
 padding: 0;

} .infobox-skill-video-area {

 width: 100%;
 max-width: 900px;
 min-height: 270px;
 display: flex;
 align-items: center;
 justify-content: center;
 background: transparent;
 border-radius: 8px;
 margin-top: 0;
 margin-bottom: 0;
 box-shadow: none;
 padding: 16px 0;
 margin-left: auto;
 margin-right: auto;

} .skill-video {

 width: 100%;
 height: auto;
 max-width: 700px;
 border-radius: 8px;
 background: #000;
 display: block;
 margin: 0 auto;

} @media (max-width: 900px) {

 .infobox-boss-wide {
   min-height: unset;
 }
 .infobox-skill-info-area,
 .infobox-skill-video-area {
   max-width: 100vw;
   width: 100%;
   padding: 0 2vw;
 }
 .skill-video,
 .skill-box {
   max-width: 100vw;
   width: 100%;
 }

}

</style>