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
|
function threadPage (src, keys) {
get(src).then(msg => {
open(msg).then(post => {
scroller.appendChild(render(post, keys))
})
})
}
function profilePage (src, keys) {
var server = 'ws://localhost:8080/'
sync(src, server, keys)
bog(src).then(log => {
if (log) {
log.forEach(function (msg) {
open(msg).then(post => {
scroller.appendChild(render(post, keys))
})
})
}
})
}
function publicPage (keys) {
scroller.appendChild(composer(keys))
bog().then(log => {
log.forEach(function (msg) {
open(msg).then(post => {
scroller.appendChild(render(post, keys))
})
})
})
}
function keyPage (keys) {
var message = h('div', {classList: 'message'})
message.appendChild(h('p', {innerHTML: marked('This is your ed25519 public/private keypair. It was generated using [TweetNaCl.js](https://tweetnacl.js.org/#/). Your public key is your identity when using [Bogbook](http://bogbook.com/), save your key in a safe place so that you can continue to use the same identity.')}))
message.appendChild(h('pre', {style: 'width: 80%'}, [h('code', [JSON.stringify(keys)])]))
message.appendChild(h('button', {
onclick: function () {
localforage.removeItem('id', function () {
location.hash = ''
location.reload()
})
}
}, ['Delete Key']))
var textarea = h('textarea', {placeholder: 'Import your existing ed25519 keypair'})
message.appendChild(textarea)
message.appendChild(h('button', {
onclick: function () {
if (textarea.value) {
localforage.setItem('id', JSON.parse(textarea.value))
location.reload()
}
}
}, ['Import Key']))
scroller.appendChild(message)
}
|