налажена логика добавления промптов через диалог с ИИ, отлажена работа с задачами, настроена авторизация в веб интерфейсе.
This commit is contained in:
+39
-21
@@ -1,31 +1,46 @@
|
||||
const AUTH_TOKEN_KEY = "scud_api_auth_token";
|
||||
const SESSION_ID = "web_session_main";
|
||||
const STORAGE_KEY = 'scud_chat_input_history';
|
||||
const STORAGE_KEY = "scud_chat_input_history";
|
||||
|
||||
let API_TOKEN = localStorage.getItem(AUTH_TOKEN_KEY) || "";
|
||||
let CURRENT_USERNAME = localStorage.getItem('scud_username') || "";
|
||||
let IS_GUEST = localStorage.getItem('scud_is_guest') === 'true';
|
||||
let currentFilter = 'ALL';
|
||||
let allTasks = [];
|
||||
let CURRENT_USERNAME = localStorage.getItem("scud_username") || "";
|
||||
let IS_ADMIN = localStorage.getItem("scud_is_admin") === "true";
|
||||
let IS_GUEST = localStorage.getItem("scud_is_guest") === "true";
|
||||
|
||||
let inputHistory = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');
|
||||
let inputHistory = JSON.parse(localStorage.getItem(STORAGE_KEY) || "[]");
|
||||
let historyIndex = -1;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const userInputEl = document.getElementById('user-input');
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const userInputEl = document.getElementById("user-input");
|
||||
|
||||
if (userInputEl) {
|
||||
userInputEl.addEventListener('input', function() {
|
||||
this.style.height = 'auto';
|
||||
this.style.height = Math.min(this.scrollHeight, 80) + 'px';
|
||||
userInputEl.addEventListener("input", function() {
|
||||
this.style.height = "auto";
|
||||
this.style.height = Math.min(this.scrollHeight, 80) + "px";
|
||||
});
|
||||
|
||||
userInputEl.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
userInputEl.addEventListener("keydown", function(e) {
|
||||
// Отправка по Enter
|
||||
if (e.key === "Enter" && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
document.getElementById('chat-form').requestSubmit();
|
||||
|
||||
const val = this.value.trim();
|
||||
if (val) {
|
||||
// Сохраняем команду в историю
|
||||
if (inputHistory.length === 0 || inputHistory[inputHistory.length - 1] !== val) {
|
||||
inputHistory.push(val);
|
||||
if (inputHistory.length > 50) inputHistory.shift();
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(inputHistory));
|
||||
}
|
||||
historyIndex = -1;
|
||||
}
|
||||
|
||||
if (typeof sendMessage === "function") {
|
||||
sendMessage(e);
|
||||
}
|
||||
}
|
||||
else if (e.key === 'ArrowUp') {
|
||||
// История: стрелка ВВЕРХ
|
||||
else if (e.key === "ArrowUp") {
|
||||
if (inputHistory.length > 0 && historyIndex < inputHistory.length - 1) {
|
||||
e.preventDefault();
|
||||
if (historyIndex === -1) {
|
||||
@@ -33,11 +48,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
historyIndex++;
|
||||
this.value = inputHistory[inputHistory.length - 1 - historyIndex];
|
||||
this.dispatchEvent(new Event('input'));
|
||||
this.dispatchEvent(new Event("input"));
|
||||
setTimeout(() => this.setSelectionRange(this.value.length, this.value.length), 0);
|
||||
}
|
||||
}
|
||||
else if (e.key === 'ArrowDown') {
|
||||
// История: стрелка ВНИЗ
|
||||
else if (e.key === "ArrowDown") {
|
||||
if (historyIndex !== -1) {
|
||||
e.preventDefault();
|
||||
if (historyIndex > 0) {
|
||||
@@ -45,9 +61,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
this.value = inputHistory[inputHistory.length - 1 - historyIndex];
|
||||
} else {
|
||||
historyIndex = -1;
|
||||
this.value = this.dataset.draft || '';
|
||||
this.value = this.dataset.draft || "";
|
||||
}
|
||||
this.dispatchEvent(new Event('input'));
|
||||
this.dispatchEvent(new Event("input"));
|
||||
setTimeout(() => this.setSelectionRange(this.value.length, this.value.length), 0);
|
||||
}
|
||||
}
|
||||
@@ -60,8 +76,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
} else if (API_TOKEN) {
|
||||
hideAuthModal();
|
||||
updateUIState();
|
||||
loadTasks();
|
||||
if (typeof loadTasks === "function") {
|
||||
loadTasks();
|
||||
}
|
||||
} else {
|
||||
showAuthModal();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user