mirror of
https://github.com/khairul169/honey.git
synced 2025-04-28 14:59:32 +07:00
Make it working with no cookies
This commit is contained in:
parent
1c637efae3
commit
be40d9642f
@ -13,7 +13,7 @@ This will be a dashboard hosted on my homeserver with self-hosted stuff. But, fo
|
||||
- [ ] Fix blur flicker on showing/hiding pages
|
||||
- [x] Open in new tab setting
|
||||
- [x] Better icon colors in 'More' page
|
||||
- [ ] Work with blocked cookies
|
||||
- [x] Work with blocked cookies
|
||||
- [ ] Minor code optimizations
|
||||
|
||||
blah blah blah
|
@ -389,4 +389,11 @@ a.box {
|
||||
}
|
||||
.hostedby b {
|
||||
color: #56F;
|
||||
}
|
||||
.warn {
|
||||
margin: 8px 0;
|
||||
color: #F60;
|
||||
}
|
||||
.none {
|
||||
display: none;
|
||||
}
|
@ -92,6 +92,7 @@
|
||||
<div class="hostedby">All services hosted by <b id="app-hostedby"></b></div>
|
||||
</div>
|
||||
<div class="screen hidden">
|
||||
<div class="warn none" id="nocook">WARNING: due to blocked cookies, all settings will be lost after page reload</div>
|
||||
<div class="settings">
|
||||
<div class="setting" onclick="switch_theme()" id="setting-theme">
|
||||
<div class="icon">dark_mode</div>
|
||||
|
30
js/dom.js
30
js/dom.js
@ -46,16 +46,26 @@ function mk_entry(app) {
|
||||
</a>`;
|
||||
}
|
||||
|
||||
function config(key, value) {
|
||||
let def = CONFIG["ui"][key];
|
||||
let val = localStorage.getItem(key);
|
||||
if (def == value && !val) return;
|
||||
if (value !== undefined) {
|
||||
localStorage.setItem(key, value);
|
||||
return;
|
||||
function check_cookies() {
|
||||
try {
|
||||
localStorage;
|
||||
return true;
|
||||
}
|
||||
if (!val) val = CONFIG["ui"][key].toString();
|
||||
return val;
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function config(key, value) {
|
||||
let write = value !== undefined;
|
||||
if (check_cookies()) {
|
||||
let val = localStorage.getItem(key);
|
||||
if (CONFIG["ui"][key] == value && !val) return;
|
||||
if (write) localStorage.setItem(key, value);
|
||||
return val;
|
||||
}
|
||||
if (write) CONFIG["ui"][key] = value.toString();
|
||||
return CONFIG["ui"][key].toString();
|
||||
}
|
||||
|
||||
function get_bool(key) {
|
||||
@ -63,11 +73,13 @@ function get_bool(key) {
|
||||
}
|
||||
|
||||
function load_config(conf) {
|
||||
CONFIG_DEFAULT = conf;
|
||||
if (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 (!check_cookies()) get("nocook").classList.remove("none");
|
||||
if (ui.hosted_by) set("app-hostedby", ui.hosted_by);
|
||||
else get("app-hostedby").parentNode.style.display = "none";
|
||||
load_apps();
|
||||
|
@ -74,8 +74,8 @@ function new_tab_toggle(value) {
|
||||
}
|
||||
|
||||
function reset_all_settings() {
|
||||
localStorage.clear();
|
||||
load_config();
|
||||
if (check_cookies()) localStorage.clear();
|
||||
load_config(CONFIG_DEFAULT);
|
||||
}
|
||||
|
||||
let S_TAP_LOCK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user