Mudanças entre as edições de "Widget:Teste"
m |
|||
| Linha 1: | Linha 1: | ||
<div class="map- | <div class="map-container" id="map"></div> | ||
<script type="application/json" id="mapa-dados"> | |||
{{#invoke:Teste|data|mapa={{{mapa|Teste}}} }} | |||
</script> | |||
</ | |||
<script> | <script> | ||
( | const data = JSON.parse(document.getElementById('mapa-dados').textContent); | ||
const skulls = data.skulls || []; | |||
const hearts = data.hearts || []; | |||
const puzzleButton = data.puzzle || {}; | |||
const map = document.getElementById("map"); | |||
// SKULLS | |||
skulls.forEach((skull, index) => { | |||
const icon = document.createElement("img"); | |||
icon.src = "/images/d/dc/Whiteskull.png"; | |||
icon.className = "skull-icon"; | |||
icon.style.left = skull.x + "px"; | |||
icon.style.top = skull.y + "px"; | |||
const popup = document.createElement("div"); | |||
popup.className = "popup"; | |||
popup.innerHTML = `<strong>${skull.title}</strong><br>${skull.desc}`; | |||
popup.style.left = (skull.x + 30) + "px"; | |||
popup.style.top = (skull.y - 10) + "px"; | |||
icon.addEventListener("click", () => { | |||
popup.style.display = popup.style.display === "block" ? "none" : "block"; | |||
}); | |||
document.addEventListener("click", (e) => { | |||
if (!icon.contains(e.target) && !popup.contains(e.target)) { | |||
popup.style.display = "none"; | |||
} | |||
}); | |||
map.appendChild(icon); | |||
map.appendChild(popup); | |||
}); | |||
// HEARTS | |||
hearts.forEach((heart, index) => { | |||
const icon = document.createElement("img"); | |||
const desc = heart.desc || "Pegue o coração para se curar"; | |||
icon.src = "/images/d/d9/Heart.png"; | |||
icon.className = "heart-icon"; | |||
icon.style.left = heart.x + "px"; | |||
icon.style.top = heart.y + "px"; | |||
const popup = document.createElement("div"); | |||
popup.className = "popup"; | |||
popup.innerHTML = `<strong>Cura</strong><br>${desc}`; | |||
popup.style.left = (heart.x + 30) + "px"; | |||
popup.style.top = (heart.y - 10) + "px"; | |||
icon.addEventListener("click", () => { | |||
popup.style.display = popup.style.display === "block" ? "none" : "block"; | |||
}); | |||
document.addEventListener("click", (e) => { | |||
if (!icon.contains(e.target) && !popup.contains(e.target)) { | |||
popup.style.display = "none"; | |||
} | |||
}); | }); | ||
})(); | |||
map.appendChild(icon); | |||
map.appendChild(popup); | |||
}); | |||
// PUZZLE | |||
const button = document.createElement("img"); | |||
button.className = "puzzle-button"; | |||
button.src = "/images/d/de/Engrenagem.png"; | |||
button.style.left = puzzleButton.x + "px"; | |||
button.style.top = puzzleButton.y + "px"; | |||
const popup = document.createElement("div"); | |||
popup.className = "popup"; | |||
popup.style.left = (puzzleButton.x + 60) + "px"; | |||
popup.style.top = (puzzleButton.y - 10) + "px"; | |||
popup.innerHTML = `<strong>Desafio Puzzle</strong><br> | |||
<iframe width="400" height="260" | |||
src="${puzzleButton.videoUrl}" | |||
frameborder="0" allowfullscreen></iframe>`; | |||
button.addEventListener("click", () => { | |||
popup.style.display = popup.style.display === "block" ? "none" : "block"; | |||
}); | |||
document.addEventListener("click", (e) => { | |||
if (!button.contains(e.target) && !popup.contains(e.target)) { | |||
popup.style.display = "none"; | |||
} | |||
}); | |||
map.appendChild(button); | |||
map.appendChild(popup); | |||
</script> | </script> | ||
<style> | |||
.map-container { | |||
position: relative; | |||
width: 811px; | |||
height: 554px; | |||
background: url('/images/5/55/SabaodyMap.png') no-repeat center center; | |||
background-size: cover; | |||
} | |||
.skull-icon, .heart-icon, .puzzle-button { | |||
position: absolute; | |||
width: 26px; | |||
height: 26px; | |||
cursor: pointer; | |||
transition: transform 0.2s, filter 0.2s; | |||
} | |||
.popup { | |||
position: absolute; | |||
background: #1e1e1e; | |||
color: #fff; | |||
padding: 10px 14px; | |||
border-radius: 8px; | |||
border: 1px solid #444; | |||
box-shadow: 0 0 10px rgba(255, 255, 255, 0.1); | |||
display: none; | |||
z-index: 10; | |||
max-width: 500px; | |||
font-size: 14px; | |||
} | |||
.popup iframe { | |||
border-radius: 6px; | |||
margin-top: 6px; | |||
max-width: 100%; | |||
} | |||
.skull-icon:hover, | |||
.heart-icon:hover, | |||
.puzzle-button:hover { | |||
transform: scale(1.3); | |||
filter: brightness(1.5); | |||
} | |||
</style> | |||
Edição das 03h16min de 18 de junho de 2025
<script type="application/json" id="mapa-dados">
Erro de script: A função "data" não existe.
</script>
<script> const data = JSON.parse(document.getElementById('mapa-dados').textContent); const skulls = data.skulls || []; const hearts = data.hearts || []; const puzzleButton = data.puzzle || {}; const map = document.getElementById("map");
// SKULLS skulls.forEach((skull, index) => {
const icon = document.createElement("img");
icon.src = "/images/d/dc/Whiteskull.png";
icon.className = "skull-icon";
icon.style.left = skull.x + "px";
icon.style.top = skull.y + "px";
const popup = document.createElement("div");
popup.className = "popup";
popup.innerHTML = `${skull.title}
${skull.desc}`;
popup.style.left = (skull.x + 30) + "px";
popup.style.top = (skull.y - 10) + "px";
icon.addEventListener("click", () => {
popup.style.display = popup.style.display === "block" ? "none" : "block";
});
document.addEventListener("click", (e) => {
if (!icon.contains(e.target) && !popup.contains(e.target)) {
popup.style.display = "none";
}
});
map.appendChild(icon); map.appendChild(popup);
});
// HEARTS hearts.forEach((heart, index) => {
const icon = document.createElement("img");
const desc = heart.desc || "Pegue o coração para se curar";
icon.src = "/images/d/d9/Heart.png";
icon.className = "heart-icon";
icon.style.left = heart.x + "px";
icon.style.top = heart.y + "px";
const popup = document.createElement("div");
popup.className = "popup";
popup.innerHTML = `Cura
${desc}`;
popup.style.left = (heart.x + 30) + "px";
popup.style.top = (heart.y - 10) + "px";
icon.addEventListener("click", () => {
popup.style.display = popup.style.display === "block" ? "none" : "block";
});
document.addEventListener("click", (e) => {
if (!icon.contains(e.target) && !popup.contains(e.target)) {
popup.style.display = "none";
}
});
map.appendChild(icon); map.appendChild(popup);
});
// PUZZLE const button = document.createElement("img"); button.className = "puzzle-button"; button.src = "/images/d/de/Engrenagem.png"; button.style.left = puzzleButton.x + "px"; button.style.top = puzzleButton.y + "px";
const popup = document.createElement("div");
popup.className = "popup";
popup.style.left = (puzzleButton.x + 60) + "px";
popup.style.top = (puzzleButton.y - 10) + "px";
popup.innerHTML = `Desafio Puzzle
<iframe width="400" height="260"
src="${puzzleButton.videoUrl}"
frameborder="0" allowfullscreen></iframe>`;
button.addEventListener("click", () => {
popup.style.display = popup.style.display === "block" ? "none" : "block";
}); document.addEventListener("click", (e) => {
if (!button.contains(e.target) && !popup.contains(e.target)) {
popup.style.display = "none";
}
});
map.appendChild(button); map.appendChild(popup); </script>
<style> .map-container {
position: relative;
width: 811px;
height: 554px;
background: url('/images/5/55/SabaodyMap.png') no-repeat center center;
background-size: cover;
}
.skull-icon, .heart-icon, .puzzle-button {
position: absolute; width: 26px; height: 26px; cursor: pointer; transition: transform 0.2s, filter 0.2s;
}
.popup {
position: absolute; background: #1e1e1e; color: #fff; padding: 10px 14px; border-radius: 8px; border: 1px solid #444; box-shadow: 0 0 10px rgba(255, 255, 255, 0.1); display: none; z-index: 10; max-width: 500px; font-size: 14px;
}
.popup iframe {
border-radius: 6px; margin-top: 6px; max-width: 100%;
}
.skull-icon:hover, .heart-icon:hover, .puzzle-button:hover {
transform: scale(1.3); filter: brightness(1.5);
} </style>