در پاسخ به درخواست شما، دکمه دانلود و دکمه اسکرول به همراه تمامی کدهای مرتبط با آنها از کد اصلی حذف شدهاند. در زیر نسخه نهایی و کامل کد HTML بدون این دو المان را مشاهده میکنید:
<!DOCTYPE html>
<html lang="fa">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>صفحه با iframe و نوار پیشرفت</title>
<style>
/* تنظیمات پایه برای body و html */
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden; /* مخفی کردن اسکرولهای اضافی */
background-color: #f0f0f0; /* رنگ پسزمینه */
font-family: Arial, sans-serif;
}
/* متغیر CSS برای ارتفاع نمایشگر */
:root {
--vh: 100%;
}
/* کانتینر iframe - initially not full screen */
.iframe-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh; /* ارتفاع کامل نمایشگر */
overflow: hidden; /* مخفی کردن بخشهای اضافی */
z-index: 1; /* ترتیب نمایش */
}
/* تنظیمات iframe */
.iframe-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
display: none; /* ابتدا مخفی است */
}
/* Overlay برای مخفی کردن بخش بالایی و پایینی صفحه - برای حالت تمام صفحه */
.overlay-top, .overlay-bottom {
position: fixed;
left: 0;
width: 100%;
background-color: transparent; /* رنگ پسزمینه شفاف */
z-index: 900; /* زیر iframe-container */
pointer-events: none; /* اجازه دادن به اسکرول از طریق iframe */
display: none; /* ابتدا مخفی است */
}
.overlay-top {
top: 0;
height: 192.75px; /* ارتفاع ۵.۱ سانتیمتر (192.75px) */
}
.overlay-bottom {
bottom: 0;
height: 38px; /* ارتفاع ۱ سانتیمتر (38px) */
}
/* نوار پیشرفت و لودینگ */
.loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
z-index: 10000;
}
.loading-message {
margin-bottom: 20px;
font-size: 18px;
}
.progress {
width: 80%;
max-width: 400px;
height: 20px;
background-color: #ddd;
border-radius: 5px;
overflow: hidden;
}
.progress-bar {
height: 100%;
width: 0;
background-color: #4caf50;
transition: width 1s;
}
.error-message {
display: none;
color: red;
margin-top: 20px;
font-size: 16px;
text-align: center;
}
#retryButton {
display: none;
margin-top: 10px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background-color: #4caf50;
color: white;
border: none;
border-radius: 5px;
}
/* استایل پنجره سفارشی (modal) */
.modal {
display: none;
position: fixed;
z-index: 10002;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 500px;
text-align: center;
border-radius: 5px;
}
.modal-button {
margin-top: 20px;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
}
.cancel-btn {
background-color: #f44336;
color: white;
}
@media (max-width: 768px) {
/* تنظیمات واکنشگرا مخصوص زمانی که دکمههای حذف شده نداریم */
}
@keyframes pulse {
0% { transform: translateY(-50%) scale(1); }
50% { transform: translateY(-50%) scale(1.1); }
100% { transform: translateY(-50%) scale(1); }
}
</style>
</head>
<body>
<!-- پنجره سفارشی (modal) برای تصاویر شناسایی شده -->
<div id="myModal" class="modal">
<div class="modal-content">
<p style="text-align: center;">تصاویر شناسایی‌شده</p>
<div class="image-container" id="imageContainer">
<!-- تصاویر شناساییشده در اینجا قرار میگیرند -->
</div>
<button class="modal-button cancel-btn" id="closeBtn">بستن</button>
</div>
</div>
<!-- لودینگ و iframe -->
<div class="iframe-container" id="iframeContainer">
<div class="loading" id="loadingContainer">
<div class="loading-message">لطفاً صبر کنید...</div>
<div class="progress">
<div class="progress-bar" id="progressBar"></div>
</div>
<div class="error-message" id="errorMessage">بارگیری زیاد طول کشید.<br />در صورت عدم بارگذاری، فیلترشکن خود را روشن کنید.</div>
<button id="retryButton">بارگذاری مجدد</button>
</div>
<iframe id="myIframe"></iframe>
</div>
<!-- Overlay برای مخفی کردن بخش بالایی و پایینی صفحه پس از بارگذاری -->
<div class="overlay-top" id="overlayTop"></div>
<div class="overlay-bottom" id="overlayBottom"></div>
<script>
const siteURL = 'https://ovi054-image-to-prompt.hf.space/';
const excludeUrls = [
'https://yanze-pulid.hf.space/--replicas/3t64n/file=/tmp/gradio/7567beceda2541f726af7beb4c9aa857b4a96b77/liuyifei.png'
];
let progress = 0;
const progressBar = document.getElementById('progressBar');
const retryButton = document.getElementById('retryButton');
const errorMessage = document.getElementById('errorMessage');
const loadingContainer = document.getElementById('loadingContainer');
const iframe = document.getElementById('myIframe');
const iframeContainer = document.getElementById('iframeContainer');
const overlayTop = document.getElementById('overlayTop');
const overlayBottom = document.getElementById('overlayBottom');
let interval;
let iframeLoadedFlag = false;
function startProgress() {
loadingContainer.style.display = 'flex';
progressBar.style.width = '0%';
progress = 0;
interval = setInterval(() => {
if (progress < 90) { // محدود کردن پیشرفت تا 90%
progress += Math.floor(Math.random() * 10) + 5; // افزایش تصادفی
if (progress > 90) progress = 90;
progressBar.style.width = progress + '%';
}
}, 1000);
}
function iframeLoaded() {
iframeLoadedFlag = true;
clearInterval(interval);
progressBar.style.width = '100%';
setTimeout(() => {
loadingContainer.style.display = 'none';
iframe.style.display = 'block';
// تنظیم iframe-container به حالت تمام صفحه
iframeContainer.style.height = '100vh';
// نمایش Overlayها برای مخفی کردن بخشهای اضافی
overlayTop.style.display = 'block';
overlayBottom.style.display = 'block';
}, 500); // تاخیر کوچک برای نمایش نوار پیشرفت به 100%
}
function iframeError() {
clearInterval(interval);
loadingContainer.style.display = 'flex';
retryButton.style.display = 'block';
errorMessage.style.display = 'block';
}
function loadIframe() {
fetch(siteURL, { method: 'HEAD', mode: 'no-cors' })
.then(() => {
iframe.src = siteURL;
iframe.onload = iframeLoaded;
iframe.onerror = iframeError;
})
.catch(() => {
iframeError();
});
}
retryButton.addEventListener('click', function() {
progress = 0;
progressBar.style.width = '0%';
iframeLoadedFlag = false;
retryButton.style.display = 'none';
errorMessage.style.display = 'none';
loadingContainer.style.display = 'flex';
iframe.style.display = 'none';
loadIframe();
startProgress();
});
// مدیریت پنجرههای مدال
const imageModal = document.getElementById('myModal');
const closeBtn = document.getElementById('closeBtn');
closeBtn.addEventListener('click', function() {
imageModal.style.display = 'none';
});
window.addEventListener('click', function(event) {
if (event.target == imageModal) {
imageModal.style.display = 'none';
}
});
// تنظیم متغیر CSS برای تنظیم ارتفاع نمایشگر
function setVh() {
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
}
// فراخوانی تابع برای تنظیم متغیر vh
setVh();
// بهروزرسانی متغیر vh در تغییر اندازه صفحه
window.addEventListener('resize', setVh);
// اجرای بارگذاری iframe و آغاز لودینگ
loadIframe();
startProgress();
</script>
</body>
</html>
توضیحات تغییرات انجام شده:
-
حذف HTML مربوط به دکمه دانلود و دکمه اسکرول:
- دکمه دانلود پایین صفحه:
<!-- دکمه دانلود در پایین صفحه -->
<a href="#" class="download-button-bottom" id="downloadButtonBottom">دانلود</a>
- دکمه اسکرول:
<!-- دکمه اسکرول -->
<button class="scroll-handle" title="برای اسکرول بکشید" role="button" aria-label="دکمه اسکرول">👆</button>
-
حذف CSS مربوط به دکمه دانلود و دکمه اسکرول:
- تمام استایلهای مرتبط با
.download-button-bottom و .scroll-handle و انیمیشنهای مربوطه حذف شدهاند.
-
حذف کدهای JavaScript مرتبط با دکمه دانلود و دکمه اسکرول:
- تمامی متغیرها، توابع، و رویدادهای مربوط به
downloadButton و scrollHandle حذف شدهاند.
- عملکرد دکمه دانلود و اسکرول دیگر در کد وجود ندارد.
-
بهینهسازی CSS پس از حذف المانها:
- استایلهای اضافی که دیگر مورد نیاز نیستند، حذف شدهاند تا کد سبکتر و بهینهتر شود.
با اعمال این تغییرات، صفحه شما بدون دکمه دانلود و اسکرول خواهد بود و تمامی عملکردهای مرتبط با آنها از بین رفته است. اگر نیاز به تغییرات بیشتری دارید یا سوال دیگری دارید، خوشحال میشوم که کمک کنم!