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

De Wiki Gla
Ir para navegação Ir para pesquisar
m
m
 
(198 revisões intermediárias por 3 usuários não estão sendo mostradas)
Linha 1: Linha 1:
<div class="map-controls">
<style>
  <button class="layer-button active" data-layer="camada1">Camada 1</button>
    .island-grid {
  <button class="layer-button" data-layer="camada2">Camada 2</button>
        display: flex;
</div>
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        padding: 12px 0;
    }


<div class="map-container" id="map"></div>
    .island-banner {
        position: relative;
        width: 380px;
        height: 90px;
        overflow: hidden;
        border-radius: 8px;
        box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 10px;
        cursor: pointer;
        transition: transform 0.15s, box-shadow 0.15s;
        display: block;
        box-sizing: border-box;
    }


<script>
     .island-banner::before {
  const MAP_DATA = {
        content: "";
     camada1: {
        position: absolute;
      background: "https://i.imgur.com/9z4WZL1.png",
         top: 0;
      skulls: [
         left: 0;
         { x: 410, y: 220, title: "White Skull", desc: "Boss: White Skull<br>Área sombria, cuidado com os ataques surpresa!" },
         right: 0;
         { x: 650, y: 125, title: "Red Fang", desc: "Boss: Red Fang<br>Possui resistência a fogo. Traga ataques de gelo!" },
         bottom: 0;
         { x: 250, y: 410, title: "Void Wraith", desc: "Boss: Void Wraith<br>Evite ataques diretos. Usa magia de sombras." },
         background: linear-gradient(105deg, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.35) 40%, rgba(0, 0, 0, 0.1) 70%, transparent 100%);
         { x: 248, y: 320, title: "Night Howler", desc: "Boss: Night Howler<br>Ataca com velocidade e confusão. Use proteção contra atordoamento!" }
        pointer-events: none;
      ],
         z-index: 1;
      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." }
      ]
    },
    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 }
      ]
     }
     }
  };


  const map = document.getElementById("map");
    .island-banner:hover {
        transform: translateY(-2px);
        box-shadow: rgba(0, 0, 0, 0.35) 0px 4px 12px;
    }


  function createIcon(x, y, className, src, popupHTML) {
    .island-banner .island-chests {
    const icon = document.createElement("img");
        position: absolute;
    icon.src = src;
        top: 8px;
    icon.className = className;
        left: 8px;
    icon.style.left = x + "px";
        display: flex;
     icon.style.top = y + "px";
        flex-wrap: wrap;
        gap: 6px;
        z-index: 2;
        pointer-events: none;
     }


     const popup = document.createElement("div");
     .island-banner .island-chest-group {
    popup.className = "popup";
        position: relative;
    popup.innerHTML = popupHTML;
        display: inline-block;
    map.appendChild(icon);
     }
     map.appendChild(popup);


     function positionPopup() {
     .island-banner .island-chest-group img {
      const mapRect = map.getBoundingClientRect();
         display: block;
      const iconRect = icon.getBoundingClientRect();
         width: auto;
      const popupRect = popup.getBoundingClientRect();
        height: auto;
      const spaceRight = mapRect.right - iconRect.right;
      const spaceLeft = iconRect.left - mapRect.left;
 
      if (spaceRight < popupRect.width && spaceLeft > popupRect.width) {
         popup.style.left = (x - popupRect.width - 10) + "px";
      } else {
         popup.style.left = (x + 30) + "px";
      }
      popup.style.top = (y - 10) + "px";
     }
     }


     icon.addEventListener("click", () => {
     .island-banner .island-chest-count {
      const visible = popup.style.display === "block";
    position: absolute;
      document.querySelectorAll(".popup").forEach(p => p.style.display = "none");
    left: 0;          /* era right: 0 */
      if (!visible) {
    bottom: 0;
        popup.style.display = "block";
    font-size: 12.5px;  /* era 11px */
        positionPopup();
    font-weight: bold;
      }
    color: #fff;
    });
    background: rgba(0, 0, 0, 0.75);
    padding: 1px 3px;
    border-radius: 3px;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    z-index: 10;
}


     document.addEventListener("click", (e) => {
     .island-banner .island-title {
      if (!icon.contains(e.target) && !popup.contains(e.target)) {
        position: absolute;
         popup.style.display = "none";
        bottom: 10px;
      }
        left: 8px;
     });
        font-size: 1.35em;
  }
        font-weight: bold;
        color: #fff;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 2px 4px rgba(0, 0, 0, 0.5);
         line-height: 1.2;
        z-index: 2;
        pointer-events: none;
        text-transform: uppercase;
     }


  function renderLayer(layerKey) {
    @media (max-width: 768px) {
    const config = MAP_DATA[layerKey];
        .island-grid {
    if (!config) return;
            flex-direction: column;
            align-items: stretch;
        }


    map.innerHTML = "";
        .island-banner {
    map.style.backgroundImage = `url('${config.background}')`;
            width: 100%;
 
            max-width: none;
    config.skulls?.forEach(skull => {
         }
      createIcon(skull.x, skull.y, "skull-icon", "/images/d/dc/Whiteskull.png",
     }
         `<strong>${skull.title}</strong><br>${skull.desc}`);
</style>
     });
<script>
 
     (function () {
    config.hearts?.forEach(heart => {
        function applyBackgrounds() {
      const desc = heart.desc || "Pegue o coração para se curar";
            document.querySelectorAll('.island-banner[data-bgimg]').forEach(function (el) {
      createIcon(heart.x, heart.y, "heart-icon", "/images/d/d9/Heart.png",
                var filename = el.getAttribute('data-bgimg');
        `<strong>Cura</strong><br>${desc}`);
                if (!filename) return;
     });
                var url;
  }
                if (typeof mw !== 'undefined' && mw.util && mw.util.getUrl) {
 
                    url = mw.util.getUrl('Especial:FilePath/' + filename);
  document.querySelectorAll(".layer-button").forEach(btn => {
                } else {
    btn.addEventListener("click", e => {
                    url = '/index.php?title=Especial:FilePath/' + encodeURIComponent(filename);
      document.querySelectorAll(".layer-button").forEach(b => b.classList.remove("active"));
                }
      e.target.classList.add("active");
                el.style.backgroundImage = 'url(' + url + ')';
      renderLayer(e.target.dataset.layer);
                el.style.backgroundSize = 'cover';
    });
                el.style.backgroundPosition = 'center';
  });
                el.style.backgroundRepeat = 'no-repeat';
 
            });
  renderLayer("camada1");
         }
 
         function initClickable() {
  document.head.insertAdjacentHTML('beforeend', `
            document.querySelectorAll('.island-banner[data-href]').forEach(function (el) {
    <style>
                if (el._icClick) return;
      .map-controls {
                el._icClick = true;
        margin-bottom: 10px;
                el.setAttribute('role', 'link');
        display: flex;
                el.setAttribute('tabindex', '0');
        gap: 8px;
                el.addEventListener('click', function () {
      }
                    var href = el.getAttribute('data-href');
      .layer-button {
                    if (href) window.location.href = href;
        padding: 6px 14px;
                });
        background-color: #222;
                el.addEventListener('keydown', function (e) {
         color: #eee;
                    if (e.key === 'Enter' || e.key === ' ') {
         border: 1px solid #444;
                        e.preventDefault();
        border-radius: 6px;
                        var href = el.getAttribute('data-href');
        cursor: pointer;
                        if (href) window.location.href = href;
        font-weight: bold;
                    }
        transition: background 0.3s, border 0.3s;
                });
      }
            });
      .layer-button.active {
         }
        background-color: #3b82f6;
         function run() {
        border-color: #3b82f6;
            applyBackgrounds();
        color: white;
            initClickable();
      }
         }
      .map-container {
         if (document.readyState === 'loading') {
        position: relative;
            document.addEventListener('DOMContentLoaded', run);
        width: 811px;
         } else {
        height: 554px;
            run();
        background-size: cover;
        }
        background-repeat: no-repeat;
     })();
        background-position: center center;
      }
      .skull-icon, .heart-icon {
        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; }
      .skull-icon:hover, .heart-icon: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;
      }
      @keyframes fadeIn {
        from { opacity: 0; transform: translateY(-5px); }
         to  { opacity: 1; transform: translateY(0); }
      }
     </style>
  `);
</script>
</script>

Edição atual tal como às 00h06min de 13 de março de 2026

<style>

   .island-grid {
       display: flex;
       flex-wrap: wrap;
       justify-content: center;
       gap: 10px;
       padding: 12px 0;
   }
   .island-banner {
       position: relative;
       width: 380px;
       height: 90px;
       overflow: hidden;
       border-radius: 8px;
       box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 10px;
       cursor: pointer;
       transition: transform 0.15s, box-shadow 0.15s;
       display: block;
       box-sizing: border-box;
   }
   .island-banner::before {
       content: "";
       position: absolute;
       top: 0;
       left: 0;
       right: 0;
       bottom: 0;
       background: linear-gradient(105deg, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.35) 40%, rgba(0, 0, 0, 0.1) 70%, transparent 100%);
       pointer-events: none;
       z-index: 1;
   }
   .island-banner:hover {
       transform: translateY(-2px);
       box-shadow: rgba(0, 0, 0, 0.35) 0px 4px 12px;
   }
   .island-banner .island-chests {
       position: absolute;
       top: 8px;
       left: 8px;
       display: flex;
       flex-wrap: wrap;
       gap: 6px;
       z-index: 2;
       pointer-events: none;
   }
   .island-banner .island-chest-group {
       position: relative;
       display: inline-block;
   }
   .island-banner .island-chest-group img {
       display: block;
       width: auto;
       height: auto;
   }
   .island-banner .island-chest-count {
   position: absolute;
   left: 0;          /* era right: 0 */
   bottom: 0;
   font-size: 12.5px;  /* era 11px */
   font-weight: bold;
   color: #fff;
   background: rgba(0, 0, 0, 0.75);
   padding: 1px 3px;
   border-radius: 3px;
   line-height: 1;
   white-space: nowrap;
   box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
   z-index: 10;

}

   .island-banner .island-title {
       position: absolute;
       bottom: 10px;
       left: 8px;
       font-size: 1.35em;
       font-weight: bold;
       color: #fff;
       text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 2px 4px rgba(0, 0, 0, 0.5);
       line-height: 1.2;
       z-index: 2;
       pointer-events: none;
       text-transform: uppercase;
   }
   @media (max-width: 768px) {
       .island-grid {
           flex-direction: column;
           align-items: stretch;
       }
       .island-banner {
           width: 100%;
           max-width: none;
       }
   }

</style> <script>

   (function () {
       function applyBackgrounds() {
           document.querySelectorAll('.island-banner[data-bgimg]').forEach(function (el) {
               var filename = el.getAttribute('data-bgimg');
               if (!filename) return;
               var url;
               if (typeof mw !== 'undefined' && mw.util && mw.util.getUrl) {
                   url = mw.util.getUrl('Especial:FilePath/' + filename);
               } else {
                   url = '/index.php?title=Especial:FilePath/' + encodeURIComponent(filename);
               }
               el.style.backgroundImage = 'url(' + url + ')';
               el.style.backgroundSize = 'cover';
               el.style.backgroundPosition = 'center';
               el.style.backgroundRepeat = 'no-repeat';
           });
       }
       function initClickable() {
           document.querySelectorAll('.island-banner[data-href]').forEach(function (el) {
               if (el._icClick) return;
               el._icClick = true;
               el.setAttribute('role', 'link');
               el.setAttribute('tabindex', '0');
               el.addEventListener('click', function () {
                   var href = el.getAttribute('data-href');
                   if (href) window.location.href = href;
               });
               el.addEventListener('keydown', function (e) {
                   if (e.key === 'Enter' || e.key === ' ') {
                       e.preventDefault();
                       var href = el.getAttribute('data-href');
                       if (href) window.location.href = href;
                   }
               });
           });
       }
       function run() {
           applyBackgrounds();
           initClickable();
       }
       if (document.readyState === 'loading') {
           document.addEventListener('DOMContentLoaded', run);
       } else {
           run();
       }
   })();

</script>