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