js.php 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. <script defer src="/js/dist/main.min.js?<?= JS_LATEST_UPDATE ?>"></script>
  2. <script defer src="/js/vendor/alpine-3.12.0.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 if (!empty($_SESSION['error_msg'])) unset($_SESSION['error_msg']); ?>
  19. <?php
  20. $customScriptDirectory = new DirectoryIterator($_SERVER["HESTIA"] . "/web/js/custom_scripts");
  21. foreach ($customScriptDirectory as $customScript) {
  22. $extension = $customScript->getExtension();
  23. if ($extension === "js") {
  24. $customScriptPath = "/js/custom_scripts/" . rawurlencode($customScript->getBasename());
  25. echo '<script defer src="' . $customScriptPath . '"></script>';
  26. } elseif ($extension === "php") {
  27. require_once $customScript->getPathname();
  28. }
  29. } ?>