Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -265,7 +265,7 @@ async (image) => {
|
|
| 265 |
}
|
| 266 |
"""
|
| 267 |
|
| 268 |
-
# --- جاوااسکریپت سراسری (
|
| 269 |
js_global_content = """
|
| 270 |
<script>
|
| 271 |
document.addEventListener('DOMContentLoaded', () => {
|
|
@@ -284,11 +284,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 284 |
|
| 285 |
// 2. RETRY FUNCTION
|
| 286 |
window.retryGeneration = function() {
|
| 287 |
-
// Close modal
|
| 288 |
const modal = document.getElementById('custom-quota-modal');
|
| 289 |
if (modal) modal.remove();
|
| 290 |
|
| 291 |
-
// Click Run button
|
| 292 |
const runBtn = document.getElementById('run-btn');
|
| 293 |
if(runBtn) runBtn.click();
|
| 294 |
};
|
|
@@ -301,12 +299,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 301 |
|
| 302 |
// 3. SHOW MODAL FUNCTION
|
| 303 |
const showQuotaModal = () => {
|
| 304 |
-
// Prevent duplicate modals
|
| 305 |
if (document.getElementById('custom-quota-modal')) return;
|
| 306 |
|
| 307 |
const modalHtml = `
|
| 308 |
<div id="custom-quota-modal" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); z-index: 99999; display: flex; align-items: center; justify-content: center; font-family: 'Vazirmatn', sans-serif;">
|
| 309 |
-
<div class="ip-reset-guide-container" style="max-width: 450px; width: 90%; background: white; border-radius: 20px; padding: 25px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); animation: slideInUp 0.4s ease;">
|
| 310 |
<div class="guide-header">
|
| 311 |
<svg class="guide-header-icon" viewbox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
| 312 |
<defs><lineargradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color: #667eea; stop-opacity: 1;"></stop><stop offset="100%" style="stop-color: #764ba2; stop-opacity: 1;"></stop></lineargradient></defs>
|
|
@@ -366,29 +363,24 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 366 |
|
| 367 |
// 4. SCANNER
|
| 368 |
setInterval(() => {
|
| 369 |
-
// Find ALL possible error containers, including small toasts and status bars
|
| 370 |
const potentialErrors = document.querySelectorAll('.toast-body, .error, .toast-wrap, .eta-bar, div[class*="error"]');
|
| 371 |
|
| 372 |
potentialErrors.forEach(el => {
|
| 373 |
const text = el.innerText || "";
|
| 374 |
-
// Trigger words
|
| 375 |
if (text.toLowerCase().includes('quota') || text.toLowerCase().includes('exceeded')) {
|
| 376 |
|
| 377 |
-
// Show our custom modal if not already open
|
| 378 |
showQuotaModal();
|
| 379 |
|
| 380 |
-
//
|
| 381 |
-
// We use display:none or remove() to ensure it's gone
|
| 382 |
el.style.display = 'none';
|
| 383 |
el.style.opacity = '0';
|
| 384 |
-
el.innerText = '';
|
| 385 |
|
| 386 |
-
// Also try to find parent wrapper and hide it
|
| 387 |
const parentWrap = el.closest('.toast-wrap');
|
| 388 |
if(parentWrap) parentWrap.style.display = 'none';
|
| 389 |
}
|
| 390 |
});
|
| 391 |
-
}, 100);
|
| 392 |
});
|
| 393 |
</script>
|
| 394 |
"""
|
|
@@ -436,6 +428,26 @@ css_code = """
|
|
| 436 |
to { opacity: 1; transform: translateY(0); }
|
| 437 |
}
|
| 438 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
.guide-header { display: flex; align-items: center; margin-bottom: 20px; }
|
| 440 |
.guide-header-icon { width: 50px; height: 50px; margin-left: 15px; animation: float 3s ease-in-out infinite; flex-shrink: 0; }
|
| 441 |
.guide-header h2 { font-size: 1.3rem; color: var(--guide-text-title); font-weight: 700; margin: 0; }
|
|
|
|
| 265 |
}
|
| 266 |
"""
|
| 267 |
|
| 268 |
+
# --- جاوااسکریپت سراسری (نسخه نهایی راستچین) ---
|
| 269 |
js_global_content = """
|
| 270 |
<script>
|
| 271 |
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
| 284 |
|
| 285 |
// 2. RETRY FUNCTION
|
| 286 |
window.retryGeneration = function() {
|
|
|
|
| 287 |
const modal = document.getElementById('custom-quota-modal');
|
| 288 |
if (modal) modal.remove();
|
| 289 |
|
|
|
|
| 290 |
const runBtn = document.getElementById('run-btn');
|
| 291 |
if(runBtn) runBtn.click();
|
| 292 |
};
|
|
|
|
| 299 |
|
| 300 |
// 3. SHOW MODAL FUNCTION
|
| 301 |
const showQuotaModal = () => {
|
|
|
|
| 302 |
if (document.getElementById('custom-quota-modal')) return;
|
| 303 |
|
| 304 |
const modalHtml = `
|
| 305 |
<div id="custom-quota-modal" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); z-index: 99999; display: flex; align-items: center; justify-content: center; font-family: 'Vazirmatn', sans-serif;">
|
| 306 |
+
<div class="ip-reset-guide-container" style="direction: rtl; text-align: right; max-width: 450px; width: 90%; background: white; border-radius: 20px; padding: 25px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); animation: slideInUp 0.4s ease;">
|
| 307 |
<div class="guide-header">
|
| 308 |
<svg class="guide-header-icon" viewbox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
| 309 |
<defs><lineargradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color: #667eea; stop-opacity: 1;"></stop><stop offset="100%" style="stop-color: #764ba2; stop-opacity: 1;"></stop></lineargradient></defs>
|
|
|
|
| 363 |
|
| 364 |
// 4. SCANNER
|
| 365 |
setInterval(() => {
|
|
|
|
| 366 |
const potentialErrors = document.querySelectorAll('.toast-body, .error, .toast-wrap, .eta-bar, div[class*="error"]');
|
| 367 |
|
| 368 |
potentialErrors.forEach(el => {
|
| 369 |
const text = el.innerText || "";
|
|
|
|
| 370 |
if (text.toLowerCase().includes('quota') || text.toLowerCase().includes('exceeded')) {
|
| 371 |
|
|
|
|
| 372 |
showQuotaModal();
|
| 373 |
|
| 374 |
+
// Immediately hide the Gradio error
|
|
|
|
| 375 |
el.style.display = 'none';
|
| 376 |
el.style.opacity = '0';
|
| 377 |
+
el.innerText = '';
|
| 378 |
|
|
|
|
| 379 |
const parentWrap = el.closest('.toast-wrap');
|
| 380 |
if(parentWrap) parentWrap.style.display = 'none';
|
| 381 |
}
|
| 382 |
});
|
| 383 |
+
}, 100);
|
| 384 |
});
|
| 385 |
</script>
|
| 386 |
"""
|
|
|
|
| 428 |
to { opacity: 1; transform: translateY(0); }
|
| 429 |
}
|
| 430 |
|
| 431 |
+
.ip-reset-guide-container {
|
| 432 |
+
text-align: right;
|
| 433 |
+
direction: rtl; /* Added this to CSS class as well */
|
| 434 |
+
background: var(--guide-bg);
|
| 435 |
+
backdrop-filter: blur(10px);
|
| 436 |
+
padding: 25px;
|
| 437 |
+
border-radius: var(--radius-lg-guide);
|
| 438 |
+
box-shadow: var(--shadow-xl);
|
| 439 |
+
border: 1px solid var(--guide-border);
|
| 440 |
+
animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
|
| 441 |
+
width: 100%;
|
| 442 |
+
max-width: 450px;
|
| 443 |
+
position: relative;
|
| 444 |
+
overflow: hidden;
|
| 445 |
+
box-sizing: border-box;
|
| 446 |
+
font-family: 'Vazirmatn', sans-serif !important;
|
| 447 |
+
}
|
| 448 |
+
.ip-reset-guide-container::before {
|
| 449 |
+
content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px; background: var(--primary-gradient-guide);
|
| 450 |
+
}
|
| 451 |
.guide-header { display: flex; align-items: center; margin-bottom: 20px; }
|
| 452 |
.guide-header-icon { width: 50px; height: 50px; margin-left: 15px; animation: float 3s ease-in-out infinite; flex-shrink: 0; }
|
| 453 |
.guide-header h2 { font-size: 1.3rem; color: var(--guide-text-title); font-weight: 700; margin: 0; }
|