$(document).ready(function () { const Toast = Swal.mixin({ toast: true, position: "bottom", showConfirmButton: false, timer: 3000, timerProgressBar: true, didOpen: (toast) => { toast.onmouseenter = Swal.stopTimer; toast.onmouseleave = Swal.resumeTimer; } }); // === Форма пароля === $('#passwordForm').on('submit', function (e) { console.log("Попытка входа"); e.preventDefault(); const formData = $(this).serialize(); const loginField = 'login'; const loginValue = $('#' + loginField).val().trim(); const password = $('#password').val().trim(); if (!loginValue || !password) { Toast.fire('Ошибка', 'Введите логин/email и пароль', 'error'); return; } // Блокируем форму $('#passwordForm input, #passwordForm button').attr('disabled', 'disabled'); $('#passwordForm').addClass('processing'); $.ajax({ url: 'ajax/check-password.php', method: 'POST', data: formData, dataType: 'json', success: function (response) { if (response.authenticated) { $('#passwordForm').removeClass('processing'); Toast.fire('Вы авторизованы!', '', 'success'); setTimeout(function () { window.location.href = 'https://invictica.ru/lk'; }, 1000); } else { Toast.fire('Ошибка', response.error || 'Неверные данные', 'error'); } }, error: function () { Toast.fire('Ошибка', 'Ошибка сервера', 'error'); }, complete: function () { // Разблокируем форму всегда $('#passwordForm input, #passwordForm button').removeAttr('disabled'); $('#passwordForm').removeClass('processing'); } }); }); });