From 1c637efae3e301a7d30a6ad4c68d477cc6c354c5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 18 Jan 2023 16:20:53 +0100 Subject: [PATCH] More page: make Security module functional --- README.md | 2 +- index.html | 2 +- js/dom.js | 9 +++++---- js/main.js | 8 +++++++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 76e4c48..6f99d1a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This will be a dashboard hosted on my homeserver with self-hosted stuff. But, fo - [x] External config loaded with XHR (app list) - [x] Apply config for the rest stuff (data shown in More page, default user settings) -- [ ] Make 'Security' module functional +- [x] Make 'Security' module functional - [x] CSS global color variables for easier theming - [ ] Fix blur flicker on showing/hiding pages - [x] Open in new tab setting diff --git a/index.html b/index.html index 38e3ed2..747fdac 100644 --- a/index.html +++ b/index.html @@ -70,7 +70,7 @@
shield
85%
-
6 out of 7 listed services use secure connections
+
out of listed services use secure connections
diff --git a/js/dom.js b/js/dom.js index 254d685..49adc2d 100644 --- a/js/dom.js +++ b/js/dom.js @@ -76,8 +76,9 @@ function load_config(conf) { } function is_secure(uri) { - if (uri.includes("tp://")) return false; - if (!uri.startsWith("https://")) { - uri = location.href; - } + let secure = uri.indexOf("tps://") != -1; + let insecure = uri.indexOf("tp://") != -1; + if (secure) return true; + if (insecure) return false; + return is_secure(location.href); } \ No newline at end of file diff --git a/js/main.js b/js/main.js index c1eb7b2..0d62ccb 100644 --- a/js/main.js +++ b/js/main.js @@ -51,11 +51,17 @@ function switch_theme(value) { function load_apps() { let final = ""; - for (let i = 0; i < CONFIG["services"].length; i++) { + let secures = 0; + let i = 0; + while (i < CONFIG["services"].length) { let app = mk_entry(CONFIG["services"][i]); final += app; + i++; } get("applist").innerHTML = final; + set("services-total", i); + set("services-secure", secures); + set("security-pp", Math.round(100 * secures / i)); } function new_tab_toggle(value) {