-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
56 lines (47 loc) · 1.06 KB
/
index.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import m from '/vendor/mithril.js'
import hs from './hashstore.js'
import w from './wrapper.js'
const {log, warn} = console,
{ stringify, parse} = JSON
let wrapper, runtime = {}
document.title = 'apps@'+self.location.host
hs.on = () => {
if (!hs.get()) {
hs.put({a: self.location.hash.slice(1)})
}
wrapper.store = hs.get()?.s
try {
wrapper.query = parse(hs.get()?.q)
} catch (ex) {
warn(ex.message)
}
}
let info
const index = {
oninit: () => {
if (!hs.get()) {
hs.put({a: self.location.hash.slice(1)})
}
},
view: () => m('div', {
run: document.title = hs.get()?.a+ '@'+ self.location.host
},
m('gem-wrapper', {
oncreate({dom}) {
wrapper = dom
wrapper.store = hs.get()?.s
try {
wrapper.query = parse(hs.get()?.q)
} catch (ex) {
warn(ex.message)
}
},
onchange: ({target}) => {
if (target.tagName!='GEM-WRAPPER') return
hs.put({s: target.store})
},
app: hs.get()?.a
})
)
}
m.mount(document.body, index)