Update templates/index.html
Browse files- templates/index.html +21 -22
templates/index.html
CHANGED
|
@@ -448,7 +448,6 @@
|
|
| 448 |
|
| 449 |
function showCriticalError(message, isGpuQuotaError = false) {
|
| 450 |
const lowerCaseMessage = (message || "").toLowerCase();
|
| 451 |
-
// اگر خطای مشخص GPU quota بود یا هر خطای دیگری که شامل کلمات کلیدی GPU باشد
|
| 452 |
if (isGpuQuotaError || lowerCaseMessage.includes("gpu") || lowerCaseMessage.includes("quota") || lowerCaseMessage.includes("capacity")) {
|
| 453 |
const detailedGpuErrorHtml = `<div class="gpu-error-message-container"><h2><span class="icon">💡</span> راهنمای رفع محدودیت ویدیو</h2><div class="error-content"><strong class="error-message-title">ارور محدودیت استفاده از GPU (کارت گرافیک)</strong><p>این خطا به دلیل محدودیتهای موقتی در سرویسدهنده ایجاد میشود. خبر خوب این است که این محدودیتها معمولاً با یک ترفند ساده قابل رفع هستند.</p><p><strong>برای رفع محدودیت، مراحل زیر را دقیقاً انجام دهید:</strong></p><ul><li>اگر از اینترنت سیمکارت استفاده میکنید، فیلترشکن خود را حتما خاموش کنید.</li><li><strong>به مدت ۱۰ تا ۱۵ ثانیه، گوشی خود را در حالت هواپیما قرار دهید و سپس آن را غیرفعال کنید.</strong> این کار IP شما را تغییر داده و محدودیت را برطرف میکند.</li><li>اگر از وای فای استفاده میکنید، مودم خود را یک بار خاموش و روشن کنید. (توصیه میشود برای استفاده نامحدود از اینترنت سیم کارت استفاده کنید).</li></ul><p>خلاصه: هر بار با این خطا مواجه شدید، از اینترنت سیمکارت بدون فیلترشکن استفاده کرده و یک یا دو بار حالت هواپیما را روشن و خاموش کنید. سپس دکمه "تلاش مجدد" را بزنید. با این روش میتوانید به صورت نامحدود ویدیو بسازید. ☘️</p></div><div class="gpu-error-actions"><button class="action-button back-button" id="gpuErrorGoBackBtn">بازگشت</button><button class="action-button retry-button" id="gpuErrorRetryBtn">تلاش مجدد</button></div></div>`;
|
| 454 |
criticalErrorSection.innerHTML = detailedGpuErrorHtml;
|
|
@@ -506,7 +505,7 @@
|
|
| 506 |
|
| 507 |
function initializeForm() {
|
| 508 |
if (videoGenerationJob) {
|
| 509 |
-
videoGenerationJob.cancel();
|
| 510 |
videoGenerationJob = null;
|
| 511 |
}
|
| 512 |
hideCriticalError();
|
|
@@ -669,54 +668,54 @@
|
|
| 669 |
0, // seed (0 = random)
|
| 670 |
true // randomize_seed
|
| 671 |
]);
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
|
|
|
| 677 |
setAiLoaderText(`در صف قرار گرفتید... (نفر ${status.queue_position} از ${status.queue_size})`);
|
| 678 |
-
addStatusMessage(`در صف انتظار... زمان تخمینی: ${Math.round(status.
|
| 679 |
setProgressBar(2);
|
| 680 |
break;
|
| 681 |
-
case "
|
| 682 |
if (status.progress_data && status.progress_data.length > 0) {
|
| 683 |
const progressItem = status.progress_data[0];
|
| 684 |
let percentage = 0;
|
| 685 |
let progressText = "در حال پردازش...";
|
| 686 |
|
| 687 |
if (progressItem.desc === "ZeroGPU init") {
|
| 688 |
-
//
|
| 689 |
percentage = (progressItem.index / progressItem.length) * 20;
|
| 690 |
progressText = `آمادهسازی: ${Math.round(percentage)}%`;
|
| 691 |
} else if (progressItem.unit === "steps" && progressItem.desc === null) {
|
| 692 |
-
//
|
| 693 |
percentage = 20 + (progressItem.index / progressItem.length) * 80;
|
| 694 |
progressText = `ساخت ویدیو: ${Math.round(percentage)}%`;
|
| 695 |
}
|
| 696 |
setProgressBar(percentage);
|
| 697 |
setAiLoaderText(progressText);
|
| 698 |
-
} else {
|
| 699 |
-
setAiLoaderText("در حال پردازش ویدیو...");
|
| 700 |
}
|
| 701 |
break;
|
| 702 |
-
case "
|
|
|
|
|
|
|
|
|
|
|
|
|
| 703 |
if (status.success) {
|
| 704 |
setProgressBar(100);
|
| 705 |
setAiLoaderText("پردازش کامل شد!");
|
| 706 |
-
handleSuccessfulVideoGeneration(status.output);
|
| 707 |
} else {
|
| 708 |
const errorMessage = status.output?.error || "یک خطای نامشخص رخ داد.";
|
| 709 |
const isGpuQuotaError = /exceeded your gpu quota/i.test(errorMessage);
|
| 710 |
showCriticalError(errorMessage, isGpuQuotaError);
|
| 711 |
}
|
| 712 |
-
videoGenerationJob = null; //
|
| 713 |
-
|
| 714 |
-
case "error":
|
| 715 |
-
showCriticalError(status.message || "ارتباط با سرور برقرار نشد.");
|
| 716 |
-
videoGenerationJob = null;
|
| 717 |
-
break;
|
| 718 |
}
|
| 719 |
-
}
|
|
|
|
| 720 |
|
| 721 |
} catch (errorCaught) {
|
| 722 |
showCriticalError(`خطای اولیه: ${errorCaught.message}`);
|
|
|
|
| 448 |
|
| 449 |
function showCriticalError(message, isGpuQuotaError = false) {
|
| 450 |
const lowerCaseMessage = (message || "").toLowerCase();
|
|
|
|
| 451 |
if (isGpuQuotaError || lowerCaseMessage.includes("gpu") || lowerCaseMessage.includes("quota") || lowerCaseMessage.includes("capacity")) {
|
| 452 |
const detailedGpuErrorHtml = `<div class="gpu-error-message-container"><h2><span class="icon">💡</span> راهنمای رفع محدودیت ویدیو</h2><div class="error-content"><strong class="error-message-title">ارور محدودیت استفاده از GPU (کارت گرافیک)</strong><p>این خطا به دلیل محدودیتهای موقتی در سرویسدهنده ایجاد میشود. خبر خوب این است که این محدودیتها معمولاً با یک ترفند ساده قابل رفع هستند.</p><p><strong>برای رفع محدودیت، مراحل زیر را دقیقاً انجام دهید:</strong></p><ul><li>اگر از اینترنت سیمکارت استفاده میکنید، فیلترشکن خود را حتما خاموش کنید.</li><li><strong>به مدت ۱۰ تا ۱۵ ثانیه، گوشی خود را در حالت هواپیما قرار دهید و سپس آن را غیرفعال کنید.</strong> این کار IP شما را تغییر داده و محدودیت را برطرف میکند.</li><li>اگر از وای فای استفاده میکنید، مودم خود را یک بار خاموش و روشن کنید. (توصیه میشود برای استفاده نامحدود از اینترنت سیم کارت استفاده کنید).</li></ul><p>خلاصه: هر بار با این خطا مواجه شدید، از اینترنت سیمکارت بدون فیلترشکن استفاده کرده و یک یا دو بار حالت هواپیما را روشن و خاموش کنید. سپس دکمه "تلاش مجدد" را بزنید. با این روش میتوانید به صورت نامحدود ویدیو بسازید. ☘️</p></div><div class="gpu-error-actions"><button class="action-button back-button" id="gpuErrorGoBackBtn">بازگشت</button><button class="action-button retry-button" id="gpuErrorRetryBtn">تلاش مجدد</button></div></div>`;
|
| 453 |
criticalErrorSection.innerHTML = detailedGpuErrorHtml;
|
|
|
|
| 505 |
|
| 506 |
function initializeForm() {
|
| 507 |
if (videoGenerationJob) {
|
| 508 |
+
videoGenerationJob.cancel();
|
| 509 |
videoGenerationJob = null;
|
| 510 |
}
|
| 511 |
hideCriticalError();
|
|
|
|
| 668 |
0, // seed (0 = random)
|
| 669 |
true // randomize_seed
|
| 670 |
]);
|
| 671 |
+
|
| 672 |
+
// --- START: NEW CORRECT WAY TO HANDLE STATUS ---
|
| 673 |
+
for await (const status of videoGenerationJob) {
|
| 674 |
+
console.log(status); // For debugging
|
| 675 |
+
switch (status.type) {
|
| 676 |
+
case "estimation":
|
| 677 |
setAiLoaderText(`در صف قرار گرفتید... (نفر ${status.queue_position} از ${status.queue_size})`);
|
| 678 |
+
addStatusMessage(`در صف انتظار... زمان تخمینی: ${Math.round(status.rank_eta)} ثانیه`);
|
| 679 |
setProgressBar(2);
|
| 680 |
break;
|
| 681 |
+
case "progress":
|
| 682 |
if (status.progress_data && status.progress_data.length > 0) {
|
| 683 |
const progressItem = status.progress_data[0];
|
| 684 |
let percentage = 0;
|
| 685 |
let progressText = "در حال پردازش...";
|
| 686 |
|
| 687 |
if (progressItem.desc === "ZeroGPU init") {
|
| 688 |
+
// Phase 1: Preparation (estimated 20% of total process)
|
| 689 |
percentage = (progressItem.index / progressItem.length) * 20;
|
| 690 |
progressText = `آمادهسازی: ${Math.round(percentage)}%`;
|
| 691 |
} else if (progressItem.unit === "steps" && progressItem.desc === null) {
|
| 692 |
+
// Phase 2: Video Generation (estimated 80% of total process)
|
| 693 |
percentage = 20 + (progressItem.index / progressItem.length) * 80;
|
| 694 |
progressText = `ساخت ویدیو: ${Math.round(percentage)}%`;
|
| 695 |
}
|
| 696 |
setProgressBar(percentage);
|
| 697 |
setAiLoaderText(progressText);
|
|
|
|
|
|
|
| 698 |
}
|
| 699 |
break;
|
| 700 |
+
case "process_starts":
|
| 701 |
+
addStatusMessage('پردازش شروع شد...');
|
| 702 |
+
setAiLoaderText("در حال پردازش ویدیو...");
|
| 703 |
+
break;
|
| 704 |
+
case "process_completed":
|
| 705 |
if (status.success) {
|
| 706 |
setProgressBar(100);
|
| 707 |
setAiLoaderText("پردازش کامل شد!");
|
| 708 |
+
await handleSuccessfulVideoGeneration(status.output);
|
| 709 |
} else {
|
| 710 |
const errorMessage = status.output?.error || "یک خطای نامشخص رخ داد.";
|
| 711 |
const isGpuQuotaError = /exceeded your gpu quota/i.test(errorMessage);
|
| 712 |
showCriticalError(errorMessage, isGpuQuotaError);
|
| 713 |
}
|
| 714 |
+
videoGenerationJob = null; // Clear the job after completion
|
| 715 |
+
return; // Exit the loop
|
|
|
|
|
|
|
|
|
|
|
|
|
| 716 |
}
|
| 717 |
+
}
|
| 718 |
+
// --- END: NEW CORRECT WAY TO HANDLE STATUS ---
|
| 719 |
|
| 720 |
} catch (errorCaught) {
|
| 721 |
showCriticalError(`خطای اولیه: ${errorCaught.message}`);
|