underbbs/src/index.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-04-22 00:32:14 +00:00
import adapter from "./adapter";
2024-04-22 00:02:44 +00:00
let adapters = [];
2024-04-22 00:32:14 +00:00
function $(id) {
return document.getElementById(id);
}
2024-04-22 00:02:44 +00:00
function main() {
2024-04-22 00:32:14 +00:00
let settings = JSON.parse(localStorage.getItem("settings"));;
2024-04-22 00:02:44 +00:00
if (settings != null) {
for (let s of settings.adapters) {
switch (s.protocol) {
case "nostr":
2024-04-22 00:32:14 +00:00
let a = adapter.toNostrAdapter(adapter.createAdapter(), s);
2024-04-22 00:02:44 +00:00
adapters.push(a);
break;
}
}
} else {
console.log("no settings exist for this client");
}
};
2024-04-22 00:32:14 +00:00
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;
2024-04-22 00:02:44 +00:00
main();