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

Sem resumo de edição
Sem resumo de edição
 
(234 revisões intermediárias por 2 usuários não estão sendo mostradas)
Linha 1: Linha 1:
<script>
<!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 {
* Returns the week number for this date. dowOffset is the day of week the week
            width: 30%;
* "starts" on for your locale - it can be from 0 to 6. If dowOffset is 1 (Monday),
            box-sizing: border-box;
* the week returned is the ISO 8601 week number.
            margin: 10px;
* @param int dowOffset
            text-align: center;
* @return int
            border: 1px solid #ccc;
*/
            padding: 10px;
Date.prototype.getWeek = function (dowOffset) {
        }
    /*getWeek() was developed by Nick Baicoianu at MeanFreePath: http://www.meanfreepath.com */


    dowOffset = typeof (dowOffset) == 'number' ? dowOffset : 0; //default dowOffset to zero
         .variation-item img {
    var newYear = new Date(this.getFullYear(), 0, 1);
             width: 100px;
    var day = newYear.getDay() - dowOffset; //the day of week the year begins on
             height: 100px;
    day = (day >= 0 ? day : day + 7);
             display: block;
    var daynum = Math.floor((this.getTime() - newYear.getTime() -
             margin: 0 auto 10px;
         (this.getTimezoneOffset() - newYear.getTimezoneOffset()) * 60000) / 86400000) + 1;
    var weeknum;
    //if the year starts before the middle of a week
    if (day < 4) {
        weeknum = Math.floor((daynum + day - 1) / 7) + 1;
        if (weeknum > 52) {
             nYear = new Date(this.getFullYear() + 1, 0, 1);
             nday = nYear.getDay() - dowOffset;
             nday = nday >= 0 ? nday : nday + 7;
             /*if the next year starts before the middle of
              the week, it is week #1 of that year*/
            weeknum = nday < 4 ? 1 : 53;
         }
         }
    }
    else {
        weeknum = Math.floor((daynum + day - 1) / 7);
    }
    return weeknum;
}


const week = new Date().getWeek();
        .swap-button {
            margin-top: 10px;
            cursor: pointer;
            width: 15px;
            height: 15px;
            background: url('https://wiki.pokexgames.com/images/2/2d/Comvip.png') no-repeat center;
            background-size: contain;
            display: block;
            margin: 0 auto;
        }
    </style>
</head>
<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>


const bossCard = document.getElementById('boss-card');
        <div id="imageContainer" class="image-container hidden">
            <!-- As imagens e suas informações serão exibidas aqui -->
        </div>
    </form>


const bosses = [
    <script>
    {
        const imageList = {
        name: 'Suicune',
            'Charmander': {  
        image: 'Card_Boss-Fight-Suicune.png'
                imageUrl: 'https://wiki.pokexgames.com/images/6/65/004-Charmander.png',  
    },
                variations: [
    {
                    {
        name: 'Entei',
                        imageUrl: 'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',
        image: 'Card_Boss-Fight-Entei.png'
                        description: 'Charmander XXX',
    },
                        obtain: {
    {
                            url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
        name: 'Raikou',
                            text: 'Estilista'
        image: 'Card_Boss-Fight-Raikou.png'
                        },
    }
                        additionalImages: [
];
                            'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',  // Frente
                            'https://example.com/left1.png',  // Lado Esquerdo
                            'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',  // Costas
                            'https://example.com/right1.png'  // Lado Direito
                        ]
                    },
                    { 
                        imageUrl: 'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',
                        description: 'Charmander brabo.',
                        obtain: {
                            url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                            text: 'Estilista'
                        },
                        additionalImages: [
                            'https://example.com/front2.png',  // Frente
                            'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',  // Lado Esquerdo
                            'https://example.com/back2.png',  // Costas
                            'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.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);
                    }
                });


</script>
                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 = `
                <div class="image-item">
                    <img src="${imageInfo.imageUrl}" alt="${imageName}">
                </div>
                <div class="variations-container">
            `;
 
            imageInfo.variations.forEach((variation, index) => {
                imagesHtml += `
                    <div class="variation-item">
                        <img src="${variation.additionalImages[0]}" alt="Variation Image" class="variation-image" data-variation-index="${index}">
                          <div class="swap-button" data-variation-index="${index}"></div>
                        <div class="image-info">
                            <b>Nome do Addon</b>: ${variation.description}
                            <b>Como Obter</b>: <a href="${variation.obtain.url}" target="_blank">${variation.obtain.text}</a>
                        </div>
                    </div>
                `;
            });
 
            imagesHtml += '</div>';
 
            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;
                    variationImage.src = variation.additionalImages[currentImageIndex];
                });
            });
        }
    </script>
</body>
</html>

Edição atual tal como às 03h33min de 17 de setembro 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: 30%;
           box-sizing: border-box;
           margin: 10px;
           text-align: center;
           border: 1px solid #ccc;
           padding: 10px;
       }
       .variation-item img {
           width: 100px;
           height: 100px;
           display: block;
           margin: 0 auto 10px;
       }
       .swap-button {
           margin-top: 10px;
           cursor: pointer;
           width: 15px;
           height: 15px;
           background: url('https://wiki.pokexgames.com/images/2/2d/Comvip.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 = {
           'Charmander': { 
               imageUrl: 'https://wiki.pokexgames.com/images/6/65/004-Charmander.png', 
               variations: [
                   { 
                       imageUrl: 'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',
                       description: 'Charmander XXX',
                       obtain: {
                           url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                           text: 'Estilista'
                       },
                       additionalImages: [
                           'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',  // Frente
                           'https://example.com/left1.png',   // Lado Esquerdo
                           'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',   // Costas
                           'https://example.com/right1.png'   // Lado Direito
                       ]
                   },
                   {  
                       imageUrl: 'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',
                       description: 'Charmander brabo.',
                       obtain: {
                           url: 'https://wiki.pokexgames.com/index.php/Craft_Profissões_-_Estilista#Rank_E',
                           text: 'Estilista'
                       },
                       additionalImages: [
                           'https://example.com/front2.png',  // Frente
                           'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.png',   // Lado Esquerdo
                           'https://example.com/back2.png',   // Costas
                           'https://wiki.pokexgames.com/images/3/3b/Clefable_Lovely-_Accessory.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]}" alt="Variation Image" class="variation-image" data-variation-index="${index}">
                           Nome do Addon: ${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;
                   variationImage.src = variation.additionalImages[currentImageIndex];
               });
           });
       }
   </script>

</body> </html>