-
Notifications
You must be signed in to change notification settings - Fork 11
/
script.go
78 lines (58 loc) · 1.23 KB
/
script.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package popup
import (
"qlova.org/seed"
"qlova.org/seed/client"
)
func init() {
client.RegisterRenderer(func(c seed.Seed) []byte {
return []byte(`
seed.CurrentPopup = null;
seed.show = async function(id, args) {
let popup = q.get(id);
if (!popup) {
console.error("seed.show: invalid popup ", id);
return;
}
popup.template = popup.parent;
popup.parent.parentElement.appendChild(popup);
seed.CurrentPopup = popup;
popup.args = args;
if (popup.onshow) await popup.onshow();
let promises = [];
if (seed.goto.in) {
promises.push(seed.goto.in);
seed.goto.in = null;
}
if (seed.goto.out) {
promises.push(seed.goto.out);
seed.goto.out = null;
}
for (let promise of promises) {
await promise;
}
};
seed.hide = async function(id) {
let popup = q.get(id);
if (!popup) {
console.error("seed.show: invalid popup ", id);
return;
}
if (!popup.template) return;
if (popup.onhide) await popup.onhide();
let promises = [];
if (seed.goto.in) {
promises.push(seed.goto.in);
seed.goto.in = null;
}
if (seed.goto.out) {
promises.push(seed.goto.out);
seed.goto.out = null;
}
for (let promise of promises) {
await promise;
}
seed.CurrentPopup = null;
popup.template.content.appendChild(popup);
};`)
})
}