diff --git a/HaWeb/Views/Shared/_Head.cshtml b/HaWeb/Views/Shared/_Head.cshtml
index 33b842a..1d09534 100644
--- a/HaWeb/Views/Shared/_Head.cshtml
+++ b/HaWeb/Views/Shared/_Head.cshtml
@@ -20,5 +20,25 @@
@* Styles *@
-@* JavaScript *@
-@await Html.PartialAsync("/Views/Shared/_JavaScript.cshtml")
\ No newline at end of file
+
+
diff --git a/HaWeb/package-lock.json b/HaWeb/package-lock.json
index e9045b0..a0522bb 100644
--- a/HaWeb/package-lock.json
+++ b/HaWeb/package-lock.json
@@ -10,6 +10,7 @@
"devDependencies": {
"autoprefixer": "^10.4.7",
"cssnano": "^5.1.11",
+ "mark.js": "^8.11.1",
"postcss": "^8.4.14",
"postcss-cli": "^9.1.0",
"postcss-import": "^14.1.0",
@@ -1480,6 +1481,12 @@
"integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==",
"dev": true
},
+ "node_modules/mark.js": {
+ "version": "8.11.1",
+ "resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz",
+ "integrity": "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==",
+ "dev": true
+ },
"node_modules/mdn-data": {
"version": "2.0.14",
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz",
@@ -3601,6 +3608,12 @@
"integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==",
"dev": true
},
+ "mark.js": {
+ "version": "8.11.1",
+ "resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz",
+ "integrity": "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==",
+ "dev": true
+ },
"mdn-data": {
"version": "2.0.14",
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz",
diff --git a/HaWeb/package.json b/HaWeb/package.json
index bfc371d..fe0874d 100644
--- a/HaWeb/package.json
+++ b/HaWeb/package.json
@@ -9,12 +9,13 @@
"preview": "vite preview"
},
"devDependencies": {
- "vite": "^5.0.8",
"autoprefixer": "^10.4.7",
"cssnano": "^5.1.11",
+ "mark.js": "^8.11.1",
"postcss": "^8.4.14",
"postcss-cli": "^9.1.0",
"postcss-import": "^14.1.0",
- "tailwindcss": "^3.0.24"
+ "tailwindcss": "^3.0.24",
+ "vite": "^5.0.8"
}
}
diff --git a/HaWeb/vite.config.js b/HaWeb/vite.config.js
index b8a9476..2b81a56 100644
--- a/HaWeb/vite.config.js
+++ b/HaWeb/vite.config.js
@@ -6,7 +6,7 @@ export default defineConfig({
lib: {
entry: resolve(__dirname, 'wwwroot/js/main.js'),
name: 'HaWeb',
- fileName: 'scripts'
+ fileName: 'scripts',
},
outDir: resolve(__dirname, 'wwwroot/dist/'),
}
diff --git a/HaWeb/wwwroot/js/anchor.js b/HaWeb/wwwroot/js/anchor.mjs
similarity index 96%
rename from HaWeb/wwwroot/js/anchor.js
rename to HaWeb/wwwroot/js/anchor.mjs
index 3f04417..a7b17d3 100644
--- a/HaWeb/wwwroot/js/anchor.js
+++ b/HaWeb/wwwroot/js/anchor.mjs
@@ -19,4 +19,4 @@ const startup_markanchor = function () {
}
}
-startup_markanchor();
\ No newline at end of file
+export { startup_markanchor };
\ No newline at end of file
diff --git a/HaWeb/wwwroot/js/clipboard.js b/HaWeb/wwwroot/js/clipboard.mjs
similarity index 90%
rename from HaWeb/wwwroot/js/clipboard.js
rename to HaWeb/wwwroot/js/clipboard.mjs
index 71f04f6..ce63fee 100644
--- a/HaWeb/wwwroot/js/clipboard.js
+++ b/HaWeb/wwwroot/js/clipboard.mjs
@@ -9,5 +9,4 @@ const startup_clipboard = function () {
});
}
-
-startup_clipboard();
\ No newline at end of file
+export { startup_clipboard };
\ No newline at end of file
diff --git a/HaWeb/wwwroot/js/main.js b/HaWeb/wwwroot/js/main.js
index b862f82..8e5cb6a 100644
--- a/HaWeb/wwwroot/js/main.js
+++ b/HaWeb/wwwroot/js/main.js
@@ -1 +1,10 @@
-import "../css/site.css";
\ No newline at end of file
+import "../css/site.css";
+import { startup_marginals } from "./marginals.mjs";
+import { startup_theme } from "./theme.mjs";
+import { startup_menu } from "./menu.js";
+import { startup_markanchor } from "./anchor.mjs";
+import { startup_mobilemenu } from "./mobilemenu.js";
+import { startup_scrollbutton } from "./scrollbutton.mjs";
+import { startup_clipboard } from "./clipboard.mjs";
+
+export { startup_clipboard, startup_mobilemenu, startup_markanchor, startup_menu, startup_scrollbutton, startup_marginals, startup_theme };
\ No newline at end of file
diff --git a/HaWeb/wwwroot/js/marginals.js b/HaWeb/wwwroot/js/marginals.mjs
similarity index 95%
rename from HaWeb/wwwroot/js/marginals.js
rename to HaWeb/wwwroot/js/marginals.mjs
index e292394..0594fff 100644
--- a/HaWeb/wwwroot/js/marginals.js
+++ b/HaWeb/wwwroot/js/marginals.mjs
@@ -154,10 +154,10 @@ const startup_marginals = function () {
overlappingcollapsebox(".ha-text .ha-marginalbox", true);
};
- var collapsedboxes = [];
+ let collapsedboxes = [];
const clearcollapsedboxes = function () {
- var elements = document.querySelectorAll(".ha-text .ha-marginalbox");
+ let elements = document.querySelectorAll(".ha-text .ha-marginalbox");
elements.forEach(element => {
element.removeAttribute("style");
});
@@ -167,7 +167,7 @@ const startup_marginals = function () {
element.outerHTML = element.outerHTML;
});
collapsedboxes = [];
- var elements = document.querySelectorAll(".ha-btn-collapsed-box");
+ elements = document.querySelectorAll(".ha-btn-collapsed-box");
elements.forEach(element => {
element.remove();
});
@@ -184,10 +184,10 @@ const startup_marginals = function () {
collapseboxes();
var doit;
- this.window.addEventListener("resize", function () {
- this.clearTimeout(doit);
- doit = this.setTimeout(resetall, 17);
+ window.addEventListener("resize", function () {
+ clearTimeout(doit);
+ doit = setTimeout(resetall, 17);
});
};
-startup_marginals();
+export { startup_marginals };
diff --git a/HaWeb/wwwroot/js/active.js b/HaWeb/wwwroot/js/menu.js
similarity index 95%
rename from HaWeb/wwwroot/js/active.js
rename to HaWeb/wwwroot/js/menu.js
index e1d85cc..8d732b9 100644
--- a/HaWeb/wwwroot/js/active.js
+++ b/HaWeb/wwwroot/js/menu.js
@@ -1,4 +1,4 @@
-const startup_active = function () {
+const startup_menu = function () {
// Gives active classes to links with active URLs
// Marks links as active which target URL starts with the current URL
const markactive_startswith = function (element) {
@@ -65,9 +65,9 @@ const startup_active = function () {
markactive_menu(document.getElementById("ha-topnav"));
if (document.getElementById("ha-register-nav") !== null)
markactive_exact(document.getElementById("ha-register-nav"));
- if (this.document.getElementById("ha-adminuploadfields") !== null)
+ if (document.getElementById("ha-adminuploadfields") !== null)
markactive_exact(document.getElementById("ha-adminuploadfields"));
};
-startup_active();
\ No newline at end of file
+export { startup_menu };
\ No newline at end of file
diff --git a/HaWeb/wwwroot/js/mobilemenu.js b/HaWeb/wwwroot/js/mobilemenu.js
index 311017e..c5533d0 100644
--- a/HaWeb/wwwroot/js/mobilemenu.js
+++ b/HaWeb/wwwroot/js/mobilemenu.js
@@ -32,4 +32,4 @@ const startup_mobilemenu = function () {
}
};
-startup_mobilemenu();
\ No newline at end of file
+export { startup_mobilemenu };
\ No newline at end of file
diff --git a/HaWeb/wwwroot/js/scrollbutton.js b/HaWeb/wwwroot/js/scrollbutton.mjs
similarity index 91%
rename from HaWeb/wwwroot/js/scrollbutton.js
rename to HaWeb/wwwroot/js/scrollbutton.mjs
index 7f53abe..51684bc 100644
--- a/HaWeb/wwwroot/js/scrollbutton.js
+++ b/HaWeb/wwwroot/js/scrollbutton.mjs
@@ -2,7 +2,7 @@ const startup_scrollbutton = function () {
// Script for showing and acting upon the "scroll to top button"
const scrollFunction = function () {
- button = document.getElementById("ha-scrollbutton");
+ let button = document.getElementById("ha-scrollbutton");
if (button !== null) {
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 300) {
// button.style.display = "block";
@@ -28,4 +28,4 @@ const startup_scrollbutton = function () {
}
};
-startup_scrollbutton();
\ No newline at end of file
+export { startup_scrollbutton };
\ No newline at end of file
diff --git a/HaWeb/wwwroot/js/theme.js b/HaWeb/wwwroot/js/theme.mjs
similarity index 92%
rename from HaWeb/wwwroot/js/theme.js
rename to HaWeb/wwwroot/js/theme.mjs
index 0df7e70..22a77d2 100644
--- a/HaWeb/wwwroot/js/theme.js
+++ b/HaWeb/wwwroot/js/theme.mjs
@@ -20,7 +20,7 @@ const startup_theme = function () {
if (
document.getElementById("ha-togglebright") !== null &&
- this.document.getElementById("ha-toggledark") !== null
+ document.getElementById("ha-toggledark") !== null
) {
document
.getElementById("ha-togglebright")
@@ -32,4 +32,4 @@ const startup_theme = function () {
get_theme_settings("ha-togglebright");
};
-startup_theme();
\ No newline at end of file
+export { startup_theme };
\ No newline at end of file