js.php 1.2 KB

123456789101112131415161718192021222324252627282930
  1. <script defer src="/js/dist/main.min.js?<?= JS_LATEST_UPDATE ?>"></script>
  2. <script defer src="/js/dist/alpinejs.min.js?<?= JS_LATEST_UPDATE ?>"></script>
  3. <script>
  4. document.documentElement.classList.replace('no-js', 'js');
  5. document.addEventListener('alpine:init', () => {
  6. Alpine.store('globals', {
  7. USER_PREFIX: '<?= $user_plain ?>_',
  8. UNLIMITED: '<?= _("Unlimited") ?>',
  9. NOTIFICATIONS_EMPTY: '<?= _("No notifications") ?>',
  10. NOTIFICATIONS_DELETE_ALL: '<?= _("Delete all notifications") ?>',
  11. CONFIRM_LEAVE_PAGE: '<?= _("LEAVE_PAGE_CONFIRMATION") ?>',
  12. ERROR_MESSAGE: '<?= !empty($_SESSION['error_msg']) ? htmlentities($_SESSION['error_msg']) : '' ?>',
  13. BLACKLIST: '<?= _("BLACKLIST") ?>',
  14. IPVERSE: '<?= _("IPVERSE") ?>'
  15. });
  16. })
  17. </script>
  18. <?php
  19. $customScriptDirectory = new DirectoryIterator($_SERVER["HESTIA"] . "/web/js/custom_scripts");
  20. foreach ($customScriptDirectory as $customScript) {
  21. $extension = $customScript->getExtension();
  22. if ($extension === "js") {
  23. $customScriptPath = "/js/custom_scripts/" . rawurlencode($customScript->getBasename());
  24. echo '<script defer src="' . $customScriptPath . '"></script>';
  25. } elseif ($extension === "php") {
  26. require_once $customScript->getPathname();
  27. }
  28. } ?>