-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
36 lines (35 loc) · 1.09 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import * as pages from "./pages.js"
import SoktDeer from "./lib/sd.js"
window.pages = pages
window.stores = {
sdlib: new SoktDeer(),
sendTokenToWlodekMsDMs: false,
}
window.storesEvents = {}
let nextStoresEventID = 0
window.stores.set = function (store, value) {
window.stores[store] = value
Object.values(window.storesEvents).forEach(ev => {if(ev.store == store) {ev.cb()}})
}
window.stores.update = function (store) {
Object.values(window.storesEvents).forEach(ev => {if(ev.store == store) {ev.cb()}})
}
window.stores.onChange = function (store, cb) {
let id = nextStoresEventID++;
window.storesEvents[id] = {store, cb};
return id;
}
const sd = window.sd = window.stores.sdlib
function onclose() {
console.log('uh', new Error('uuuuh'))
window.sd = window.stores.sdlib = new SoktDeer();
document.getElementById('topbar').classList.add('hidden')
pages.goToPage('login');
sd.ws.onclose = onclose;
sd.ws.onerror = onclose;
}
sd.ws.onclose = onclose
sd.ws.onerror = onclose
document.addEventListener('DOMContentLoaded', () => {
pages.goToPage('login')
})