refactor: Refactor main.js to use shared utilities (Step 2 of 6)

Refactored main.js from 544 → 266 lines (51% reduction) by:
- Removing duplicate functions now in utils/form-helpers.js
- Removing duplicate i18n logic now in utils/i18n.js
- Removing API loading code now in utils/api.js
- Removing cookie consent handlers now in modules/cookie-consent.js

Kept only page-specific form handlers:
- Contact form submission with reCaptcha
- Subscribe form submission with reCaptcha
- Language switcher initialization
- Footer year and version display

All calls now use window.MyAi.* utilities for consistency.

Updated index.html to load all utilities before main.js.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-05-29 09:12:19 +03:00
parent 98979b58f8
commit ce05426452
2 changed files with 49 additions and 322 deletions
+4
View File
@@ -217,6 +217,10 @@
<a href="#" id="cookieManage" class="cookie-manage btn btn-dark btn-sm shadow" data-i18n="cookies.settings">Cookie settings</a>
<script src="/js/vendor/jquery-4.0.0.min.js"></script>
<script src="/js/i18n.js"></script>
<script src="/js/utils/form-helpers.js"></script>
<script src="/js/utils/i18n.js"></script>
<script src="/js/utils/api.js"></script>
<script src="/js/modules/cookie-consent.js"></script>
<script src="/js/main.js"></script>
</body>
</html>