Widget:Test: mudanças entre as edições

De PokeXGames
Ir para navegação Ir para pesquisar
Sem resumo de edição
Sem resumo de edição
 
(198 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="pt-BR">
<html lang="pt-BR">
<head>
<head>
     <meta charset="UTF-8">
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>SelectItem</title>
     <title>Busca de Imagens por Nome</title>
     <style>
     <style>
         /* Estilos similares aos fornecidos */
         .input-group { margin-bottom: 1em; position: relative; }
         .suggest-icon {
         .dropdown {
             max-width: 20px;
            border: 1px solid #ccc;
             max-height: 20px;
            display: none;
            position: absolute;
            background-color: #fff;
            z-index: 1000;
             max-height: 150px;
            overflow-y: auto;
            width: 100%;
        }
        .dropdown-item {
             padding: 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
        }
        .dropdown-item img {
            margin-right: 10px;
         }
         }
 
         .dropdown-item:hover {
         #suggest {
             background-color: #f0f0f0;
            max-height: 300px;
             max-width: 300px;
            overflow-y: scroll;
            overflow-x: hidden;
         }
         }
 
         .image-container {
         .item-name {
             display: flex;
             display: flex;
            flex-direction: column;
             align-items: center;
             align-items: center;
            justify-content: center;
         }
         }
 
         .image-item {  
         .item-name-icon {
             margin-bottom: 1em;  
             max-width: 30px;
             text-align: center;
             margin-right: 8px;
         }
         }
 
         .image-item img {
         .craft p {
            display: block;
             margin: 0;
             margin: 0 auto;
         }
         }


         .materials {
         .variations-container {
             display: flex;
             display: flex;
            align-items: center;
             flex-wrap: wrap;
             flex-wrap: wrap;
             gap: 8px;
             justify-content: center;
            margin-top: 1em;
         }
         }


         .item-from-craft {
         .variation-item {
             display: flex;
             width: 35%;
             align-items: center;
             box-sizing: border-box;
             padding: 8px 12px;
            margin: 5px;
             border: 1px solid #ccc;
             text-align: center;
             border-radius: 8px;
             border: 1px solid ;
             padding: 10px;
        }
 
        .variation-item img {
            display: block;
            margin: 0 auto 10px;
         }
         }


         .material-icon-container {
         .swap-button {
             display: flex;
            margin-top: 10px;
             align-items: center;
            cursor: pointer;
             justify-content: center;
            width: 15px;
             width: 30px;
             height: 15px;
             height: 30px;
             background: url('https://wiki.pokexgames.com/images/f/fb/SwapButtonAddons.png') no-repeat center;
             background-size: contain;
             display: block;
             margin: 0 auto;
         }
         }
     </style>
     </style>
</head>
</head>
<body>
<body>
    <form id="imageForm">
        <div class="input-group">
            <input type="text" id="imageSearch" placeholder="Digite o nome da imagem" autocomplete="off">
            <div id="dropdown" class="dropdown"></div>
        </div>


    <input type="text" id="search" placeholder="Busque um item..." />
        <div id="imageContainer" class="image-container hidden">
    <div id="suggest"></div>
            <!-- As imagens e suas informações serão exibidas aqui -->
     <div id="content"></div>
        </div>
     </form>


    <!-- Base de dados será carregada de uma outra página -->
     <script>
     <script>
         const allData = [
         const imageList = {
             {
             'Squirtle': {  
                 "id": 18,
                 imageUrl: 'https://wiki.pokexgames.com/images/7/7a/007-Squirtle.png',  
                "name": "Bag of Pollen",
                 variations: [
                "icon": "https://wiki.pokexgames.com/images/b/bc/BagOfPollem.png",
                    {  
                "link": "https://wiki.pokexgames.com/index.php/Bag_Of_Pollem",
                        description: 'Squirtle Purple Ninja Pack',
                "isNightmare": false,
                        descriptionIMG: 'https://wiki.pokexgames.com/images/c/c1/Purple_Stripe.png',
                 "whoDrops":[
                        obtain: {
      {
                            url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
        "id": 1,
                             text: 'Estilista'
        "icon": "https://wiki.pokexgames.com/images/5/5c/001-Bulbasaur.png",
        "link": "https://wiki.pokexgames.com/index.php/Bulbasaur",
        "name": "Bulbasaur"
      },
      {
        "id": 2,
        "icon": "https://wiki.pokexgames.com/images/c/c6/003-Venusaur.png",
        "link": "https://wiki.pokexgames.com/index.php/Venusaur",
        "name": "Venusaur"
      },
      {
        "id": 3,
        "icon": "https://wiki.pokexgames.com/images/f/f0/003-MegaVenusaur.png",
        "link": "https://wiki.pokexgames.com/index.php/Mega_Venusaur",
        "name": "Mega Venusaur"
      },
      {
        "id": 4,
        "icon": "https://wiki.pokexgames.com/images/2/2a/Sh_venu.png",
        "link": "https://wiki.pokexgames.com/index.php/Shiny_Venusaur",
        "name": "Shiny Venusaur"
      },
      {
        "id": 5,
        "icon": "https://wiki.pokexgames.com/images/4/4e/012-Butterfree.png",
        "link": "https://wiki.pokexgames.com/index.php/Butterfree",
        "name": "Butterfree"
      },
      {
        "id": 6,
        "icon": "https://wiki.pokexgames.com/images/2/27/012-Sh_Butterfree.png",
        "link": "https://wiki.pokexgames.com/index.php/Shiny_Butterfree",
        "name": "Shiny Butterfree"
      },
      {
        "id": 7,
        "icon": "https://wiki.pokexgames.com/images/a/ad/015-Beedrill.png",
        "link": "https://wiki.pokexgames.com/index.php/Beedrill",
        "name": "Beedrill"
      },
      {
        "id": 8,
        "icon": "https://wiki.pokexgames.com/images/b/ba/015-Sh_Beedrill.png",
        "link": "https://wiki.pokexgames.com/index.php/Shiny_Beedrill",
        "name": "Shiny Beedrill"
      },
      {
        "id": 9,
        "icon": "https://wiki.pokexgames.com/images/1/1a/043-Oddish.png",
        "link": "https://wiki.pokexgames.com/index.php/Oddish",
        "name": "Oddish"
      },
      {
        "id": 10,
        "icon": "https://wiki.pokexgames.com/images/c/cc/043-Sh_Oddish.png",
        "link": "https://wiki.pokexgames.com/index.php/Shiny_Oddish",
        "name": "Shiny Oddish"
      },
      {
        "id": 11,
        "icon": "https://wiki.pokexgames.com/images/9/92/044-Gloom.png",
        "link": "https://wiki.pokexgames.com/index.php/Gloom",
        "name": "Gloom"
      },
      {
        "id": 12,
        "icon": "https://wiki.pokexgames.com/images/a/ab/045-Vileplume.png",
        "link": "https://wiki.pokexgames.com/index.php/Vileplume",
        "name": "Vileplume"
      },
      {
        "id": 13,
        "icon": "https://wiki.pokexgames.com/images/8/8e/Shinyvil.png",
        "link": "https://wiki.pokexgames.com/index.php/Shiny_Vileplume",
        "name": "Shiny Vileplume"
      },
      {
        "id": 14,
        "icon": "https://wiki.pokexgames.com/images/e/e7/046-Paras.png",
        "link": "https://wiki.pokexgames.com/index.php/Paras",
        "name": "Paras"
      },
      {
        "id": 15,
        "icon": "https://wiki.pokexgames.com/images/5/56/047-Parasect.png",
        "link": "https://wiki.pokexgames.com/index.php/Parasect",
        "name": "Parasect"
      },
      {
        "id": 16,
        "icon": "https://wiki.pokexgames.com/images/a/ab/048-Venonat.png",
        "link": "https://wiki.pokexgames.com/index.php/Venonat",
        "name": "Venonat"
      },
      {
        "id": 17,
        "icon": "https://wiki.pokexgames.com/images/e/ec/049-Venomoth.png",
        "link": "https://wiki.pokexgames.com/index.php/Venomoth",
        "name": "Venomoth"
      },
      {
        "id": 18,
        "icon": "https://wiki.pokexgames.com/images/0/03/049-Sh_Venomoth.png",
        "link": "https://wiki.pokexgames.com/index.php/Shiny_Venomoth",
        "name": "Shiny Venomoth"
      },
      {
        "id": 19,
        "icon": "https://wiki.pokexgames.com/images/b/bf/152-Chikorita.png",
        "link": "https://wiki.pokexgames.com/index.php/Chikorita",
        "name": "Chikorita"
      },
      {
        "id": 20,
        "icon": "https://wiki.pokexgames.com/images/f/fc/153-Bayleef.png",
        "link": "https://wiki.pokexgames.com/index.php/Bayleef",
        "name": "Bayleef"
      },
      {
        "id": 21,
        "icon": "https://wiki.pokexgames.com/images/2/2f/154-Meganium.png",
        "link": "https://wiki.pokexgames.com/index.php/Meganium",
        "name": "Meganium"
      },
      {
        "id": 22,
        "icon": "https://wiki.pokexgames.com/images/1/1b/154-Sh_Meganium.png",
        "link": "https://wiki.pokexgames.com/index.php/Shiny_Meganium",
        "name": "Shiny Meganium"
      },
      {
        "id": 23,
        "icon": "https://wiki.pokexgames.com/images/c/c7/187-Hoppip.png",
        "link": "https://wiki.pokexgames.com/index.php/Hoppip",
        "name": "Hoppip"
      },
      {
        "id": 24,
        "icon": "https://wiki.pokexgames.com/images/1/14/188-Skiploom.png",
        "link": "https://wiki.pokexgames.com/index.php/Skiploom",
        "name": "Skiploom"
      },
      {
        "id": 25,
        "icon": "https://wiki.pokexgames.com/images/e/ee/189-Jumpluff.png",
        "link": "https://wiki.pokexgames.com/index.php/Jumpluff",
        "name": "Jumpluff"
      },
      {
        "id": 26,
        "icon": "https://wiki.pokexgames.com/images/5/52/407-Roserade.png",
        "link": "https://wiki.pokexgames.com/index.php/Roserade",
        "name": "Roserade"
      },
      {
        "id": 27,
        "icon": "https://wiki.pokexgames.com/images/d/dc/412-Burmy.png",
        "link": "https://wiki.pokexgames.com/index.php/Burmy",
        "name": "Burmy"
      },
      {
        "id": 28,
        "icon": "https://wiki.pokexgames.com/images/c/cf/616-Shelmet.png",
        "link": "https://wiki.pokexgames.com/index.php/Shelmet",
        "name": "Shelmet"
      }
    ]
  },
            {
                "id": 1884,
                "name": "Anya Outfit (female)",
                "icon": "https://wiki.pokexgames.com/images/8/8a/Anya_Outfit_Designer.png",
                "link": null,
                "isNightmare": false,
                "craft": {
                    "quantity": 1,
                    "skill": "100",
                    "cooldownText": "5 dias",
                    "rank": "S",
                    "profession": "Stylist",
                    "materials": [
                        {
                            "name": "Lovely Topknot",
                            "icon": "https://wiki.pokexgames.com/images/e/e9/Lovely_Topknot.png",
                            "isNightmare": true,
                            "quantity": 10,
                             "id": 532
                         },
                         },
                         // Outros materiais...
                         additionalImages: [
                     ]
                            { url: 'https://wiki.pokexgames.com/images/d/dd/Squirtle_Purple_Ninja_Pack_Frente.png'}, // Frente
                 }
                            { url: 'https://wiki.pokexgames.com/images/5/50/Squirtle_Purple_Ninja_Pack_Esquerda.png'}, // Lado Esquerdo
                            { url: 'https://wiki.pokexgames.com/images/a/af/Squirtle_Purple_Ninja_Pack_Direita.png'}, // Costas
                            { url: 'https://wiki.pokexgames.com/images/5/5d/Squirtle_Purple_Ninja_Pack_Costas.png'}  // Lado Direito
                        ]
                     },
                    { 
                        description: 'Squirtle Red Ninja Pack',
                        descriptionIMG: 'https://wiki.pokexgames.com/images/c/c1/Purple_Stripe.png',
                        obtain: {
                            url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                            text: 'Estilista'
                        },
                        additionalImages: [
                            { url: 'https://wiki.pokexgames.com/images/1/13/Squirtle_Red_Ninja_Pack_Frente.png'}, // Frente
                            { url: 'https://wiki.pokexgames.com/images/1/1e/Squirtle_Red_Ninja_Pack_Esquerda.png'}, // Lado Esquerdo
                            { url: 'https://wiki.pokexgames.com/images/0/01/Squirtle_Red_Ninja_Pack_Costas.png'}, // Costas
                            { url: 'https://wiki.pokexgames.com/images/f/fd/Squirtle_Red_Ninja_Pack_Direita.png'}  // Lado Direito
                        ]
                    }
                 ]
             },
             },
             {
        };
                 "id": 1912,
 
                "name": "Catcher Token",
        const imageSearch = document.getElementById('imageSearch');
                "icon": "https://wiki.pokexgames.com/images/f/fd/Catcher_Token.png",
        const dropdown = document.getElementById('dropdown');
                 "link": "https://wiki.pokexgames.com/index.php/Tokens",
        const imageContainer = document.getElementById('imageContainer');
                 "isNightmare": false
 
        imageSearch.addEventListener('input', function() {
            const searchValue = this.value.trim().toLowerCase();
             dropdown.innerHTML = '';
 
            if (searchValue) {
                 Object.keys(imageList).forEach(imageName => {
                    if (imageName.toLowerCase().includes(searchValue)) {
                        const dropdownItem = document.createElement('div');
                        dropdownItem.classList.add('dropdown-item');
                       
                        const imgElement = document.createElement('img');
                        imgElement.src = imageList[imageName].imageUrl;
                        imgElement.alt = imageName;
                       
                        dropdownItem.appendChild(imgElement);
                        dropdownItem.appendChild(document.createTextNode(imageName));
                       
                        dropdownItem.addEventListener('click', function() {
                            showImageInfo(imageName);
                            dropdown.style.display = 'none';
                        });
                        dropdown.appendChild(dropdownItem);
                    }
                });
 
                 dropdown.style.display = dropdown.childNodes.length ? 'block' : 'none';
            } else {
                 dropdown.style.display = 'none';
             }
             }
         ];
         });


         const search = document.getElementById("search");
         document.addEventListener('click', function(event) {
        const suggest = document.getElementById("suggest");
            if (!imageSearch.contains(event.target) && !dropdown.contains(event.target)) {
         const content = document.getElementById("content");
                dropdown.style.display = 'none';
            }
         });


        const clearSuggestions = () => {
function showImageInfo(imageName) {
             suggest.innerHTML = "";
    const imageInfo = imageList[imageName];
         };
    let imagesHtml = `
        <div class="image-item">
             <img src="${imageInfo.imageUrl}" alt="${imageName}">
        </div>
         <div class="variations-container">
    `;


        const setItem = (id) => {
    imageInfo.variations.forEach((variation, index) => {
             const data = allData.find((data) => data.id == id);
        imagesHtml += `
             if (!data) return;
             <div class="variation-item">
            clearSuggestions();
                <img src="${variation.additionalImages[0].url}" alt="Variation Image" class="variation-image" data-variation-index="${index}" style="width: ${variation.additionalImages[0].width}px;">
                <div class="swap-button" data-variation-index="${index}"></div><br>
                <div class="image-info">
                    <img src="${variation.descriptionIMG}" alt="Description Image" style="margin-right: 5px; display: inline-block;"> <!-- Exibe a imagem antes da descrição -->
                    <br> ${variation.description} <br> <!-- Descrição após a imagem -->
                    <b>Como Obter</b>: <a href="${variation.obtain.url}" target="_blank">${variation.obtain.text}</a>
                </div>
             </div>
        `;
    });


            content.innerHTML = `
    imagesHtml += '</div>';
            <div class="item-name">
                <img class="item-name-icon" src="${data.icon}" />
                <span>${data.name}</span>
            </div>`;


            if (data.craft) {
    imageContainer.innerHTML = imagesHtml;
                content.innerHTML += `
    imageContainer.classList.remove('hidden');
                <h3>Craft</h3>
                <div class="craft">
                    <p><b>Quantidade:</b> ${data.craft.quantity}</p>
                    <p><b>Skill:</b> ${data.craft.skill} - Rank ${data.craft.rank}</p>
                    <p><b>Tempo de Craft:</b> ${data.craft.cooldownText}</p>
                    <p><b>Profissão:</b> ${data.craft.profession}</p>
                    <p><b>Materiais:</b></p>
                    <div class="materials">
                        ${data.craft.materials.map((material) => `
                        <div class="item-from-craft">
                            <div class="material-icon-container">
                                <img class="item-name-icon" src="${material.icon}" />
                            </div>
                            ${material.quantity}x ${material.name}
                        </div>`).join("")}
                    </div>
                </div>`;
            }


            const materialTo = allData.filter((item) => {
    // Alternar imagens ao clicar no botão de troca
                if (!item.craft?.materials) return false;
    const swapButtons = document.querySelectorAll('.swap-button');
                return item.craft.materials.some((m) => m.id == id);
            });


            if (materialTo.length) {
    swapButtons.forEach(button => {
                content.innerHTML += `
        const index = button.getAttribute('data-variation-index');
                <h3>Usado para craftar</h3>
        const variation = imageInfo.variations[index];
                <div class="materials">
         let currentImageIndex = 0;
                    ${materialTo.map((material) => `
                    <div class="item-from-craft">
                        <div class="material-icon-container">
                            <img class="item-name-icon" src="${material.icon}" />
                        </div>
                        ${material.name}
                    </div>`).join("")}
                </div>`;
            }
         };


         document.addEventListener("click", (e) => {
         button.addEventListener('click', () => {
             if (e.target.classList.contains("suggest-item")) {
             currentImageIndex = (currentImageIndex + 1) % variation.additionalImages.length;
                e.preventDefault();
            const variationImage = button.previousElementSibling; // Atualiza a imagem da variação
                setItem(e.target.dataset.itemId);
            variationImage.src = variation.additionalImages[currentImageIndex].url;
             }
             variationImage.style.width = `${variation.additionalImages[currentImageIndex].width}px`;
         });
         });
    });
}


        search.addEventListener("input", () => {
            const value = search.value?.toLowerCase();
            suggest.innerHTML = "";
            allData.forEach((data) => {
                if (data.name.toLowerCase().includes(value)) {
                    const div = document.createElement("div");
                    div.innerHTML = `
                    <img src="${data.icon}" class="suggest-icon" lazy />
                    <a class="suggest-item" href="#" data-item-id="${data.id}">${data.name}</a>`;
                    suggest.appendChild(div);
                }
            });
        });
     </script>
     </script>
</body>
</body>
</html>
</html>

Edição atual tal como às 23h45min de 16 de outubro de 2024

<!DOCTYPE html> <html lang="pt-BR"> <head>

   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Busca de Imagens por Nome</title>
   <style>
       .input-group { margin-bottom: 1em; position: relative; }
       .dropdown {
           border: 1px solid #ccc;
           display: none;
           position: absolute;
           background-color: #fff;
           z-index: 1000;
           max-height: 150px;
           overflow-y: auto;
           width: 100%;
       }
       .dropdown-item {
           padding: 8px;
           cursor: pointer;
           display: flex;
           align-items: center;
       }
       .dropdown-item img {
           margin-right: 10px;
       }
       .dropdown-item:hover {
           background-color: #f0f0f0;
       }
       .image-container {
           display: flex;
           flex-direction: column;
           align-items: center;
           justify-content: center;
       }
       .image-item { 
           margin-bottom: 1em; 
           text-align: center;
       }
       .image-item img {
           display: block;
           margin: 0 auto;
       }
       .variations-container {
           display: flex;
           flex-wrap: wrap;
           justify-content: center;
           margin-top: 1em;
       }
       .variation-item {
           width: 35%;
           box-sizing: border-box;
           margin: 5px;
           text-align: center;
           border: 1px solid ;
           padding: 10px;
       }
       .variation-item img {
           display: block;
           margin: 0 auto 10px;
       }
       .swap-button { 
           margin-top: 10px;
           cursor: pointer;
           width: 15px;
           height: 15px;
           background: url('https://wiki.pokexgames.com/images/f/fb/SwapButtonAddons.png') no-repeat center;
           background-size: contain;
           display: block;
           margin: 0 auto;
       }
   </style>

</head> <body>

   <form id="imageForm">
           <input type="text" id="imageSearch" placeholder="Digite o nome da imagem" autocomplete="off">
   </form>
   <script>
       const imageList = {
           'Squirtle': { 
               imageUrl: 'https://wiki.pokexgames.com/images/7/7a/007-Squirtle.png', 
               variations: [
                   { 
                       description: 'Squirtle Purple Ninja Pack',
                       descriptionIMG: 'https://wiki.pokexgames.com/images/c/c1/Purple_Stripe.png',
                       obtain: {
                           url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                           text: 'Estilista'
                       },
                       additionalImages: [
                           { url: 'https://wiki.pokexgames.com/images/d/dd/Squirtle_Purple_Ninja_Pack_Frente.png'}, // Frente
                           { url: 'https://wiki.pokexgames.com/images/5/50/Squirtle_Purple_Ninja_Pack_Esquerda.png'}, // Lado Esquerdo
                           { url: 'https://wiki.pokexgames.com/images/a/af/Squirtle_Purple_Ninja_Pack_Direita.png'}, // Costas
                           { url: 'https://wiki.pokexgames.com/images/5/5d/Squirtle_Purple_Ninja_Pack_Costas.png'}  // Lado Direito
                       ]
                   },
                   {  
                       description: 'Squirtle Red Ninja Pack',
                       descriptionIMG: 'https://wiki.pokexgames.com/images/c/c1/Purple_Stripe.png',
                       obtain: {
                           url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                           text: 'Estilista'
                       },
                       additionalImages: [
                           { url: 'https://wiki.pokexgames.com/images/1/13/Squirtle_Red_Ninja_Pack_Frente.png'}, // Frente
                           { url: 'https://wiki.pokexgames.com/images/1/1e/Squirtle_Red_Ninja_Pack_Esquerda.png'}, // Lado Esquerdo
                           { url: 'https://wiki.pokexgames.com/images/0/01/Squirtle_Red_Ninja_Pack_Costas.png'}, // Costas
                           { url: 'https://wiki.pokexgames.com/images/f/fd/Squirtle_Red_Ninja_Pack_Direita.png'}  // Lado Direito
                       ]
                   }
               ]
           },
       };
       const imageSearch = document.getElementById('imageSearch');
       const dropdown = document.getElementById('dropdown');
       const imageContainer = document.getElementById('imageContainer');
       imageSearch.addEventListener('input', function() {
           const searchValue = this.value.trim().toLowerCase();
           dropdown.innerHTML = ;
           if (searchValue) {
               Object.keys(imageList).forEach(imageName => {
                   if (imageName.toLowerCase().includes(searchValue)) {
                       const dropdownItem = document.createElement('div');
                       dropdownItem.classList.add('dropdown-item');
                       
                       const imgElement = document.createElement('img');
                       imgElement.src = imageList[imageName].imageUrl;
                       imgElement.alt = imageName;
                       
                       dropdownItem.appendChild(imgElement);
                       dropdownItem.appendChild(document.createTextNode(imageName));
                       
                       dropdownItem.addEventListener('click', function() {
                           showImageInfo(imageName);
                           dropdown.style.display = 'none';
                       });
                       dropdown.appendChild(dropdownItem);
                   }
               });
               dropdown.style.display = dropdown.childNodes.length ? 'block' : 'none';
           } else {
               dropdown.style.display = 'none';
           }
       });
       document.addEventListener('click', function(event) {
           if (!imageSearch.contains(event.target) && !dropdown.contains(event.target)) {
               dropdown.style.display = 'none';
           }
       });

function showImageInfo(imageName) {

   const imageInfo = imageList[imageName];
   let imagesHtml = `
           <img src="${imageInfo.imageUrl}" alt="${imageName}">
   `;
   imageInfo.variations.forEach((variation, index) => {
       imagesHtml += `
                <img src="${variation.additionalImages[0].url}" alt="Variation Image" class="variation-image" data-variation-index="${index}" style="width: ${variation.additionalImages[0].width}px;">

                   <img src="${variation.descriptionIMG}" alt="Description Image" style="margin-right: 5px; display: inline-block;"> 
                   
${variation.description}
Como Obter: <a href="${variation.obtain.url}" target="_blank">${variation.obtain.text}</a>
       `;
   });
imagesHtml += '

';

   imageContainer.innerHTML = imagesHtml;
   imageContainer.classList.remove('hidden');
   // Alternar imagens ao clicar no botão de troca
   const swapButtons = document.querySelectorAll('.swap-button');
   swapButtons.forEach(button => {
       const index = button.getAttribute('data-variation-index');
       const variation = imageInfo.variations[index];
       let currentImageIndex = 0;
       button.addEventListener('click', () => {
           currentImageIndex = (currentImageIndex + 1) % variation.additionalImages.length;
           const variationImage = button.previousElementSibling; // Atualiza a imagem da variação
           variationImage.src = variation.additionalImages[currentImageIndex].url;
           variationImage.style.width = `${variation.additionalImages[currentImageIndex].width}px`;
       });
   });

}

   </script>

</body> </html>