diff --git a/index.html b/index.html
deleted file mode 100644
index 6e4354e..0000000
--- a/index.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
- BMI-Web-App
-
-
-
-
-
\ No newline at end of file
diff --git a/src/dashboard/dashboard.js b/src/dashboard/dashboard.js
index 3f49590..d84f6a1 100644
--- a/src/dashboard/dashboard.js
+++ b/src/dashboard/dashboard.js
@@ -1,195 +1,219 @@
// src/dashboard/dashboard.js
-// Hash route -> view file
-const routes = {
+const ROUTES = {
dashboard: "./dashboard/dashboard.html",
formular: "./formular/formular.html",
tables: "./tables/tables.html",
};
+const DEFAULT_ROUTE = "dashboard";
+const VIEW_ID = "view";
+const SIDEBAR_ID = "sidebarNav";
+
const loadedScripts = new Set();
-function getRouteFromHash() {
- const raw = (location.hash || "#dashboard").replace("#", "").trim();
- return routes[raw] ? raw : "dashboard";
+/* =========================================================
+ Routing
+========================================================= */
+
+function getCurrentRoute() {
+ const hash = location.hash.replace("#", "").trim();
+ return ROUTES[hash] ? hash : DEFAULT_ROUTE;
}
-function getBaseDir(filePath) {
- const i = filePath.lastIndexOf("/");
- return i >= 0 ? filePath.slice(0, i + 1) : "./";
+function getRouteFile(route) {
+ return ROUTES[route];
}
-function isAbsoluteUrl(url) {
- return (
- /^(https?:)?\/\//i.test(url) ||
- url.startsWith("data:") ||
- url.startsWith("blob:")
- );
+/* =========================================================
+ Path Utilities
+========================================================= */
+
+function getBaseDirectory(path) {
+ const index = path.lastIndexOf("/");
+ return index >= 0 ? path.slice(0, index + 1) : "./";
+}
+
+function isExternalUrl(url) {
+ return /^(https?:)?\/\//i.test(url);
}
-function isRootAbsolute(url) {
+function isRootPath(url) {
return url.startsWith("/");
}
-function isSpecialUrl(url) {
- return (
- url.startsWith("#") ||
- url.startsWith("mailto:") ||
- url.startsWith("tel:") ||
- url.startsWith("javascript:")
+function isSpecialProtocol(url) {
+ return ["#", "mailto:", "tel:", "javascript:"].some((prefix) =>
+ url.startsWith(prefix),
);
}
-function toResolvedPath(url, baseDir) {
- // baseDir ist z. B. "./dashboard/"
- // Dokument liegt bei /src/app.html -> daraus wird /src/dashboard/...
+function shouldRewrite(url) {
+ if (!url) return false;
+ if (isExternalUrl(url)) return false;
+ if (isRootPath(url)) return false;
+ if (isSpecialProtocol(url)) return false;
+ if (url.startsWith("data:") || url.startsWith("blob:")) return false;
+ return true;
+}
+
+function resolvePath(url, baseDir) {
const base = new URL(baseDir, window.location.href);
const resolved = new URL(url, base);
-
- // Nur path + query + hash zurückgeben (kein kompletter Origin nötig)
return `${resolved.pathname}${resolved.search}${resolved.hash}`;
}
-function rewriteRelativeAssets(containerEl, baseDir) {
- const nodes = containerEl.querySelectorAll(
- "link[href], script[src], img[src], source[src], iframe[src]",
+/* =========================================================
+ Asset Handling
+========================================================= */
+
+function rewriteRelativeAssets(container, baseDir) {
+ const elements = container.querySelectorAll(
+ "link[href], script[src], img[src], source[src], iframe[src]"
);
- nodes.forEach((el) => {
- const attr = el.hasAttribute("href") ? "href" : "src";
- const val = (el.getAttribute(attr) || "").trim();
+ elements.forEach((element) => {
+ const attribute = element.hasAttribute("href") ? "href" : "src";
+ const value = element.getAttribute(attribute)?.trim();
- if (!val) {
- return;
- }
+ if (!shouldRewrite(value)) return;
- // Absolute / Root / Sonderfälle nicht anfassen
- if (isAbsoluteUrl(val) || isRootAbsolute(val) || isSpecialUrl(val)) {
- return;
- }
-
- // ALLE relativen Pfade auflösen (nicht nur "./...")
- const newVal = toResolvedPath(val, baseDir);
- el.setAttribute(attr, newVal);
+ element.setAttribute(attribute, resolvePath(value, baseDir));
});
}
-function runInlineScripts(containerEl) {
- // Inline
+
diff --git a/src/settings/setting.js b/src/settings/settings.js
similarity index 100%
rename from src/settings/setting.js
rename to src/settings/settings.js
diff --git a/src/tables/tables.html b/src/tables/tables.html
index 08cae36..0485059 100644
--- a/src/tables/tables.html
+++ b/src/tables/tables.html
@@ -7,9 +7,6 @@
-
-
-
BMI Tabellen
@@ -56,8 +53,6 @@ BMI-Messungen
-
-