66 lines
1.5 KiB
JavaScript
66 lines
1.5 KiB
JavaScript
/** @import * as TYPES from "./graph/types.ts" */
|
|
import * as FSHandle from "./store-directory-handle.js";
|
|
|
|
const {Div, DOM} = Gale({
|
|
Title:{
|
|
padding:"2rem",
|
|
background: "blue",
|
|
color:"white"
|
|
},
|
|
Plain:{}
|
|
})
|
|
|
|
/** @type {Van.State<Record<string, TYPES.GraphParts>>} */
|
|
const rooms = van.state({});
|
|
|
|
async function EvaluateHandle()
|
|
{
|
|
try
|
|
{
|
|
const module = await import("./data/room.js"+"?rand="+Math.random());
|
|
/** @type {Record<string, TYPES.GraphParts>} */
|
|
const read = module.default();
|
|
console.log("rooms found:", read);
|
|
rooms.val = read;
|
|
}
|
|
catch(e)
|
|
{
|
|
console.log("rooms read error:", e);
|
|
rooms.val = {};
|
|
}
|
|
}
|
|
let handle = await FSHandle.getDirectoryHandle();
|
|
EvaluateHandle();
|
|
|
|
/** @type {(pass:TYPES.Pass)=>HTMLElement} */
|
|
function Pass(pass)
|
|
{
|
|
return Div.Plain(
|
|
Div.Title(
|
|
DOM.span.Plain(pass.name),
|
|
DOM.span.Plain(pass.path),
|
|
)
|
|
)
|
|
}
|
|
|
|
|
|
function App()
|
|
{
|
|
return Div.Plain(
|
|
DOM.button({
|
|
async onclick(){
|
|
handle = await showDirectoryPicker();
|
|
await FSHandle.setDirectoryHandle(handle);
|
|
EvaluateHandle();
|
|
}
|
|
}, "Pick Directory"),
|
|
Object.entries(rooms.val).map(([room_id, graphParts])=>
|
|
Object.entries(graphParts.Pass).map(([pass_id, pass])=>{
|
|
return Pass(pass)
|
|
})
|
|
)
|
|
)
|
|
}
|
|
|
|
van.add(document.body, App);
|