placeholder for settings dialogue
This commit is contained in:
parent
343cdbd3b5
commit
03f776e634
2 changed files with 37 additions and 3 deletions
1
dist/index.html
vendored
1
dist/index.html
vendored
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><a href="#" onclick="showSettings()">settings</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<main>
|
<main>
|
||||||
|
|
39
src/index.js
39
src/index.js
|
@ -1,14 +1,18 @@
|
||||||
import { createAdapter, toNostrAdapter } from "./adapter";
|
import adapter from "./adapter";
|
||||||
|
|
||||||
let adapters = [];
|
let adapters = [];
|
||||||
|
|
||||||
|
function $(id) {
|
||||||
|
return document.getElementById(id);
|
||||||
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
let settings = localStorage.getItem("settings");
|
let settings = JSON.parse(localStorage.getItem("settings"));;
|
||||||
if (settings != null) {
|
if (settings != null) {
|
||||||
for (let s of settings.adapters) {
|
for (let s of settings.adapters) {
|
||||||
switch (s.protocol) {
|
switch (s.protocol) {
|
||||||
case "nostr":
|
case "nostr":
|
||||||
let a = toNostrAdapter(createAdapter(), s);
|
let a = adapter.toNostrAdapter(adapter.createAdapter(), s);
|
||||||
adapters.push(a);
|
adapters.push(a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -18,4 +22,33 @@ function main() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function showSettings() {
|
||||||
|
// tab bar hidden
|
||||||
|
let tabbar = $("tabbar");
|
||||||
|
tabbar.style.display = "none";
|
||||||
|
|
||||||
|
// tabcontent to show settings ui
|
||||||
|
let tabcontent = $("tabcontent");
|
||||||
|
|
||||||
|
tabcontent.innerHTML = "<p>this is our settings dialogue</p>";
|
||||||
|
tabcontent.innerHTML += "<button onclick='saveSettings()'>save</button>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveSettings() {
|
||||||
|
if (window.settings) {
|
||||||
|
localStorage.setItem("settings", JSON.stringify(window.settings));
|
||||||
|
}
|
||||||
|
// tab bar hidden
|
||||||
|
let tabbar = $("tabbar");
|
||||||
|
tabbar.style.display = "block";
|
||||||
|
|
||||||
|
// tabcontent to show settings ui
|
||||||
|
let tabcontent = $("tabcontent");
|
||||||
|
tabcontent.innerHTML = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
window.showSettings = showSettings;
|
||||||
|
window.saveSettings = saveSettings;
|
||||||
|
|
||||||
main();
|
main();
|
Loading…
Reference in a new issue