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

De Wiki Gla
Ir para navegação Ir para pesquisar
m
m
Linha 1: Linha 1:
  <div class="map-container" id="map">
<select id="layerSelector" style="margin-bottom: 8px">
    <!-- Caveiras e elementos serão inseridos via JS -->
  <option value="camada1">Camada 1</option>
  </div>
  <option value="camada2">Camada 2</option>
</select>


  <script>
<div class="map-container" id="map"></div>
    const skulls = [
      {
        x: 410, y: 220,
        title: "White Skull",
        desc: "Boss: White Skull<br>Área sombria, cuidado com os ataques surpresa!"
      },
      {
        x: 650, y: 125,
        title: "Red Fang",
        desc: "Boss: Red Fang<br>Possui resistência a fogo. Traga ataques de gelo!"
      },
      {
        x: 250, y: 410,
        title: "Void Wraith",
        desc: "Boss: Void Wraith<br>Evite ataques diretos. Usa magia de sombras."
      },
      {
        x: 248, y: 320,
        title: "Night Howler",
        desc: "Boss: Night Howler<br>Ataca com velocidade e confusão. Use proteção contra atordoamento!"
      }
    ];


    const hearts = [
<script>
       { x: 280, y: 210, desc: "Cura escondida: Quebre a caixa para obter uma cura." },
  const MAP_DATA = {
      { x: 312, y: 196 },
    camada1: {
      { x: 245, y: 358, desc: "Após o chefe, o jogador com menos vida receberá uma cura automática." }
      background: "https://i.imgur.com/9z4WZL1.png",
     ];
      skulls: [
        { x: 410, y: 220, title: "White Skull", desc: "Boss: White Skull<br>Área sombria, cuidado com os ataques surpresa!" },
        { x: 650, y: 125, title: "Red Fang", desc: "Boss: Red Fang<br>Possui resistência a fogo. Traga ataques de gelo!" },
        { x: 250, y: 410, title: "Void Wraith", desc: "Boss: Void Wraith<br>Evite ataques diretos. Usa magia de sombras." },
        { x: 248, y: 320, title: "Night Howler", desc: "Boss: Night Howler<br>Ataca com velocidade e confusão. Use proteção contra atordoamento!" }
      ],
       hearts: [
        { x: 280, y: 210, desc: "Cura escondida: Quebre a caixa para obter uma cura." },
        { x: 312, y: 196 },
        { x: 245, y: 358, desc: "Após o chefe, o jogador com menos vida receberá uma cura automática." }
      ],
      puzzle: { x: 244, y: 217, videoUrl: "https://www.youtube.com/embed/10rhyP32vdw" }
     },
    camada2: {
      background: "https://i.imgur.com/IoBLbik.png",
      skulls: [
        { x: 330, y: 150, title: "Phantom", desc: "Boss: Phantom<br>Usa invisibilidade e veneno." }
      ],
      hearts: [
        { x: 290, y: 190 }
      ],
      puzzle: { x: 220, y: 200, videoUrl: "https://www.youtube.com/embed/10rhyP32vdw" }
    }
  };


    const puzzleButton = {
  const map = document.getElementById("map");
      x: 244,
  const selector = document.getElementById("layerSelector");
      y: 217,
      videoUrl: "https://www.youtube.com/embed/10rhyP32vdw"
    };


    const map = document.getElementById("map");
  function createIcon(x, y, className, src, popupHTML) {
 
     const icon = document.createElement("img");
    // Adiciona as caveiras
    icon.src = src;
    skulls.forEach((skull, index) => {
    icon.className = className;
      const icon = document.createElement("img");
    icon.style.left = x + "px";
      icon.src = "/images/d/dc/Whiteskull.png";
     icon.style.top = y + "px";
      icon.className = "skull-icon";
      icon.style.left = skull.x + "px";
      icon.style.top = skull.y + "px";
      icon.dataset.index = index;
 
      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);
     });
 
    // Adiciona os corações
    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";
      icon.dataset.index = index;
 
      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);
    });
 
    // Ícone do Puzzle
    const button = document.createElement("img");
    button.className = "puzzle-button";
    button.src = "/images/d/de/Engrenagem.png";
    button.alt = "Puzzle";
    button.style.left = puzzleButton.x + "px";
     button.style.top = puzzleButton.y + "px";


     const popup = document.createElement("div");
     const popup = document.createElement("div");
     popup.className = "popup";
     popup.className = "popup";
     popup.style.left = (puzzleButton.x + 60) + "px";
    popup.innerHTML = popupHTML;
     popup.style.top = (puzzleButton.y - 10) + "px";
     popup.style.left = (x + 30) + "px";
    popup.innerHTML = `
     popup.style.top = (y - 10) + "px";
      <strong>Desafio Puzzle</strong><br>
      <iframe width="400" height="260"
        src="${puzzleButton.videoUrl}"
        frameborder="0"
        allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
        allowfullscreen>
      </iframe>
    `;


     button.addEventListener("click", () => {
     icon.addEventListener("click", () => {
       popup.style.display = popup.style.display === "block" ? "none" : "block";
       popup.style.display = popup.style.display === "block" ? "none" : "block";
     });
     });
     document.addEventListener("click", (e) => {
     document.addEventListener("click", (e) => {
       if (!button.contains(e.target) && !popup.contains(e.target)) {
       if (!icon.contains(e.target) && !popup.contains(e.target)) {
         popup.style.display = "none";
         popup.style.display = "none";
       }
       }
     });
     });


     map.appendChild(button);
     map.appendChild(icon);
     map.appendChild(popup);
     map.appendChild(popup);
// CSS
   }
    document.head.insertAdjacentHTML('beforeend', `
   <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 {
  function renderLayer(layerKey) {
      position: absolute;
    const config = MAP_DATA[layerKey];
      width: 24px;
    if (!config) return;
      height: 24px;
      cursor: pointer;
      transition: transform 0.2s, filter 0.2s;
    }


     .heart-icon {
     map.innerHTML = "";
      position: absolute;
    map.style.backgroundImage = `url('${config.background}')`;
      width: 26px;
      height: 26px;
      padding: 1px;
      cursor: pointer;
      transition: transform 0.2s, filter 0.2s;
    }


     .skull-icon:hover,
     config.skulls?.forEach(skull => {
    .heart-icon:hover,
      createIcon(skull.x, skull.y, "skull-icon", "/images/d/dc/Whiteskull.png",
    .puzzle-button:hover {
        `<strong>${skull.title}</strong><br>${skull.desc}`);
      transform: scale(1.3);
    });
      filter: brightness(1.5);
    }


     .popup {
     config.hearts?.forEach(heart => {
       position: absolute;
       const desc = heart.desc || "Pegue o coração para se curar";
       background: #1e1e1e;
       createIcon(heart.x, heart.y, "heart-icon", "/images/d/d9/Heart.png",
      color: #fff;
        `<strong>Cura</strong><br>${desc}`);
      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;
      animation: fadeIn 0.3s ease-out;
     }


     .popup iframe {
     if (config.puzzle) {
       border-radius: 6px;
       createIcon(config.puzzle.x, config.puzzle.y, "puzzle-button", "/images/d/de/Engrenagem.png",
      margin-top: 6px;
        `<strong>Desafio Puzzle</strong><br><iframe width="400" height="260" src="${config.puzzle.videoUrl}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`);
      max-width: 100%;
     }
     }
  }


    .puzzle-button {
  selector.addEventListener("change", e => renderLayer(e.target.value));
      position: absolute;
  renderLayer("camada1");
      cursor: pointer;
      z-index: 999;
      width: 28px;
      height: 28px;
      transition: transform 0.2s, filter 0.2s;
    }


     @keyframes fadeIn {
  document.head.insertAdjacentHTML('beforeend', `
      from { opacity: 0; transform: translateY(-5px); }
     <style>
      to { opacity: 1; transform: translateY(0); }
      .map-container {
    }
        position: relative;
  </style>
        width: 811px;
        height: 554px;
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center center;
      }
      .skull-icon, .heart-icon, .puzzle-button {
        position: absolute;
        cursor: pointer;
        transition: transform 0.2s, filter 0.2s;
      }
      .skull-icon { width: 24px; height: 24px; }
      .heart-icon { width: 26px; height: 26px; padding: 1px; }
      .puzzle-button { width: 28px; height: 28px; z-index: 999; }
      .skull-icon:hover, .heart-icon:hover, .puzzle-button:hover {
        transform: scale(1.3);
        filter: brightness(1.5);
      }
      .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;
        animation: fadeIn 0.3s ease-out;
      }
      .popup iframe {
        border-radius: 6px;
        margin-top: 6px;
        max-width: 100%;
      }
      @keyframes fadeIn {
        from { opacity: 0; transform: translateY(-5px); }
        to   { opacity: 1; transform: translateY(0); }
      }
    </style>
   `);
   `);
</script>
</script>

Edição das 03h45min de 18 de junho de 2025

<select id="layerSelector" style="margin-bottom: 8px">

 <option value="camada1">Camada 1</option>
 <option value="camada2">Camada 2</option>

</select>

<script>

 const MAP_DATA = {
   camada1: {
     background: "https://i.imgur.com/9z4WZL1.png",
     skulls: [
       { x: 410, y: 220, title: "White Skull", desc: "Boss: White Skull
Área sombria, cuidado com os ataques surpresa!" }, { x: 650, y: 125, title: "Red Fang", desc: "Boss: Red Fang
Possui resistência a fogo. Traga ataques de gelo!" }, { x: 250, y: 410, title: "Void Wraith", desc: "Boss: Void Wraith
Evite ataques diretos. Usa magia de sombras." }, { x: 248, y: 320, title: "Night Howler", desc: "Boss: Night Howler
Ataca com velocidade e confusão. Use proteção contra atordoamento!" } ], hearts: [ { x: 280, y: 210, desc: "Cura escondida: Quebre a caixa para obter uma cura." }, { x: 312, y: 196 }, { x: 245, y: 358, desc: "Após o chefe, o jogador com menos vida receberá uma cura automática." } ], puzzle: { x: 244, y: 217, videoUrl: "https://www.youtube.com/embed/10rhyP32vdw" } }, camada2: { background: "https://i.imgur.com/IoBLbik.png", skulls: [ { x: 330, y: 150, title: "Phantom", desc: "Boss: Phantom
Usa invisibilidade e veneno." } ], hearts: [ { x: 290, y: 190 } ], puzzle: { x: 220, y: 200, videoUrl: "https://www.youtube.com/embed/10rhyP32vdw" } } };
 const map = document.getElementById("map");
 const selector = document.getElementById("layerSelector");
 function createIcon(x, y, className, src, popupHTML) {
   const icon = document.createElement("img");
   icon.src = src;
   icon.className = className;
   icon.style.left = x + "px";
   icon.style.top = y + "px";
   const popup = document.createElement("div");
   popup.className = "popup";
   popup.innerHTML = popupHTML;
   popup.style.left = (x + 30) + "px";
   popup.style.top = (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);
 }
 function renderLayer(layerKey) {
   const config = MAP_DATA[layerKey];
   if (!config) return;
   map.innerHTML = "";
   map.style.backgroundImage = `url('${config.background}')`;
   config.skulls?.forEach(skull => {
     createIcon(skull.x, skull.y, "skull-icon", "/images/d/dc/Whiteskull.png",
       `${skull.title}
${skull.desc}`); });
   config.hearts?.forEach(heart => {
     const desc = heart.desc || "Pegue o coração para se curar";
     createIcon(heart.x, heart.y, "heart-icon", "/images/d/d9/Heart.png",
       `Cura
${desc}`); });
   if (config.puzzle) {
     createIcon(config.puzzle.x, config.puzzle.y, "puzzle-button", "/images/d/de/Engrenagem.png",
       `Desafio Puzzle
<iframe width="400" height="260" src="${config.puzzle.videoUrl}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`); } }
 selector.addEventListener("change", e => renderLayer(e.target.value));
 renderLayer("camada1");
 document.head.insertAdjacentHTML('beforeend', `
   <style>
     .map-container {
       position: relative;
       width: 811px;
       height: 554px;
       background-size: cover;
       background-repeat: no-repeat;
       background-position: center center;
     }
     .skull-icon, .heart-icon, .puzzle-button {
       position: absolute;
       cursor: pointer;
       transition: transform 0.2s, filter 0.2s;
     }
     .skull-icon { width: 24px; height: 24px; }
     .heart-icon { width: 26px; height: 26px; padding: 1px; }
     .puzzle-button { width: 28px; height: 28px; z-index: 999; }
     .skull-icon:hover, .heart-icon:hover, .puzzle-button:hover {
       transform: scale(1.3);
       filter: brightness(1.5);
     }
     .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;
       animation: fadeIn 0.3s ease-out;
     }
     .popup iframe {
       border-radius: 6px;
       margin-top: 6px;
       max-width: 100%;
     }
     @keyframes fadeIn {
       from { opacity: 0; transform: translateY(-5px); }
       to   { opacity: 1; transform: translateY(0); }
     }
   </style>
 `);

</script>