-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.js
98 lines (89 loc) · 2.41 KB
/
settings.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { h } from 'h'
import { bogbot } from 'bogbot'
import { nameDiv, avatarSpan } from './profile.js'
export const importKey = async () => {
const textarea = h('textarea', {placeholder: 'Keypair'})
const button = h('button', {
onclick: async () => {
const trashkey = await bogbot.generate()
if (textarea.value && textarea.value.length === trashkey.length) {
await bogbot.put('keypair', textarea.value)
window.location.hash = '#'
location.reload()
} else { alert('Invalid Keypair')}
}
}, ['Import key'])
const div = h('div', {classList: 'message'}, [
textarea,
button
])
return div
}
const editKey = async () => {
const textarea = h('textarea', [await bogbot.keypair()])
const span = h('span', [
textarea,
h('button', {
onclick: async () => {
const keypair = await bogbot.keypair()
if (textarea.value.length === keypair.length) {
await bogbot.put('keypair', textarea.value)
window.location.hash = '#'
location.reload()
} else { alert('Invalid Keypair')}
}
}, ['Import key']),
h('button', {
onclick: async () => {
await bogbot.deletekey()
window.location.hash = '#'
location.reload()
}
}, ['Delete key']),
h('button', {
onclick: async () => {
await bogbot.clear()
window.location.hash = '#'
location.reload()
}
}, ['Delete everything'])
])
return span
}
//const didweb = async () => {
// const input = h('input', {placeholder: 'https://yourwebsite.com/'})
// const get = await bogbot.get('didweb')
// if (get) {input.placeholder = get}
//
// return h('div', [
// input,
// h('button', {onclick: async () => {
// if (input.value) {
// const check = await fetch(input.value + '/keys', {
// method: 'get',
// mode: 'no-cors',
// headers: {
// 'Access-Control-Allow-Origin' : '*'
// }
// })
// if (check) { console.log(await check.text()) }
// }
// }}, ['Verify'])
// ])
//}
export const settings = async () => {
const div = h('div', {classList: 'message'}, [
h('p', ['Upload photo']),
await avatarSpan(),
h('hr'),
h('p', ['New name']),
await nameDiv(),
h('hr'),
//h('p', ['Did:web']),
//await didweb(),
//h('hr'),
h('p', ['Import Keypair']),
await editKey()
])
return div
}