Mudanças entre as edições de "Widget:TesteBossYawn"
Ir para navegação
Ir para pesquisar
(Criou página com '<div class="boss-component" data-json="{{{data}}}"> <div class="boss-diff"> <button onclick="bossSetDiff(this,'normal')">NORMAL</button> <button onclick="bossSetD...') |
|||
| Linha 1: | Linha 1: | ||
<div class="boss-component" data-json="{{{data}}}"> | <div class="boss-component" data-json="{{{data}}}"> | ||
<div class="boss-diff"> | <div class="boss-diff"> | ||
<button onclick="bossSetDiff(this,'normal')">NORMAL</button> | <button onclick="bossSetDiff(this,'normal')">NORMAL</button> | ||
| Linha 36: | Linha 36: | ||
<script> | <script> | ||
function | (function(){ | ||
function bossRender(root, diff) { | |||
const data = JSON.parse(root.dataset.json); | |||
const d = data[diff]; | |||
const content = root.querySelector(".boss-content"); | |||
let html = ""; | |||
html += "<div class='box'><h3>REQUISITOS</h3>"; | |||
d.requisitos.forEach(r => html += `<div>- ${r}</div>`); | |||
html += "</div>"; | |||
html += "<div class='box'><h3>RECOMPENSAS</h3>"; | |||
d.recompensas.forEach(r => html += `<div>${r}</div>`); | |||
html += "</div>"; | |||
html += "<div class='skills'>"; | |||
d.skills.forEach((s, i) => { | |||
html += `<button onclick="bossSetSkill(this, ${i})">${s.nome}</button>`; | |||
}); | |||
html += "</div>"; | |||
html += "<div class='skills-desc'>"; | |||
d.skills.forEach((s, i) => { | |||
html += `<div class="skill-desc" style="display:${i===0?'block':'none'}">${s.desc}</div>`; | |||
}); | |||
html += "</div>"; | |||
content.innerHTML = html; | |||
} | |||
} | |||
window.bossSetDiff = function(el, diff){ | |||
} | const root = el.closest(".boss-component"); | ||
bossRender(root, diff); | |||
} | |||
function | window.bossSetSkill = function(el, index){ | ||
const root = el.closest(".boss-component"); | |||
const skills = root.querySelectorAll(".skill-desc"); | |||
skills.forEach(s => s.style.display = "none"); | |||
skills[index].style.display = "block"; | |||
} | |||
// INIT | |||
document.querySelectorAll(".boss-component").forEach(root => { | |||
bossRender(root, "normal"); | |||
}); | |||
})(); | |||
</script> | </script> | ||
Edição das 12h09min de 4 de abril de 2026
<button onclick="bossSetDiff(this,'normal')">NORMAL</button> <button onclick="bossSetDiff(this,'elite')">ELITE</button> <button onclick="bossSetDiff(this,'hard')">HARD</button>
<style> .boss-component {
border: 2px solid cyan; background: black; color: lime; padding: 10px;
}
.boss-diff button, .skills button {
border: 2px solid cyan; background: black; color: lime; margin: 5px; padding: 8px;
}
.box {
border: 2px solid cyan; margin-top: 10px; padding: 10px;
} </style>
<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 = "";
html += "
REQUISITOS
"; d.requisitos.forEach(r => html += `- ${r}
`);
html += ""; html += "
RECOMPENSAS
"; d.recompensas.forEach(r => html += `${r}
`);
html += ""; html += "
";
d.skills.forEach((s, i) => {
html += `<button onclick="bossSetSkill(this, ${i})">${s.nome}</button>`;
});
html += ""; html += "
";
d.skills.forEach((s, i) => {
html += `${s.desc}
`;
});html += "
";
content.innerHTML = html; }
window.bossSetDiff = function(el, diff){
const root = el.closest(".boss-component");
bossRender(root, diff);
}
window.bossSetSkill = function(el, index){
const root = el.closest(".boss-component");
const skills = root.querySelectorAll(".skill-desc");
skills.forEach(s => s.style.display = "none"); skills[index].style.display = "block"; }
// INIT
document.querySelectorAll(".boss-component").forEach(root => {
bossRender(root, "normal");
});
})(); </script>