Загрузка данных


const imageSrcMap = {
    dog: "https://media.istockphoto.com/id/864274008/ru/фото/мамесиба-ину.jpg?s=612x612&w=0&k=20&c=Rz66mcaw7nrr1umepb2a-K52RpX0-T3a492VoKjXnjc=",
    flower: "https://img.freepik.com/premium-photo/colorful-flower-blossom-with-leaf-floral-design-concept-vibrant-bloom-illustration-botanic-art-decor_1292377-38429.jpg",
    bouquet: "https://avatars.mds.yandex.net/i?id=170fd55eec0c991d5f36d6106ed1ed08d41daa15-5280837-images-thumbs&n=13"
};
showBtn.addEventListener('click', () => {
    const title = document.getElementById('title').value;
    const selectedImageValue = document.querySelector('input[name="image"]:checked').value;
    const caption = document.getElementById('caption').value;
    let backgroundColor;
    if (bgColorSelect.value === 'custom') {
        backgroundColor = bgColorPicker.value;
    } else {
        backgroundColor = bgColorSelect.value;
    }
    const selectedTextColorRadio = document.querySelector('input[name="textColor"]:checked');
    let textColor = selectedTextColorRadio ? selectedTextColorRadio.value : '#000';
    const imageUrl = imageSrcMap[selectedImageValue];
    const newWindow = window.open('', '_blank', 'width=800,height=600');
    if (newWindow) {
        newWindow.document.write(`
            <html>
            <head>
                <title>${title}</title>
                <style>
                    body {
                        font-family: 'Times New Roman', serif;
                        background-color: ${backgroundColor};
                        color: ${textColor};
                        margin: 20px;
                        padding: 0;
                    }
                    h1 {
                        text-align: center;
                    }
                    img {
                        max-width: 100%;
                        height: auto;
                        display: block;
                        margin: 20px auto;
                        border-radius: 8px;
                    }
                </style>
            </head>
            <body>
                <h1>${title}</h1>
                <img src="${imageUrl}" alt="${title}">
                <p>${caption}</p>
            </body>
            </html>
        `);
        newWindow.document.close();
    } else {
        alert('Не удалось открыть новое окно. Пожалуйста, разрешите всплывающие окна для этого сайта.');
    }
});