Spaces:
Paused
Paused
Update templates/index.html
Browse files- templates/index.html +26 -5
templates/index.html
CHANGED
|
@@ -658,6 +658,7 @@
|
|
| 658 |
const PREMIUM_PAGE_ID = '1149636'; // آیدی صفحه ویژه خرید
|
| 659 |
const DAILY_MSG_LIMIT = 20; // محدودیت پیام
|
| 660 |
const DAILY_IMG_LIMIT = 2; // محدودیت عکس
|
|
|
|
| 661 |
|
| 662 |
function isUserPaid(userObject) {
|
| 663 |
return userObject?.isLogin && userObject.accessible_pages?.some(p => p == PREMIUM_PAGE_ID);
|
|
@@ -693,9 +694,12 @@
|
|
| 693 |
let usage = JSON.parse(localStorage.getItem('alpha_chat_usage') || '{}');
|
| 694 |
if (usage.date !== today) {
|
| 695 |
// ریست کردن برای روز جدید
|
| 696 |
-
usage = { date: today, messages: 0, images: 0 };
|
| 697 |
localStorage.setItem('alpha_chat_usage', JSON.stringify(usage));
|
| 698 |
}
|
|
|
|
|
|
|
|
|
|
| 699 |
return usage;
|
| 700 |
}
|
| 701 |
|
|
@@ -715,10 +719,19 @@
|
|
| 715 |
}
|
| 716 |
}
|
| 717 |
|
| 718 |
-
function checkCanSend(hasImage) {
|
| 719 |
if (userSubscriptionStatus === 'paid') return true;
|
| 720 |
const usage = getUsage();
|
| 721 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 722 |
if (usage.messages >= DAILY_MSG_LIMIT) {
|
| 723 |
document.getElementById('premiumModalDesc').innerText = "محدودیت ۲۰ پیام روزانه شما به پایان رسیده است. برای چت نامحدود حساب خود را ارتقا دهید.";
|
| 724 |
openPremiumModal();
|
|
@@ -732,11 +745,15 @@
|
|
| 732 |
return true;
|
| 733 |
}
|
| 734 |
|
| 735 |
-
function incrementUsage(hasImage) {
|
| 736 |
if (userSubscriptionStatus === 'paid') return;
|
| 737 |
let usage = getUsage();
|
| 738 |
-
|
| 739 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 740 |
localStorage.setItem('alpha_chat_usage', JSON.stringify(usage));
|
| 741 |
}
|
| 742 |
// --- پایان بخش محدودیتها ---
|
|
@@ -1916,6 +1933,10 @@
|
|
| 1916 |
|
| 1917 |
// بررسی اینکه آیا کاربر در حالت ساخت فایل (مقاله) قرار دارد؟
|
| 1918 |
if (isFileCreationMode && text) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1919 |
isFileCreationMode = false; // خروج از حالت فایل پس از ارسال
|
| 1920 |
textInput.value = '';
|
| 1921 |
textInput.style.height = 'auto'; // ریست کردن ارتفاع کادر
|
|
|
|
| 658 |
const PREMIUM_PAGE_ID = '1149636'; // آیدی صفحه ویژه خرید
|
| 659 |
const DAILY_MSG_LIMIT = 20; // محدودیت پیام
|
| 660 |
const DAILY_IMG_LIMIT = 2; // محدودیت عکس
|
| 661 |
+
const DAILY_FILE_LIMIT = 1; // محدودیت ساخت فایل
|
| 662 |
|
| 663 |
function isUserPaid(userObject) {
|
| 664 |
return userObject?.isLogin && userObject.accessible_pages?.some(p => p == PREMIUM_PAGE_ID);
|
|
|
|
| 694 |
let usage = JSON.parse(localStorage.getItem('alpha_chat_usage') || '{}');
|
| 695 |
if (usage.date !== today) {
|
| 696 |
// ریست کردن برای روز جدید
|
| 697 |
+
usage = { date: today, messages: 0, images: 0, files: 0 };
|
| 698 |
localStorage.setItem('alpha_chat_usage', JSON.stringify(usage));
|
| 699 |
}
|
| 700 |
+
if (usage.files === undefined) {
|
| 701 |
+
usage.files = 0;
|
| 702 |
+
}
|
| 703 |
return usage;
|
| 704 |
}
|
| 705 |
|
|
|
|
| 719 |
}
|
| 720 |
}
|
| 721 |
|
| 722 |
+
function checkCanSend(hasImage, isFile = false) {
|
| 723 |
if (userSubscriptionStatus === 'paid') return true;
|
| 724 |
const usage = getUsage();
|
| 725 |
|
| 726 |
+
if (isFile) {
|
| 727 |
+
if (usage.files >= DAILY_FILE_LIMIT) {
|
| 728 |
+
document.getElementById('premiumModalDesc').innerText = "محدودیت ساخت ۱ فایل در روز شما به پایان رسیده است. برای استفاده نامحدود حساب خود را ارتقا دهید.";
|
| 729 |
+
openPremiumModal();
|
| 730 |
+
return false;
|
| 731 |
+
}
|
| 732 |
+
return true;
|
| 733 |
+
}
|
| 734 |
+
|
| 735 |
if (usage.messages >= DAILY_MSG_LIMIT) {
|
| 736 |
document.getElementById('premiumModalDesc').innerText = "محدودیت ۲۰ پیام روزانه شما به پایان رسیده است. برای چت نامحدود حساب خود را ارتقا دهید.";
|
| 737 |
openPremiumModal();
|
|
|
|
| 745 |
return true;
|
| 746 |
}
|
| 747 |
|
| 748 |
+
function incrementUsage(hasImage, isFile = false) {
|
| 749 |
if (userSubscriptionStatus === 'paid') return;
|
| 750 |
let usage = getUsage();
|
| 751 |
+
if (isFile) {
|
| 752 |
+
usage.files = (usage.files || 0) + 1;
|
| 753 |
+
} else {
|
| 754 |
+
usage.messages += 1;
|
| 755 |
+
if (hasImage) usage.images += 1;
|
| 756 |
+
}
|
| 757 |
localStorage.setItem('alpha_chat_usage', JSON.stringify(usage));
|
| 758 |
}
|
| 759 |
// --- پایان بخش محدودیتها ---
|
|
|
|
| 1933 |
|
| 1934 |
// بررسی اینکه آیا کاربر در حالت ساخت فایل (مقاله) قرار دارد؟
|
| 1935 |
if (isFileCreationMode && text) {
|
| 1936 |
+
if (!checkCanSend(false, true)) {
|
| 1937 |
+
return;
|
| 1938 |
+
}
|
| 1939 |
+
incrementUsage(false, true);
|
| 1940 |
isFileCreationMode = false; // خروج از حالت فایل پس از ارسال
|
| 1941 |
textInput.value = '';
|
| 1942 |
textInput.style.height = 'auto'; // ریست کردن ارتفاع کادر
|