Spaces:
Paused
Paused
Update templates/index.html
Browse files- templates/index.html +28 -43
templates/index.html
CHANGED
|
@@ -384,7 +384,7 @@
|
|
| 384 |
|
| 385 |
.input-wrapper {
|
| 386 |
display: flex; align-items: flex-end; background-color: #ffffff;
|
| 387 |
-
border: 1.5px solid #e8e8e8; border-radius:
|
| 388 |
box-shadow: 0 8px 25px rgba(0,0,0,0.06); transition: border-color 0.3s ease, background 0.3s;
|
| 389 |
}
|
| 390 |
.input-wrapper:focus-within { border-color: #c0caff; }
|
|
@@ -401,7 +401,7 @@
|
|
| 401 |
font-size: 15px; padding: 10px 5px; font-family: inherit; color: #333; transition: color 0.3s;
|
| 402 |
resize: none;
|
| 403 |
height: 24px;
|
| 404 |
-
max-height: 140px; /* حدود ۶ ا
|
| 405 |
line-height: 1.5;
|
| 406 |
overflow-y: auto;
|
| 407 |
}
|
|
@@ -684,16 +684,6 @@
|
|
| 684 |
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
| 685 |
}
|
| 686 |
|
| 687 |
-
// تنظیم خودکار ارتفاع کادر ورودی متن
|
| 688 |
-
function adjustTextareaHeight() {
|
| 689 |
-
const textarea = document.getElementById('textInput');
|
| 690 |
-
textarea.style.height = '24px'; // تنظیم به ارتفاع اولیه پیش از محاسبه
|
| 691 |
-
const scrollHeight = textarea.scrollHeight;
|
| 692 |
-
if (scrollHeight > 24) {
|
| 693 |
-
textarea.style.height = scrollHeight + 'px';
|
| 694 |
-
}
|
| 695 |
-
}
|
| 696 |
-
|
| 697 |
function getUsage() {
|
| 698 |
const today = getTodayString();
|
| 699 |
let usage = JSON.parse(localStorage.getItem('alpha_chat_usage') || '{}');
|
|
@@ -818,7 +808,7 @@
|
|
| 818 |
let html = txt.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
| 819 |
|
| 820 |
// تبدیل متون ضخیم
|
| 821 |
-
html = html.replace(/\*\*(.*?)\*\
|
| 822 |
|
| 823 |
// تبدیل هدرها برای زیبایی و مرتب شدن
|
| 824 |
html = html.replace(/^### (.*?)$/gm, '<h3 style="font-size: 15px; margin: 12px 0 6px 0; color: #5a67d8; font-weight: bold;">$1</h3>');
|
|
@@ -918,12 +908,12 @@
|
|
| 918 |
}
|
| 919 |
|
| 920 |
function fallbackCopy() {
|
| 921 |
-
const
|
| 922 |
-
|
| 923 |
-
document.body.appendChild(
|
| 924 |
-
|
| 925 |
try { document.execCommand('copy'); showSuccess(); } catch(e) {}
|
| 926 |
-
|
| 927 |
}
|
| 928 |
}
|
| 929 |
/* ---------------------------------------------------- */
|
|
@@ -1026,21 +1016,21 @@
|
|
| 1026 |
fallbackCopy();
|
| 1027 |
}
|
| 1028 |
function fallbackCopy() {
|
| 1029 |
-
const
|
| 1030 |
-
|
| 1031 |
-
|
| 1032 |
-
|
| 1033 |
-
|
| 1034 |
-
document.body.appendChild(
|
| 1035 |
-
|
| 1036 |
-
|
| 1037 |
try {
|
| 1038 |
document.execCommand('copy');
|
| 1039 |
showCopiedSuccess();
|
| 1040 |
} catch (err) {
|
| 1041 |
console.error('Copy failed', err);
|
| 1042 |
}
|
| 1043 |
-
|
| 1044 |
}
|
| 1045 |
}
|
| 1046 |
|
|
@@ -1442,9 +1432,6 @@
|
|
| 1442 |
const sendBtn = document.getElementById('sendBtn');
|
| 1443 |
const statusBar = document.getElementById('statusBar');
|
| 1444 |
|
| 1445 |
-
// ثبت رخداد ورودی برای تنظیم خودکار ارتفاع
|
| 1446 |
-
textInput.addEventListener('input', adjustTextareaHeight);
|
| 1447 |
-
|
| 1448 |
function toggleSidebar() {
|
| 1449 |
document.getElementById('sidebar').classList.toggle('open');
|
| 1450 |
document.getElementById('overlay').classList.toggle('visible');
|
|
@@ -1632,11 +1619,11 @@
|
|
| 1632 |
|
| 1633 |
/* --- منطق جدید برای ساخت فایل (مقاله) بصورت استریم مشابه عکس --- */
|
| 1634 |
async function proceedToCreateFile(topic) {
|
| 1635 |
-
|
| 1636 |
-
|
| 1637 |
-
|
| 1638 |
-
|
| 1639 |
-
|
| 1640 |
sendBtn.innerHTML = `<svg viewBox="0 0 24 24"><rect x="7" y="7" width="10" height="10" fill="white" stroke="none" rx="2" ry="2"/></svg>`;
|
| 1641 |
sendBtn.style.backgroundColor = "#5a67d8";
|
| 1642 |
statusBar.textContent = "در حال ایجاد مقاله...";
|
|
@@ -1948,7 +1935,7 @@
|
|
| 1948 |
if (isFileCreationMode && text) {
|
| 1949 |
isFileCreationMode = false; // خروج از حالت فایل پس از ارسال
|
| 1950 |
textInput.value = '';
|
| 1951 |
-
textInput.style.height = '
|
| 1952 |
proceedToCreateFile(text);
|
| 1953 |
return;
|
| 1954 |
}
|
|
@@ -1965,7 +1952,7 @@
|
|
| 1965 |
incrementUsage(hasImage);
|
| 1966 |
|
| 1967 |
textInput.value = '';
|
| 1968 |
-
textInput.style.height = '
|
| 1969 |
clearSelectedImage();
|
| 1970 |
|
| 1971 |
if (!currentSessionId) {
|
|
@@ -1979,12 +1966,10 @@
|
|
| 1979 |
}
|
| 1980 |
});
|
| 1981 |
|
| 1982 |
-
//
|
| 1983 |
-
textInput.addEventListener('
|
| 1984 |
-
|
| 1985 |
-
|
| 1986 |
-
sendBtn.click();
|
| 1987 |
-
}
|
| 1988 |
});
|
| 1989 |
|
| 1990 |
window.onload = async () => {
|
|
|
|
| 384 |
|
| 385 |
.input-wrapper {
|
| 386 |
display: flex; align-items: flex-end; background-color: #ffffff;
|
| 387 |
+
border: 1.5px solid #e8e8e8; border-radius: 22px; padding: 6px 6px 6px 16px;
|
| 388 |
box-shadow: 0 8px 25px rgba(0,0,0,0.06); transition: border-color 0.3s ease, background 0.3s;
|
| 389 |
}
|
| 390 |
.input-wrapper:focus-within { border-color: #c0caff; }
|
|
|
|
| 401 |
font-size: 15px; padding: 10px 5px; font-family: inherit; color: #333; transition: color 0.3s;
|
| 402 |
resize: none;
|
| 403 |
height: 24px;
|
| 404 |
+
max-height: 140px; /* محدوده ارتفاعی برابر با حدود ۶ تا ۷ خط */
|
| 405 |
line-height: 1.5;
|
| 406 |
overflow-y: auto;
|
| 407 |
}
|
|
|
|
| 684 |
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
| 685 |
}
|
| 686 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 687 |
function getUsage() {
|
| 688 |
const today = getTodayString();
|
| 689 |
let usage = JSON.parse(localStorage.getItem('alpha_chat_usage') || '{}');
|
|
|
|
| 808 |
let html = txt.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
| 809 |
|
| 810 |
// تبدیل متون ضخیم
|
| 811 |
+
html = html.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>");
|
| 812 |
|
| 813 |
// تبدیل هدرها برای زیبایی و مرتب شدن
|
| 814 |
html = html.replace(/^### (.*?)$/gm, '<h3 style="font-size: 15px; margin: 12px 0 6px 0; color: #5a67d8; font-weight: bold;">$1</h3>');
|
|
|
|
| 908 |
}
|
| 909 |
|
| 910 |
function fallbackCopy() {
|
| 911 |
+
const textArea = document.createElement("textarea");
|
| 912 |
+
textArea.value = textToCopy;
|
| 913 |
+
document.body.appendChild(textArea);
|
| 914 |
+
textArea.select();
|
| 915 |
try { document.execCommand('copy'); showSuccess(); } catch(e) {}
|
| 916 |
+
textArea.remove();
|
| 917 |
}
|
| 918 |
}
|
| 919 |
/* ---------------------------------------------------- */
|
|
|
|
| 1016 |
fallbackCopy();
|
| 1017 |
}
|
| 1018 |
function fallbackCopy() {
|
| 1019 |
+
const textArea = document.createElement("textarea");
|
| 1020 |
+
textArea.value = textToCopy;
|
| 1021 |
+
textArea.style.position = "fixed";
|
| 1022 |
+
textArea.style.left = "-999999px";
|
| 1023 |
+
textArea.style.top = "-999999px";
|
| 1024 |
+
document.body.appendChild(textArea);
|
| 1025 |
+
textArea.focus();
|
| 1026 |
+
textArea.select();
|
| 1027 |
try {
|
| 1028 |
document.execCommand('copy');
|
| 1029 |
showCopiedSuccess();
|
| 1030 |
} catch (err) {
|
| 1031 |
console.error('Copy failed', err);
|
| 1032 |
}
|
| 1033 |
+
textArea.remove();
|
| 1034 |
}
|
| 1035 |
}
|
| 1036 |
|
|
|
|
| 1432 |
const sendBtn = document.getElementById('sendBtn');
|
| 1433 |
const statusBar = document.getElementById('statusBar');
|
| 1434 |
|
|
|
|
|
|
|
|
|
|
| 1435 |
function toggleSidebar() {
|
| 1436 |
document.getElementById('sidebar').classList.toggle('open');
|
| 1437 |
document.getElementById('overlay').classList.toggle('visible');
|
|
|
|
| 1619 |
|
| 1620 |
/* --- منطق جدید برای ساخت فایل (مقاله) بصورت استریم مشابه عکس --- */
|
| 1621 |
async function proceedToCreateFile(topic) {
|
| 1622 |
+
const msgTimestamp = Date.now();
|
| 1623 |
+
appendUserMessageUI(topic, false, null, msgTimestamp);
|
| 1624 |
+
await saveMessage('user', topic, null, null, msgTimestamp);
|
| 1625 |
+
|
| 1626 |
+
isGenerating = true;
|
| 1627 |
sendBtn.innerHTML = `<svg viewBox="0 0 24 24"><rect x="7" y="7" width="10" height="10" fill="white" stroke="none" rx="2" ry="2"/></svg>`;
|
| 1628 |
sendBtn.style.backgroundColor = "#5a67d8";
|
| 1629 |
statusBar.textContent = "در حال ایجاد مقاله...";
|
|
|
|
| 1935 |
if (isFileCreationMode && text) {
|
| 1936 |
isFileCreationMode = false; // خروج از حالت فایل پس از ارسال
|
| 1937 |
textInput.value = '';
|
| 1938 |
+
textInput.style.height = 'auto'; // ریست کردن ارتفاع پس از ارسال
|
| 1939 |
proceedToCreateFile(text);
|
| 1940 |
return;
|
| 1941 |
}
|
|
|
|
| 1952 |
incrementUsage(hasImage);
|
| 1953 |
|
| 1954 |
textInput.value = '';
|
| 1955 |
+
textInput.style.height = 'auto'; // ریست کردن ارتفاع پس از ارسال
|
| 1956 |
clearSelectedImage();
|
| 1957 |
|
| 1958 |
if (!currentSessionId) {
|
|
|
|
| 1966 |
}
|
| 1967 |
});
|
| 1968 |
|
| 1969 |
+
// تنظیم تغییر اندازه خودکار ارتفاع textarea با توجه به حجم متن ورودی
|
| 1970 |
+
textInput.addEventListener('input', function() {
|
| 1971 |
+
this.style.height = 'auto';
|
| 1972 |
+
this.style.height = (this.scrollHeight) + 'px';
|
|
|
|
|
|
|
| 1973 |
});
|
| 1974 |
|
| 1975 |
window.onload = async () => {
|