mirror of
https://github.com/khairul169/honey.git
synced 2026-10-04 18:03:54 +07:00
config: show loaded values on page
This commit is contained in:
@@ -2,6 +2,10 @@ function get(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
function set(id, text) {
|
||||
get(id).innerText = text;
|
||||
}
|
||||
|
||||
function get_class(class_name, parent) {
|
||||
if (!parent) parent = document;
|
||||
return parent.getElementsByClassName(class_name);
|
||||
@@ -55,4 +59,15 @@ function config(key, value) {
|
||||
|
||||
function get_bool(key) {
|
||||
return config(key) == "true";
|
||||
}
|
||||
|
||||
function load_config(conf) {
|
||||
CONFIG = JSON.parse(conf);
|
||||
let ui = CONFIG.ui;
|
||||
set("app-name", ui.name);
|
||||
set("app-desc", ui.desc);
|
||||
get("app-icon").src = ui.icon;
|
||||
if (ui.hosted_by) set("app-hostedby", ui.hosted_by);
|
||||
else get("app-hostedby").parentNode.style.display = "none";
|
||||
load_apps();
|
||||
}
|
||||
+3
-4
@@ -2,12 +2,11 @@ function onload() {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "config/config.json");
|
||||
xhr.onload = function() {
|
||||
CONFIG = JSON.parse(this.responseText);
|
||||
load_config(this.responseText);
|
||||
for_all("back", (btn) => {
|
||||
btn.onclick = show;
|
||||
});
|
||||
switch_theme(config("dark_mode") == "true");
|
||||
load_apps();
|
||||
setTimeout(() => {
|
||||
show();
|
||||
document.body.classList.remove("init");
|
||||
@@ -41,13 +40,13 @@ function switch_theme(value) {
|
||||
setting.classList.add("checked");
|
||||
icon.innerText = "dark_mode";
|
||||
bg.add("dark");
|
||||
get_background().src = "img/background-dark.jpg";
|
||||
get_background().src = CONFIG.ui.wallpaper_dark;
|
||||
}
|
||||
else {
|
||||
setting.classList.remove("checked");
|
||||
icon.innerText = "light_mode";
|
||||
bg.remove("dark");
|
||||
get_background().src = "img/background.jpg";
|
||||
get_background().src = CONFIG.ui.wallpaper;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user