2022-11-03 22:12:53 +01:00
|
|
|
import l1 from "../../stear/extra/Elements/loading1.js";
|
|
|
|
import showStatus from "../../stear/extra/Pages/showStatus.js";
|
|
|
|
import { Stear, SWindow, _ } from "../../stear/main.js";
|
|
|
|
import { fadein, fadeout, wait } from "../../stear/utils.js";
|
2022-06-09 15:29:53 +02:00
|
|
|
|
2022-08-13 17:52:45 +02:00
|
|
|
const pool = Stear.addLanguagePool("connect");
|
|
|
|
const connectingto = pool.add("connectingto", "Connecting to: {} ({})");
|
|
|
|
const connected = pool.add("connected", "connected");
|
|
|
|
const connecterror = pool.add("connecterror", "Error while Connecting to: {}");
|
|
|
|
|
|
|
|
export const call = async (stear, { find, resolve, render, call, event }, {name,id}) => {
|
|
|
|
|
|
|
|
event.onloaded = async ()=>{
|
|
|
|
await fadein(find.main, 200, true);
|
|
|
|
//do connection
|
|
|
|
await wait(1000);
|
|
|
|
if (Math.random() > 0.25) {
|
|
|
|
|
|
|
|
call(showStatus, { text: connected });
|
|
|
|
|
|
|
|
return resolve(true);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
call(showStatus, { text: connecterror.r(name), color: "red" });
|
|
|
|
|
|
|
|
return resolve(false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
event.onresolve = async ()=>{
|
|
|
|
await fadeout(find.main);
|
2022-06-09 15:29:53 +02:00
|
|
|
}
|
2022-08-13 17:52:45 +02:00
|
|
|
|
|
|
|
return _({ find: "main" }, [
|
|
|
|
_({
|
|
|
|
type: "p",
|
|
|
|
style: {
|
|
|
|
position: "absolute",
|
|
|
|
minWidth: "90%",
|
|
|
|
textAlign: "center",
|
|
|
|
top: "25%",
|
|
|
|
left: "50%",
|
|
|
|
transform: "translate(-50%,-50%)",
|
|
|
|
}
|
|
|
|
}, connectingto.r(name, id)),
|
|
|
|
_({
|
|
|
|
style: {
|
|
|
|
position: "absolute",
|
|
|
|
left: "50%",
|
|
|
|
top: "50%",
|
|
|
|
transform: "translate(-50%, -50%)",
|
|
|
|
}
|
|
|
|
}, l1())
|
|
|
|
]);
|
2022-06-09 15:29:53 +02:00
|
|
|
}
|
2022-08-13 17:52:45 +02:00
|
|
|
|
|
|
|
export default new SWindow({ preRender: true, call, backgroundColor: "#dde" });
|