stear/example/connect.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-06-09 16:36:21 +02:00
import { l1 } from "../stear/extras/loading1.js";
2022-06-09 16:26:27 +02:00
import { _ } from "../stear/main.js";
import { fadein, fadeout, wait } from "../stear/utils.js";
2022-06-09 16:36:21 +02:00
//import "./waitStyle.js";
2022-06-09 15:29:53 +02:00
export const preRender = true;
export const render = ({},{}) =>
_({find:"main"},[
_({type:"p",find:"text",style:{
position: "absolute",
minWidth: "90%",
textAlign: "center",
top: "25%",
left: "50%",
transform: "translate(-50%,-50%)",
}}),
_({style:{
position: "absolute",
left: "50%",
top: "50%",
transform: "translate(-50%, -50%)",
}},[
2022-06-09 16:36:21 +02:00
l1()
2022-06-09 15:29:53 +02:00
])
]);
2022-06-09 16:26:27 +02:00
export const call = async (stear, { find, resolve, render, call }, {name,id}) => {
2022-06-09 15:29:53 +02:00
find.text._.innerText = "Connecting to: " + name + " (" + id + ")";
await fadein(find.main._, 200, true);
//do connection
await wait(1000);
var success = Math.random()>0.25;
if(success){
alert("success");
await fadeout(find.main._);
return resolve(true);
}else{
alert("error");
await fadeout(find.main._);
return resolve(false);
}
}