Files
Falknat c1a781a0f5 Оптимизация
- Оптимизация JS файлов
- FIX: Исправил Crash, если не было папки logs
- Удалил скомпилированный EXE файл с репозитория исходников.
2025-11-15 23:33:57 +07:00

54 lines
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* ============================================
DOM Utilities
Утилиты для работы с DOM
============================================ */
// Получить элемент по ID
export function $(id) {
return document.getElementById(id);
}
// Получить все элементы по селектору
export function $$(selector, parent = document) {
return parent.querySelectorAll(selector);
}
// Показать элемент
export function show(element) {
const el = typeof element === 'string' ? $(element) : element;
if (el) el.style.display = 'block';
}
// Скрыть элемент
export function hide(element) {
const el = typeof element === 'string' ? $(element) : element;
if (el) el.style.display = 'none';
}
// Переключить видимость элемента
export function toggle(element) {
const el = typeof element === 'string' ? $(element) : element;
if (el) {
el.style.display = el.style.display === 'none' ? 'block' : 'none';
}
}
// Добавить класс
export function addClass(element, className) {
const el = typeof element === 'string' ? $(element) : element;
if (el) el.classList.add(className);
}
// Удалить класс
export function removeClass(element, className) {
const el = typeof element === 'string' ? $(element) : element;
if (el) el.classList.remove(className);
}
// Переключить класс
export function toggleClass(element, className) {
const el = typeof element === 'string' ? $(element) : element;
if (el) el.classList.toggle(className);
}