<p> </p> <style> /* تنظیمات پایه برای body و html / html, body { margin: 0;…
- Usercode
- Assistant
/* متغیر CSS برای ارتفاع نمایشگر */
:root {
--vh: 100%;
}
/* حالت عادی */
.iframe-container.normal {
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
}
.iframe-container.normal iframe {
width: 100%;
height: 100%;
border: none;
display: none;
position: relative;
top: 0;
}
/* حالت تمام صفحه */
.iframe-container.fullscreen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: calc(var(--vh) * 100); /* استفاده از متغیر --vh */
overflow: hidden; /* مخفی کردن بخشهای اضافی */
z-index: 1; /* ترتیب نمایش */
}
.iframe-container.fullscreen iframe {
position: absolute;
top: -192.75px; /* پنهان کردن ۵.۱ سانتیمتر بالای صفحه (192.75px) */
left: 0;
width: 100%;
height: calc((var(--vh) * 100) + 192.75px + 38px); /* افزایش ارتفاع iframe به اندازه ۵.۱ سانتیمتر بالا و ۱ سانتیمتر پایین */
border: none;
display: block;
}
/* استایلهای مشترک */
.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;
}
.image-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.image-item {
margin: 10px;
text-align: center;
}
.image-item img {
width: 80px;
height: 80px;
object-fit: cover;
border-radius: 5px;
margin-bottom: 5px;
}
.image-item button {
background-color: #4CAF50;
color: white;
padding: 5px 10px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 12px;
}
.image-item button:hover {
background-color: #45a049;
}
@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); }
}
/* Overlay برای مخفی کردن بخشهای اضافی */
.overlay-top {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 192.75px; /* ارتفاع ۵.۱ سانتیمتر (192.75px) */
background-color: transparent; /* رنگ پسزمینه شفاف */
z-index: 900; /* زیر iframe-container */
pointer-events: none; /* اجازه دادن به اسکرول از طریق iframe */
display: none; /* مخفی در حالت عادی */
}
.overlay-bottom {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 38px; /* ارتفاع ۱ سانتیمتر (38px) */
background-color: transparent; /* رنگ پسزمینه شفاف */
z-index: 900; /* زیر iframe-container */
pointer-events: none; /* اجازه دادن به اسکرول از طریق iframe */
display: none; /* مخفی در حالت عادی */
}
</style>
let progress = 0;
const progressBar = document.getElementById('progressBar');
const retryButton = document.getElementById('retryButton');
const errorMessage = document.getElementById('errorMessage');
const loadingContainer = document.getElementById('loadingContainer');
let interval;
let iframeLoadedFlag = false;
function startProgress() {
loadingContainer.style.display = 'flex';
progressBar.style.width = '0%';
progress = 0;
interval = setInterval(() => {
if (progress < 100) {
progress += 10;
progressBar.style.width = progress + '%';
}
if (progress === 100) {
clearInterval(interval);
if (!iframeLoadedFlag) {
retryButton.style.display = 'block';
errorMessage.style.display = 'block';
}
}
}, 1000);
}
function iframeLoaded() {
iframeLoadedFlag = true;
clearInterval(interval);
loadingContainer.style.display = 'none';
const iframeContainer = document.querySelector('.iframe-container');
iframeContainer.classList.remove('normal');
iframeContainer.classList.add('fullscreen');
// نمایش overlayها
document.getElementById('overlayTop').style.display = 'block';
document.getElementById('overlayBottom').style.display = 'block';
// تنظیم iframe به نمایش
document.getElementById('myIframe').style.display = 'block';
}
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(() => {
const iframe = document.getElementById('myIframe');
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';
document.getElementById('myIframe').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';
}
});
// تنظیم ارتفاع نمایشگر برای متغیر --vh
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();
// جلوگیری از باز شدن لینکها در مرورگر (برای لینکهای خارج از iframe)
document.addEventListener('click', function(event) {
if (event.target.tagName === 'A') {
event.preventDefault();
// اینجا میتوانید کد مورد نظر برای مدیریت کلیک روی لینک را قرار دهید
}
});
</script>
برای اضافه کردن یک دکمه با نام "حامد" در انتهای صفحه موبایل که به صورت ثابت در پایین صفحه قرار گیرد و بدون تعامل با کدهای فعلی شما باشد، میتوانید مراحل زیر را دنبال کنید. این دکمه فقط نمایشی خواهد بود و در هر حالت از وضعیت صفحه (لودینگ یا تمام صفحه شدن) در پایین صفحه موبایل نمایش داده میشود.
اضافه کردن HTML برای دکمه:
دکمه را در انتهای بدنه (<body>) قرار دهید تا مطمئن شوید که همواره در پایین صفحه نمایش داده میشود.
اضافه کردن CSS برای استایلدهی و قرارگیری دکمه:
دکمه را با استفاده از position: fixed در پایین صفحه قرار دهید و استایلهای لازم برای ظاهر زیبا آن را به آن اضافه کنید.
تضمین تطابق با ریسپانسیو بودن صفحه: مطمئن شوید که دکمه در اندازهها و دستگاههای مختلف به درستی نمایش داده میشود.
<!DOCTYPE html>
<html lang="fa">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>صفحه موبایل با دکمه حامد</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%;
}
/* متعلقات دکمه حامد */
.hamed-button {
position: fixed;
bottom: 20px; /* فاصله از پایین */
left: 50%;
transform: translateX(-50%);
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: default; /* نشانگر غیرقابل کلیک */
z-index: 10003; /* بالا بودن از سایر عناصر */
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.hamed-button:active {
transform: translateX(-50%) scale(0.98);
}
/* حالت عادی */
.iframe-container.normal {
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
}
.iframe-container.normal iframe {
width: 100%;
height: 100%;
border: none;
display: none;
position: relative;
top: 0;
}
/* حالت تمام صفحه */
.iframe-container.fullscreen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: calc(var(--vh) * 100); /* استفاده از متغیر --vh */
overflow: hidden; /* مخفی کردن بخشهای اضافی */
z-index: 1; /* ترتیب نمایش */
}
.iframe-container.fullscreen iframe {
position: absolute;
top: -192.75px; /* پنهان کردن ۵.۱ سانتیمتر بالای صفحه (192.75px) */
left: 0;
width: 100%;
height: calc((var(--vh) * 100) + 192.75px + 38px); /* افزایش ارتفاع iframe به اندازه ۵.۱ سانتیمتر بالا و ۱ سانتیمتر پایین */
border: none;
display: block;
}
/* استایلهای مشترک */
.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;
}
.image-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.image-item {
margin: 10px;
text-align: center;
}
.image-item img {
width: 80px;
height: 80px;
object-fit: cover;
border-radius: 5px;
margin-bottom: 5px;
}
.image-item button {
background-color: #4CAF50;
color: white;
padding: 5px 10px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 12px;
}
.image-item button:hover {
background-color: #45a049;
}
@media (max-width: 768px) {
/* تنظیمات واکنشگرا برای عناصر دیگر در صورت نیاز */
.hamed-button {
font-size: 14px;
padding: 8px 16px;
}
.loading-message {
font-size: 16px;
}
.error-message {
font-size: 14px;
}
}
@keyframes pulse {
0% { transform: translateY(-50%) scale(1); }
50% { transform: translateY(-50%) scale(1.1); }
100% { transform: translateY(-50%) scale(1); }
}
/* Overlay برای مخفی کردن بخشهای اضافی */
.overlay-top {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 192.75px; /* ارتفاع ۵.۱ سانتیمتر (192.75px) */
background-color: transparent; /* رنگ پسزمینه شفاف */
z-index: 900; /* زیر iframe-container */
pointer-events: none; /* اجازه دادن به اسکرول از طریق iframe */
display: none; /* مخفی در حالت عادی */
}
.overlay-bottom {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 38px; /* ارتفاع ۱ سانتیمتر (38px) */
background-color: transparent; /* رنگ پسزمینه شفاف */
z-index: 900; /* زیر iframe-container */
pointer-events: none; /* اجازه دادن به اسکرول از طریق iframe */
display: none; /* مخفی در حالت عادی */
}
</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 normal">
<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 />
در صورت عدم بارگذاری، فیلترشکن خود را روشن کنید.<br />
اگر روشن بود و این فرایند ادامه داشت بعدا امتحان کنید.
</div>
<button id="retryButton">بارگذاری مجدد</button>
</div>
<!-- اضافه کردن ویژگی sandbox و allow -->
<iframe id="myIframe" sandbox="allow-scripts allow-same-origin allow-forms allow-modals" allow="clipboard-read; clipboard-write"></iframe>
</div>
<!-- Overlay برای مخفی کردن بخشهای اضافی -->
<div class="overlay-top" id="overlayTop"></div>
<div class="overlay-bottom" id="overlayBottom"></div>
<!-- دکمه حامد -->
<button class="hamed-button">حامد</button>
<script>
const siteURL = 'https://yuntian-deng-o1mini.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');
let interval;
let iframeLoadedFlag = false;
function startProgress() {
loadingContainer.style.display = 'flex';
progressBar.style.width = '0%';
progress = 0;
interval = setInterval(() => {
if (progress < 100) {
progress += 10;
progressBar.style.width = progress + '%';
}
if (progress === 100) {
clearInterval(interval);
if (!iframeLoadedFlag) {
retryButton.style.display = 'block';
errorMessage.style.display = 'block';
}
}
}, 1000);
}
function iframeLoaded() {
iframeLoadedFlag = true;
clearInterval(interval);
loadingContainer.style.display = 'none';
const iframeContainer = document.querySelector('.iframe-container');
iframeContainer.classList.remove('normal');
iframeContainer.classList.add('fullscreen');
// نمایش overlayها
document.getElementById('overlayTop').style.display = 'block';
document.getElementById('overlayBottom').style.display = 'block';
// تنظیم iframe به نمایش
document.getElementById('myIframe').style.display = 'block';
}
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(() => {
const iframe = document.getElementById('myIframe');
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';
document.getElementById('myIframe').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';
}
});
// تنظیم ارتفاع نمایشگر برای متغیر --vh
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();
// جلوگیری از باز شدن لینکها در مرورگر (برای لینکهای خارج از iframe)
document.addEventListener('click', function(event) {
if (event.target.tagName === 'A') {
event.preventDefault();
// اینجا میتوانید کد مورد نظر برای مدیریت کلیک روی لینک را قرار دهید
}
});
</script>
</body>
</html>
HTML مربوط به دکمه حامد:
<!-- دکمه حامد -->
<button class="hamed-button">حامد</button>
این دکمه را در انتهای بدنه قرار دادهایم تا در هر حالت از وضعیت صفحه به درستی نمایش داده شود.
CSS مربوط به دکمه حامد:
.hamed-button {
position: fixed;
bottom: 20px; /* فاصله از پایین */
left: 50%;
transform: translateX(-50%);
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: default; /* نشانگر غیرقابل کلیک */
z-index: 10003; /* بالا بودن از سایر عناصر */
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.hamed-button:active {
transform: translateX(-50%) scale(0.98);
}
@media (max-width: 768px) {
.hamed-button {
font-size: 14px;
padding: 8px 16px;
}
}
fixed): دکمه به صورت ثابت در پایین صفحه قرار میگیرد.left: 50% و transform: translateX(-50%) دکمه به مرکز افقی صفحه منتقل میشود.Z-Index:
دکمه با استفاده از z-index: 10003 بالاتر از سایر عناصر مانند loading, modal, و iframe قرار گرفته تا همیشه قابل مشاهده باشد.
حالت فعال دکمه:
با :active، هنگام لمس دکمه در گوشیهای موبایل کمی کوچکتر میشود تا بازخورد بصری ایجاد شود.
عدم قابلیت کلیک:
با استفاده از cursor: default; نشانگر موس تغییر نمیکند تا کاربر فکر نکند دکمه قابل کلیک است. همچنین، چون دکمه هیچ عملکردی ندارد، نیازی به تعاملی با کاربر نیست.
با اعمال این تغییرات، دکمه "حامد" به صورت ثابت در پایین صفحه موبایل نمایش داده میشود و با تغییر وضعیت صفحه (لودینگ یا نمایش iframe) نیز در جای خود باقی میماند. این دکمه فقط برای نمایش است و هیچ عملکردی ندارد و به صفحه HTML دیگری لینک نمیدهد.
Not yet included in a published release.