mirror of
https://github.com/khairul169/honey.git
synced 2025-04-28 14:59:32 +07:00
Read & load external config.json file
This commit is contained in:
parent
e9525864c2
commit
988a823b4e
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
config/config.json
|
57
config/defaults.json
Normal file
57
config/defaults.json
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"ui": {
|
||||||
|
"name": "honey",
|
||||||
|
"desc": "Nice and sweet place for all your self-hosted services.",
|
||||||
|
"icon": "img/icon.png",
|
||||||
|
"wallpaper": "img/background.jpg",
|
||||||
|
"wallpaper_dark": "img/background_dark.jpg",
|
||||||
|
"dark_mode": false,
|
||||||
|
"open_new_tab": false,
|
||||||
|
"hosted_by": "somebody",
|
||||||
|
"enable_security": true
|
||||||
|
},
|
||||||
|
"services": [
|
||||||
|
{
|
||||||
|
"name": "CalDav",
|
||||||
|
"desc": "Simple CalDav server for calendar sync between various devices.",
|
||||||
|
"href": "caldav",
|
||||||
|
"icon": "img/preview/caldav.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Files",
|
||||||
|
"desc": "Fancy file manager for the web.",
|
||||||
|
"href": "files",
|
||||||
|
"icon": "img/preview/files.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Gallery",
|
||||||
|
"desc": "Photo & video gallery syncable with multiple Android devices.",
|
||||||
|
"href": "gallery",
|
||||||
|
"icon": "img/preview/gallery.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Git",
|
||||||
|
"desc": "Self-hosted, painless, secure place for your repositories.",
|
||||||
|
"href": "git",
|
||||||
|
"icon": "img/preview/git.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "E-Mail",
|
||||||
|
"desc": "Feature-rich, decentralized and secure E-Mail server.",
|
||||||
|
"href": "mail",
|
||||||
|
"icon": "img/preview/mail.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Music",
|
||||||
|
"desc": "Beautiful, moody music streaming app.",
|
||||||
|
"href": "music",
|
||||||
|
"icon": "img/preview/music.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Notes",
|
||||||
|
"desc": "Sweet & lightweight app for taking notes.",
|
||||||
|
"href": "notes",
|
||||||
|
"icon": "img/preview/notes.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -80,8 +80,8 @@
|
|||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="icon" style="--color: 144deg">lock</div>
|
<div class="icon" style="--color: 144deg">lock</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="name">Enryption?</div>
|
<div class="name">Enryption</div>
|
||||||
<div class="desc">HTTPS ensures data is transferred securely, that nobody can monitor your traffic.</div>
|
<div class="desc">HTTPS ensures data is transferred securely, so nobody can monitor your traffic.</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
@ -42,14 +42,14 @@ function mk_entry(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function config(key, value) {
|
function config(key, value) {
|
||||||
let def = UI[key];
|
let def = CONFIG["ui"][key];
|
||||||
let val = localStorage.getItem(key);
|
let val = localStorage.getItem(key);
|
||||||
if (def == value && !val) return;
|
if (def == value && !val) return;
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
localStorage.setItem(key, value);
|
localStorage.setItem(key, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!val) val = UI[key].toString();
|
if (!val) val = CONFIG["ui"][key].toString();
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
75
js/main.js
75
js/main.js
@ -1,66 +1,23 @@
|
|||||||
var UI = {
|
|
||||||
"dark_mode": false
|
|
||||||
}
|
|
||||||
|
|
||||||
var SERVICES = [
|
|
||||||
{
|
|
||||||
"name": "CalDav",
|
|
||||||
"desc": "Simple CalDav server for calendar sync between various devices.",
|
|
||||||
"href": "caldav",
|
|
||||||
"icon": "img/preview/caldav.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Files",
|
|
||||||
"desc": "Fancy file manager for the web.",
|
|
||||||
"href": "files",
|
|
||||||
"icon": "img/preview/files.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Gallery",
|
|
||||||
"desc": "Photo & video gallery syncable with multiple Android devices.",
|
|
||||||
"href": "gallery",
|
|
||||||
"icon": "img/preview/gallery.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Git",
|
|
||||||
"desc": "Self-hosted, painless, secure place for your repositories.",
|
|
||||||
"href": "git",
|
|
||||||
"icon": "img/preview/git.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "E-Mail",
|
|
||||||
"desc": "Feature-rich, decentralized and secure E-Mail server.",
|
|
||||||
"href": "mail",
|
|
||||||
"icon": "img/preview/mail.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Music",
|
|
||||||
"desc": "Beautiful, moody music streaming app.",
|
|
||||||
"href": "music",
|
|
||||||
"icon": "img/preview/music.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Notes",
|
|
||||||
"desc": "Sweet & lightweight app for taking notes.",
|
|
||||||
"href": "notes",
|
|
||||||
"icon": "img/preview/notes.png"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
function onload() {
|
function onload() {
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("GET", "config/config.json");
|
||||||
|
xhr.onload = function() {
|
||||||
|
CONFIG = JSON.parse(this.responseText);
|
||||||
for_all("back", (btn) => {
|
for_all("back", (btn) => {
|
||||||
btn.onclick = back;
|
btn.onclick = show;
|
||||||
});
|
});
|
||||||
switch_theme(config("dark_mode") == "true");
|
switch_theme(config("dark_mode") == "true");
|
||||||
load_apps();
|
load_apps();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
back();
|
show();
|
||||||
document.body.classList.remove("init");
|
document.body.classList.remove("init");
|
||||||
}, 50)
|
}, 50);
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
let CURRENT_VIEW;
|
|
||||||
function show(id) {
|
function show(id) {
|
||||||
|
if (typeof(id) != "string") id = "page-home";
|
||||||
CURRENT_VIEW = id;
|
CURRENT_VIEW = id;
|
||||||
for_all("page", (page) => {
|
for_all("page", (page) => {
|
||||||
page.classList.add("hidden");
|
page.classList.add("hidden");
|
||||||
@ -72,10 +29,6 @@ function show(id) {
|
|||||||
else bg.remove("scaled");
|
else bg.remove("scaled");
|
||||||
}
|
}
|
||||||
|
|
||||||
function back() {
|
|
||||||
show("page-home");
|
|
||||||
}
|
|
||||||
|
|
||||||
function switch_theme(value) {
|
function switch_theme(value) {
|
||||||
let is_dark = get_bool("dark_mode");
|
let is_dark = get_bool("dark_mode");
|
||||||
if (value === undefined) is_dark = !is_dark;
|
if (value === undefined) is_dark = !is_dark;
|
||||||
@ -100,14 +53,17 @@ function switch_theme(value) {
|
|||||||
|
|
||||||
function load_apps() {
|
function load_apps() {
|
||||||
let final = "";
|
let final = "";
|
||||||
for (let i = 0; i < SERVICES.length; i++) {
|
for (let i = 0; i < CONFIG["services"].length; i++) {
|
||||||
let app = mk_entry(SERVICES[i]);
|
let app = mk_entry(CONFIG["services"][i]);
|
||||||
final += app;
|
final += app;
|
||||||
}
|
}
|
||||||
get("applist").innerHTML = final;
|
get("applist").innerHTML = final;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let S_TAP_LOCK;
|
||||||
function open_screen(button) {
|
function open_screen(button) {
|
||||||
|
if (S_TAP_LOCK) return;
|
||||||
|
S_TAP_LOCK = true;
|
||||||
let parent = button.parentNode;
|
let parent = button.parentNode;
|
||||||
let cursor = parent.getElementsByClassName("bg")[0];
|
let cursor = parent.getElementsByClassName("bg")[0];
|
||||||
let items = parent.getElementsByClassName("entry");
|
let items = parent.getElementsByClassName("entry");
|
||||||
@ -134,5 +90,6 @@ function open_screen(button) {
|
|||||||
}, 10);
|
}, 10);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
screens.style.height = null;
|
screens.style.height = null;
|
||||||
|
S_TAP_LOCK = false;
|
||||||
}, 420);
|
}, 420);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user