Игорь Надеин 76f6f4ea32 refactor: extract JavaScript utilities to separate modules (Phase 2)
- Created reusable utility modules:
  * static/js/utils/stringUtils.js - string operations (esc, norm, escAttr, truncate, getInitials)
  * static/js/utils/timing.js - timing utilities (debounce, throttle, delay, poll, once)
  * static/js/utils/scroll.js - scroll helpers (smoothScrollTo, scrollToTop, isElementInViewport, etc.)

- Updated static/js/utils/index.js:
  * Exports all utilities from a single entry point
  * Provides centralized access to all utility functions

- Modified base.html:
  * Removed inline esc() and norm() function definitions
  * Added ES6 module imports for utilities
  * Exported utilities to window for backward compatibility
  * All existing code continues to work without changes

Benefits:
- Eliminates code duplication (esc/norm found in 9 templates)
- Centralizes utility functions for easier maintenance
- Enables future improvements (testing, optimization)
- Maintains backward compatibility with existing templates

Tests: All 12 static file tests passing ✅
2025-10-28 08:37:02 +03:00

46 lines
1.1 KiB
JavaScript
Raw 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.

/**
* JavaScript Utilities Index
*
* Этот файл служит единой точкой входа для всех JS утилит.
* Экспортирует все утилиты для удобного импорта.
*
* Использование в шаблонах:
* <script type="module">
* import { esc, norm, debounce } from '{% static "js/utils/index.js" %}';
* </script>
*
* Или импорт конкретной утилиты:
* import { esc } from '{% static "js/utils/stringUtils.js" %}';
*/
// Утилиты работы со строками
export {
esc,
norm,
escAttr,
truncate,
getInitials
} from './stringUtils.js';
// Утилиты для работы со временем
export {
debounce,
throttle,
delay,
poll,
once
} from './timing.js';
// Утилиты прокрутки
export {
smoothScrollTo,
scrollToTop,
scrollToBottom,
isElementInViewport,
getScrollPosition,
onScrollThreshold
} from './scroll.js';
// Версия утилит
export const UTILS_VERSION = '1.0.0';