40061-vm/assets/js/main.js
Flatlogic Bot f9536ee19b 01
2026-05-24 07:14:49 +00:00

55 lines
1.9 KiB
JavaScript

document.addEventListener('DOMContentLoaded', () => {
if (window.bootstrap) {
document.querySelectorAll('.toast').forEach((toastEl) => {
const toast = new bootstrap.Toast(toastEl, {
delay: 4200,
});
toast.show();
});
}
const searchInput = document.querySelector('[data-mail-search]');
const messageItems = Array.from(document.querySelectorAll('[data-mail-item]'));
const searchEmpty = document.querySelector('[data-mail-empty]');
if (searchInput && messageItems.length) {
const applyFilter = () => {
const term = searchInput.value.trim().toLowerCase();
let visibleCount = 0;
messageItems.forEach((item) => {
const haystack = (item.getAttribute('data-search') || '').toLowerCase();
const matches = term === '' || haystack.includes(term);
item.classList.toggle('d-none', !matches);
if (matches) {
visibleCount += 1;
}
});
if (searchEmpty) {
searchEmpty.classList.toggle('d-none', visibleCount > 0);
}
};
searchInput.addEventListener('input', applyFilter);
applyFilter();
}
document.querySelectorAll('[data-security-select]').forEach((select) => {
const portInput = document.querySelector(select.getAttribute('data-port-target'));
if (!portInput) {
return;
}
select.addEventListener('change', () => {
const currentValue = portInput.value.trim();
if (select.value === 'ssl' && (currentValue === '' || currentValue === '110')) {
portInput.value = '995';
}
if (select.value === 'plain' && (currentValue === '' || currentValue === '995')) {
portInput.value = '110';
}
});
});
});