Files: d9ba09fe7118718dfeddc73ddab338839d9e78c7 / modules_extra / key.js
1880 bytesRaw
1 | var h = require('hyperscript') |
2 | |
3 | exports.gives = { |
4 | menu_items: true, screen_view: true |
5 | } |
6 | |
7 | exports.create = function (api) { |
8 | return { |
9 | menu_items: function () { |
10 | return h('a', {href: '#/key'}, '/key') |
11 | }, |
12 | screen_view: function (path, sbot) { |
13 | if(path === '/key') { |
14 | if(process.title === 'browser') { |
15 | var importKey = h('textarea', {placeholder: 'import an existing public/private key', name: 'textarea'}) |
16 | var importRemote = h('textarea', {placeholder: 'import an existing remote', name: 'textarea'}) |
17 | |
18 | return h('div.column.scroller', |
19 | {style: {'overflow':'auto'}}, |
20 | h('div.scroller__wrapper', |
21 | h('div.column.scroller__content', |
22 | h('div.message', |
23 | h('p', {innerHTML: 'Your secret key is: <pre><code>' + localStorage['browser/.ssb/secret'] + '</code></pre>'}), |
24 | h('form', |
25 | importKey, |
26 | h('button', {onclick: function (e){ |
27 | localStorage['browser/.ssb/secret'] = importKey.value.replace(/\s+/g, ' ') |
28 | alert('Your public/private key has been updated') |
29 | e.preventDefault() |
30 | }}, 'Import'), |
31 | h('p', {innerHTML: 'Your ws remote is: <pre>' + localStorage.remote + '</pre>'}), |
32 | h('form', |
33 | importRemote, |
34 | h('button', {onclick: function (e){ |
35 | localStorage.remote = importRemote.value |
36 | alert('Your websocket remote has been updated') |
37 | e.preventDefault() |
38 | }}, 'Import') |
39 | ) |
40 | ) |
41 | ) |
42 | ) |
43 | ) |
44 | ) |
45 | } else { |
46 | return h('p', 'Your key is saved at .ssb/secret') |
47 | } |
48 | } |
49 | } |
50 | } |
51 | } |
52 | |
53 |
Built with git-ssb-web