скрипты в скриптах
This commit is contained in:
132
public/auth.js
132
public/auth.js
@@ -83,11 +83,84 @@ function showMainInterface() {
|
||||
|
||||
document.getElementById('current-user').textContent = userInfo;
|
||||
|
||||
// 👇 СОЗДАЕМ НАВИГАЦИЮ ПОСЛЕ УСТАНОВКИ ПОЛЬЗОВАТЕЛЯ 👇
|
||||
createUserNavigation();
|
||||
// 👇 ПЕРЕЗАГРУЗКА ВСЕХ СКРИПТОВ ПОСЛЕ АВТОРИЗАЦИИ 👇
|
||||
reloadAllScripts();
|
||||
}
|
||||
|
||||
document.getElementById('tasks-controls').style.display = 'block';
|
||||
// Функция для перезагрузки всех скриптов
|
||||
function reloadAllScripts() {
|
||||
console.log('🔄 Перезагрузка всех скриптов после авторизации...');
|
||||
|
||||
// Список скриптов для перезагрузки (в правильном порядке)
|
||||
const scriptsToReload = [
|
||||
'users.js',
|
||||
'ui.js',
|
||||
'signature.js',
|
||||
'tasks.js',
|
||||
'kanban.js',
|
||||
'files.js',
|
||||
'profile.js',
|
||||
'time-selector.js',
|
||||
'openTaskChat.js',
|
||||
'tasks_files.js',
|
||||
'navbar.js',
|
||||
'chat-ui.js',
|
||||
'document-fields.js',
|
||||
'main.js'
|
||||
];
|
||||
|
||||
// Удаляем существующие скрипты
|
||||
scriptsToReload.forEach(src => {
|
||||
const existingScripts = document.querySelectorAll(`script[src="${src}"]`);
|
||||
existingScripts.forEach(script => script.remove());
|
||||
});
|
||||
|
||||
// Загружаем скрипты последовательно
|
||||
loadScriptsSequentially(scriptsToReload, 0);
|
||||
}
|
||||
|
||||
function loadScriptsSequentially(scripts, index) {
|
||||
if (index >= scripts.length) {
|
||||
console.log('✅ Все скрипты успешно перезагружены');
|
||||
|
||||
// Инициализация после загрузки всех скриптов
|
||||
setTimeout(() => {
|
||||
initializeAfterReload();
|
||||
}, 100);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const script = document.createElement('script');
|
||||
script.src = scripts[index];
|
||||
script.onload = () => {
|
||||
console.log(`✅ Загружен: ${scripts[index]}`);
|
||||
loadScriptsSequentially(scripts, index + 1);
|
||||
};
|
||||
script.onerror = (error) => {
|
||||
console.error(`❌ Ошибка загрузки ${scripts[index]}:`, error);
|
||||
loadScriptsSequentially(scripts, index + 1);
|
||||
};
|
||||
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
function initializeAfterReload() {
|
||||
console.log('🚀 Инициализация интерфейса после перезагрузки...');
|
||||
|
||||
// Создаем навигацию
|
||||
if (typeof createNavigation === 'function') {
|
||||
createNavigation();
|
||||
} else {
|
||||
console.warn('⚠️ createNavigation не найдена, пробуем позже...');
|
||||
setTimeout(() => {
|
||||
if (typeof createNavigation === 'function') {
|
||||
createNavigation();
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
|
||||
// Настраиваем отображение чекбокса удаленных задач
|
||||
const showDeletedLabel = document.querySelector('.show-deleted-label');
|
||||
if (showDeletedLabel) {
|
||||
if (currentUser.role === 'admin') {
|
||||
@@ -97,30 +170,36 @@ function showMainInterface() {
|
||||
}
|
||||
}
|
||||
|
||||
// Загружаем данные
|
||||
if (typeof loadUsers === 'function') {
|
||||
loadUsers();
|
||||
loadTasks();
|
||||
loadActivityLogs();
|
||||
showSection('tasks');
|
||||
loadKanbanTasks();
|
||||
}
|
||||
|
||||
showingTasksWithoutDate = false;
|
||||
if (typeof loadTasks === 'function') {
|
||||
loadTasks();
|
||||
}
|
||||
|
||||
if (typeof loadActivityLogs === 'function') {
|
||||
loadActivityLogs();
|
||||
}
|
||||
|
||||
if (typeof loadKanbanTasks === 'function') {
|
||||
loadKanbanTasks();
|
||||
}
|
||||
|
||||
// Показываем секцию задач
|
||||
if (typeof showSection === 'function') {
|
||||
showSection('tasks');
|
||||
}
|
||||
|
||||
// Сбрасываем состояние кнопки задач без даты
|
||||
window.showingTasksWithoutDate = false;
|
||||
const btn = document.getElementById('tasks-no-date-btn');
|
||||
if (btn) btn.classList.remove('active');
|
||||
}
|
||||
// Новая функция для создания навигации
|
||||
function createUserNavigation() {
|
||||
if (typeof createNavigation === 'function') {
|
||||
console.log('🔄 Создание навигации для пользователя:', currentUser.role);
|
||||
createNavigation();
|
||||
} else {
|
||||
console.warn('⚠️ Функция createNavigation не найдена');
|
||||
// Если функция не загружена, пробуем еще раз через небольшую задержку
|
||||
setTimeout(() => {
|
||||
if (typeof createNavigation === 'function') {
|
||||
console.log('🔄 Повторная попытка создания навигации');
|
||||
createNavigation();
|
||||
}
|
||||
}, 100);
|
||||
|
||||
// Переустанавливаем обработчики событий
|
||||
if (typeof setupEventListeners === 'function') {
|
||||
setupEventListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +251,13 @@ async function logout() {
|
||||
await fetch('/api/logout', { method: 'POST' });
|
||||
currentUser = null;
|
||||
showLoginInterface();
|
||||
|
||||
// Очищаем интерфейс
|
||||
document.querySelector('.container').style.display = 'none';
|
||||
document.querySelectorAll('.section').forEach(section => {
|
||||
section.classList.remove('active');
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Ошибка выхода:', error);
|
||||
}
|
||||
|
||||
@@ -6,24 +6,29 @@
|
||||
<title>School CRM - Управление задачами</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<!--
|
||||
<script src="loading-start.js"></script>
|
||||
|
||||
-->
|
||||
<script src="auth.js"></script>
|
||||
<!--
|
||||
<script src="users.js"></script>
|
||||
<script src="ui.js"></script>
|
||||
<script src="signature.js"></script>
|
||||
<script src="tasks.js"></script>
|
||||
<script src="kanban.js"></script>
|
||||
<script src="files.js"></script>
|
||||
<script src="profile.js"></script>
|
||||
<!-- <script src="tasks-type.js"></script> tasks-type.js -->
|
||||
<script src="time-selector.js"></script>
|
||||
<script src="openTaskChat.js"></script>
|
||||
<script src="main.js"></script>
|
||||
<script src="tasks_files.js"></script>
|
||||
<script src="navbar.js"></script>
|
||||
<script src="chat-ui.js"></script>
|
||||
<script src="signature.js"></script>
|
||||
<script src="document-fields.js"></script>
|
||||
<script src="chat-ui.js"></script>
|
||||
-->
|
||||
<script src="main.js"></script>
|
||||
<!--
|
||||
<script src="tasks-type.js"></script>
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="login-modal" class="modal">
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// Конфигурация
|
||||
const CONFIG = {
|
||||
maxRetries: 3,
|
||||
retryDelay: 2000,
|
||||
retryDelay: 5000,
|
||||
timeout: 10000,
|
||||
showWarnings: true,
|
||||
maxLoadingTime: 15000, // Максимум 15 секунд
|
||||
minLoadingTime: 5000 // Минимум 5 секунд
|
||||
minLoadingTime: 1000 // Минимум 5 секунд
|
||||
};
|
||||
|
||||
// Генерация случайных цветов для градиента
|
||||
@@ -124,8 +124,8 @@
|
||||
{ emoji: '🔔', text: 'Настройка уведомлений...', weight: 80 },
|
||||
{ emoji: '💾', text: 'Сохранение кэша...', weight: 85 },
|
||||
{ emoji: '✨', text: 'Финальная обработка...', weight: 90 },
|
||||
{ emoji: '🚀', text: 'Запуск приложения...', weight: 95 },
|
||||
{ emoji: '✅', text: 'Почти готово...', weight: 98 }
|
||||
{ emoji: '✅', text: 'Наливаем кофе...', weight: 98 },
|
||||
{ emoji: '✅', text: 'Завершено!', weight: 100 }
|
||||
];
|
||||
|
||||
// Дополнительные случайные статусы
|
||||
@@ -544,7 +544,7 @@
|
||||
const loadedScripts = this.loaded;
|
||||
const totalScripts = this.total;
|
||||
const errors = this.errors.length;
|
||||
const timeElapsed = ((Date.now() - this.startTime) / 1000).toFixed(1);
|
||||
const timeElapsed = ((Date.now() - this.startTime) / 3000).toFixed(1);
|
||||
|
||||
let detailsHtml = `📊 ${loadedScripts}/${totalScripts} модулей • ⏱️ ${timeElapsed}с`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user