https://domlink.deployments.hotsocket.fyi/
at main 29 lines 763 B view raw
1import { Row, Button, Column, Node } from "./domlink.ts"; 2 3// extra little handy things i guess. 4export async function timeout<T>(time: number, promise: Promise<T>): Promise<T> { 5 const result = await Promise.race([new Promise<null>(r=>setTimeout(r, time, null)), promise]); 6 if (result == null) { 7 throw new Error("timeout"); 8 } 9 return result; 10} 11 12function webFrame(url: string) { 13 const frame = document.createElement("iframe"); 14 frame.src = url; 15 frame.style.width = "100%"; 16 frame.style.height = "100%"; 17 const controls = new Row().with( 18 "Web Frame Controls:", 19 new Button("reload", ()=>{frame.contentWindow?.location.reload();}) 20 ); 21 22 return new Column().with( 23 controls, 24 new Node(frame) 25 ).style((s)=>{ 26 s.width = "100%"; 27 s.height = "100%"; 28 }); 29}