diff --git a/config/prod/config.php b/config/prod/config.php new file mode 100644 index 0000000..bc2b204 --- /dev/null +++ b/config/prod/config.php @@ -0,0 +1,4 @@ + +' . PHP_EOL; +} + +// Scripts im Footer +foreach ($GLOBALS['page_footer_scripts'] as $script) { + $src = $script['src']; + if (!empty($script['version'])) { + $src .= (str_contains($src, '?') ? '&' : '?') . 'v=' . urlencode($script['version']); + } + + $attr = ''; + if ($script['async']) { + $attr .= ' async'; + } elseif ($script['defer']) { + $attr .= ' defer'; + } + if ($script['type']) { + $attr .= ' type="' . htmlspecialchars($script['type']) . '"'; + } + + echo '' . PHP_EOL; +} +?> diff --git a/partials/structure/layout_start.php b/partials/structure/layout_start.php index 1e3e3fd..610e50c 100644 --- a/partials/structure/layout_start.php +++ b/partials/structure/layout_start.php @@ -38,6 +38,41 @@ $host = $_SERVER['HTTP_HOST'] ?? ''; +' . PHP_EOL; +} + +// Scripts im Header +foreach ($GLOBALS['page_header_scripts'] as $script) { + $src = $script['src']; + if (!empty($script['version'])) { + $src .= (str_contains($src, '?') ? '&' : '?') . 'v=' . urlencode($script['version']); + } + + $attr = ''; + if ($script['async']) { + $attr .= ' async'; + } elseif ($script['defer']) { + $attr .= ' defer'; + } + if ($script['type']) { + $attr .= ' type="' . htmlspecialchars($script['type']) . '"'; + } + + echo '' . PHP_EOL; +} +?> diff --git a/public/assets/js/auth.js b/public/assets/js/auth.js new file mode 100644 index 0000000..39eba4a --- /dev/null +++ b/public/assets/js/auth.js @@ -0,0 +1,30 @@ +document.addEventListener("DOMContentLoaded", () => { + const tabs = document.querySelectorAll(".auth-tab"); + const panelLogin = document.getElementById("authPanelLogin"); + const panelRegister = document.getElementById("authPanelRegister"); + + if (!tabs.length || !panelLogin || !panelRegister) return; + + tabs.forEach(tab => { + tab.addEventListener("click", () => { + const target = tab.getAttribute("data-tab"); // "login" oder "register" + + // Tab-Styles + tabs.forEach(t => { + t.classList.remove("bg-brand-primary", "text-brand-bg"); + t.classList.add("hover:text-brand-primary"); + }); + tab.classList.add("bg-brand-primary", "text-brand-bg"); + tab.classList.remove("hover:text-brand-primary"); + + // Panels + if (target === "login") { + panelLogin.classList.remove("hidden"); + panelRegister.classList.add("hidden"); + } else { + panelRegister.classList.remove("hidden"); + panelLogin.classList.add("hidden"); + } + }); + }); +}); diff --git a/public/fakecheck/index.php b/public/fakecheck/index.php index 7bfd844..1431160 100644 --- a/public/fakecheck/index.php +++ b/public/fakecheck/index.php @@ -1,4 +1,7 @@ $src, + 'defer' => $defer, + 'async' => $async, + 'type' => $type, + 'version' => $version, // kann null, '' oder string sein + ]; + + if ($pos === 'header') { + $GLOBALS['page_header_scripts'][] = $data; + } else { + $GLOBALS['page_footer_scripts'][] = $data; + } +} + +/** + * CSS registrieren + * + * @param string $href Pfad zur CSS + * @param string $pos 'header' oder 'footer' + * @param string|null $version gleiche Logik wie bei Scripts + */ +function tpl_add_style(string $href, string $pos = 'header', ?string $version = null): void +{ + if ($version === null && defined('ASSET_VERSION')) { + $version = ASSET_VERSION; + } + + $GLOBALS['page_styles'][] = [ + 'href' => $href, + 'pos' => $pos, + 'version' => $version, + ]; +} + + /** * Templating Loader *