o1-mini-2024-09-12· OpenAI
WildChat-4.8M (AI2)
دکمه دانلود تصویر و نوار پیشرفت این کد تغییر بده <!DOCTYPE html> <html lang="fa"> <head>…
- User
دکمه دانلود تصویر و نوار پیشرفت این کد تغییر بده
#loader { display: flex; width: 100%; height: 100%; justify-content: center; align-items: center; position: fixed; top: 0; left: 0; background-color: #f4f4f9; z-index: 9999; text-align: center; } #progress { width: 80%; height: 30px; background-color: #eee; border: 1px solid #ccc; border-radius: 5px; overflow: hidden; margin-bottom: 10px; } #bar { width: 0; height: 100%; background-color: #76c7c0; text-align: center; line-height: 30px; color: white; transition: width 0.2s ease; } gradio-app { display: flex; justify-content: center; align-items: center; zoom: 0.8; min-height: 100vh; } #videoModal { display: none; position: fixed; z-index: 10001; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.8); justify-content: center; align-items: center; flex-direction: column; padding: 20px; box-sizing: border-box; } #videoModalContent { background-color: #fff; color: #333; padding: 20px; border-radius: 5px; max-width: 600px; width: 100%; text-align: center; } #videoModal video { width: 100%; max-height: 500px; margin-bottom: 10px; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); } .notification, .image-save-notification { display: none; position: fixed; z-index: 10002; left: 50%; top: 50%; transform: translate(-50%, -50%); background-color: #fff; padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0,0,0,0.5); text-align: center; color: #333; max-width: 400px; width: 80%; overflow-y: auto; max-height: 90%; } #tutorialTitle { color: red; } #einsteinTip { margin-top: 10px; font-style: italic; color: #555; } #downloadButton { position: fixed; bottom: 10px; left: 10px; background-color: #76c7c0; color: white; font-size: 16px; border: none; border-radius: 5px; padding: 10px 20px; cursor: pointer; z-index: 10000; } .download-image-button { background-color: #76c7c0; color: white; font-size: 14px; border: none; border-radius: 5px; padding: 5px 10px; cursor: pointer; margin-top: 5px; display: block; } .image-preview { margin-bottom: 15px; } .confirm-text { color: green; } </style><!-- Gradio App --> <gradio-app src="https://victorestrada-diffusers-image-outpaint.hf.space/"></gradio-app> <!-- مودال نمایش ویدیو --> <div id="videoModal"> <div id="videoModalContent"> <h3 id="tutorialTitle">آموزش دانلود ویدیو</h3> <video controls id="videoPreview"></video> </div> </div> <!-- اعلان (مودال) برای نمایش تصاویر --> <div class="notification" id="imageNotification"> <h3>تصاویر قابل دانلود</h3> <div id="imageContainer"></div> <button id="closeImageNotification">بستن</button> </div> <!-- اعلان برای ذخیره تصویر --> <div class="image-save-notification" id="imageSaveNotification"> <h3>راهنمایی ذخیره تصویر</h3> <p class="confirm-text">برای ذخیره تصویر روی تأیید کلیک کنید. پس از باز شدن کامل تصویر، اسکرینشات بگیرید و سپس آن را برش دهید.</p> <button id="confirmSaveButton">تأیید</button> <button id="closeSaveNotification">بستن</button> </div> <!-- دکمه دانلود اصلی --> <button id="downloadButton">دانلود تصویر</button> <!-- اعلان ساده برای تصاویر نیافتاده --> <div class="notification" id="noImagesFoundNotification"> <h3>هیچ تصویر ساخته شدهای یافت نشد</h3> </div> <script> document.addEventListener('DOMContentLoaded', function() { function modifyText() { document.querySelectorAll('body *').forEach(element => { element.childNodes.forEach(node => { if (node.nodeType === Node.TEXT_NODE) { // مخفی کردن عناصر حاوی "GPU" if (node.nodeValue.includes('GPU')) { node.parentElement.style.display = 'none'; } // جایگزینی متنهای مشخص const replacements = { 'Examples': 'نمونه ها', 'Expected Ratio': 'اندازه مورد انتظار', 'Prompt': 'متن', 'Optional': 'انگلیسی وارد کنید', 'Generate': 'شروع ساخت', 'Diffusers Image Outpaint': 'ابزار فوق پیشرفته گسترش تصاویر', 'Drop an image you would like to extend, pick your expected ratio and hit شروع ساخت': 'با نرم افزار هوش مصنوعی', 'Input Image': 'تصویر ورودی', 'Alignment': 'تراز', 'Advanced settings': 'تنظیمات پیشرفته', 'Middle': 'وسط', 'Left': 'چپ', 'Right': 'راست', 'Top': 'بالا', 'Bottom': 'پایین', 'Width': 'عرض', 'Steps': 'مراحل', 'Height': 'ارتفاع', 'Mask': 'ماسک', 'Overlap': 'همپوشانی', 'Resize input image': 'تغییر اندازه تصویر ورودی', 'Loading': 'در حال بارگذاری' }; for (const [original, replacement] of Object.entries(replacements)) { if (node.nodeValue.includes(original)) { node.nodeValue = node.nodeValue.replace(original, replacement); } } } }); }); } function showContent() { document.getElementById('loader').style.display = 'none'; } window.onload = function() { const simulateProgress = (callback) => { let progress = 0; const progressElement = document.getElementById('bar'); const updateProgress = () => { progress += 1; if (progress > 100) progress = 100; progressElement.style.width = progress + '%'; progressElement.textContent = progress + '%'; if (progress < 100) { setTimeout(updateProgress, 50); } else { callback(); modifyText(); } } updateProgress(); }; simulateProgress(showContent); }; // اضافه کردن دکمه دانلود به تصاویر با فرمت WebP function addDownloadButtonsToWebPImages() { const imageContainer = document.getElementById('imageContainer'); imageContainer.innerHTML = ''; // پاکسازی let found = false; document.querySelectorAll('img').forEach((img, index) => { const excludedImgSrc = 'https://victorestrada-diffusers-image-outpaint.hf.space/file=/tmp/gradio/58d27ee015923ff8867291e88910c3b1fc5e49698a7a06372037c6d58cd5452e/example_1.webp'; if (img.src.endsWith('.webp') && img.src !== excludedImgSrc) { found = true; const div = document.createElement('div'); div.classList.add('image-preview'); const clonedImg = img.cloneNode(true); clonedImg.style.maxWidth = '100%'; const downloadButton = document.createElement('button'); downloadButton.textContent = 'دانلود این تصویر'; downloadButton.classList.add('download-image-button'); downloadButton.addEventListener('click', function() { showSaveNotification(img.src, `image-${index + 1}.webp`); }); div.appendChild(clonedImg); div.appendChild(downloadButton); imageContainer.appendChild(div); } }); if (found) { document.getElementById('imageNotification').style.display = 'block'; } else { document.getElementById('noImagesFoundNotification').style.display = 'block'; setTimeout(() => { document.getElementById('noImagesFoundNotification').style.display = 'none'; }, 3000); // نمایش برای ۳ ثانیه } } function showSaveNotification(imageSrc, downloadName) { const saveNotification = document.getElementById('imageSaveNotification'); saveNotification.style.display = 'block'; const confirmButton = document.getElementById('confirmSaveButton'); confirmButton.onclick = function() { saveNotification.style.display = 'none'; const a = document.createElement('a'); a.href = imageSrc; a.download = downloadName; document.body.appendChild(a); a.click(); document.body.removeChild(a); }; } document.getElementById('downloadButton').addEventListener('click', addDownloadButtonsToWebPImages); document.getElementById('closeImageNotification').addEventListener('click', function() { document.getElementById('imageNotification').style.display = 'none'; }); document.getElementById('closeSaveNotification').addEventListener('click', function() { document.getElementById('imageSaveNotification').style.display = 'none'; }); // مشاهده تغییرات برای نشان دادن تصاویر پویا const observer = new MutationObserver(modifyText); observer.observe(document.body, { childList: true, subtree: true }); }); </script> - Assistant