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