Commit 5404eb9aac0d3f76707c6bf2fa5b57c55f46cb64
show menu for fixed tabs
Dominic Tarr committed on 8/14/2016, 2:11:23 AMParent: 7aaa1d8740dd0cb389adc4a35856345b8b7b8211
Files changed
modules/app.js | changed |
modules/network.js | changed |
modules/query.js | changed |
modules/tabs.js | changed |
modules/versions.js | added |
modules/app.js | ||
---|---|---|
@@ -1,11 +1,21 @@ | ||
1 | 1 | var plugs = require('../plugs') |
2 | 2 | var h = require('hyperscript') |
3 | 3 | |
4 | 4 | var screen_view = plugs.first(exports.screen_view = []) |
5 | +var menu_items = plugs.map(exports.menu_items = []) | |
5 | 6 | |
6 | 7 | var status = h('div.status.error') //start off disconnected |
8 | +var list = h('div.column', {style: 'display: none;'}) | |
7 | 9 | |
10 | +var menu = h('div.menu.row', list, status, { | |
11 | + onmouseover: function (e) { | |
12 | + list.style.display = 'flex' | |
13 | + }, onmouseout: function () { | |
14 | + list.style.display = 'none' | |
15 | + } | |
16 | +}) | |
17 | + | |
8 | 18 | exports.connection_status = function (err) { |
9 | 19 | if(err) status.classList.add('error') |
10 | 20 | else status.classList.remove('error') |
11 | 21 | } |
@@ -16,18 +26,23 @@ | ||
16 | 26 | } |
17 | 27 | |
18 | 28 | var view = screen_view(hash() || 'tabs') |
19 | 29 | |
20 | - var screen = h('div.screen.column', status, view) | |
30 | + var screen = h('div.screen.column', menu, view) | |
21 | 31 | |
32 | + menu_items().forEach(function (el) { | |
33 | + list.appendChild(el) | |
34 | + }) | |
35 | + | |
22 | 36 | window.onhashchange = function (ev) { |
23 | 37 | var _view = view |
24 | 38 | view = screen_view(hash() || 'tabs') |
25 | 39 | |
26 | 40 | if(_view) screen.replaceChild(view, _view) |
27 | 41 | else document.body.appendChild(view) |
28 | 42 | } |
29 | 43 | |
44 | + | |
30 | 45 | return screen |
31 | 46 | |
32 | 47 | } |
33 | 48 | |
@@ -49,4 +64,9 @@ | ||
49 | 64 | |
50 | 65 | |
51 | 66 | |
52 | 67 | |
68 | + | |
69 | + | |
70 | + | |
71 | + | |
72 | + |
modules/network.js | ||
---|---|---|
@@ -12,8 +12,12 @@ | ||
12 | 12 | function legacyToMultiServer(addr) { |
13 | 13 | return 'net:'+addr.host + ':'+addr.port + '~shs:'+addr.key.substring(1).replace('.ed25519','') |
14 | 14 | } |
15 | 15 | |
16 | +exports.menu_items = function () { | |
17 | + return h('a', {href: '#/network'}, '/network') | |
18 | +} | |
19 | + | |
16 | 20 | exports.screen_view = function (path) { |
17 | 21 | |
18 | 22 | if(path !== '/network') return |
19 | 23 |
modules/query.js | ||
---|---|---|
@@ -3,8 +3,12 @@ | ||
3 | 3 | var HJSON = require('hjson') |
4 | 4 | |
5 | 5 | var sbot_query = require('../plugs').first(exports.sbot_query = []) |
6 | 6 | |
7 | +exports.menu_items = function () { | |
8 | + return h('a', {href:'#/query'}, '/query') | |
9 | +} | |
10 | + | |
7 | 11 | exports.screen_view = function (path) { |
8 | 12 | if(path != '/query') return |
9 | 13 | var output, status, editor, stream, query |
10 | 14 |
modules/tabs.js | ||
---|---|---|
@@ -60,9 +60,9 @@ | ||
60 | 60 | |
61 | 61 | // tabs.select(sessionStorage.selectedTab || saved[0] || '/public') |
62 | 62 | tabs.select('/public') |
63 | 63 | |
64 | - tabs.onclick = function (ev) { | |
64 | + window.onclick = function (ev) { | |
65 | 65 | var link = ancestor(ev.target) |
66 | 66 | if(!link) return |
67 | 67 | var path = link.hash.substring(1) |
68 | 68 | |
@@ -103,9 +103,9 @@ | ||
103 | 103 | return tabs.selectedTab.scroll(-1) |
104 | 104 | |
105 | 105 | // close a tab |
106 | 106 | case 88: // x |
107 | - if (tabs.selected && tabs.selected[0] !== '/') { | |
107 | + if (tabs.selected/* && tabs.selected[0] !== '/'*/) { | |
108 | 108 | var sel = tabs.selected |
109 | 109 | tabs.selectRelative(-1) |
110 | 110 | tabs.remove(sel) |
111 | 111 | // localStorage.openTabs = JSON.stringify(tabs.tabs) |
modules/versions.js | ||
---|---|---|
@@ -1,0 +1,36 @@ | ||
1 | +var h = require('hyperscript') | |
2 | + | |
3 | +exports.menu_items = function () { | |
4 | + return h('a', {href: '#/versions'}, '/versions') | |
5 | +} | |
6 | + | |
7 | +exports.screen_view = function (path) { | |
8 | + if(path !== '/versions') return | |
9 | + | |
10 | + if('undefined' === typeof WebBoot) | |
11 | + return h('h1', 'must run with web-boot enabled enviroment') | |
12 | + | |
13 | + var content = h('div.column') | |
14 | + | |
15 | + WebBoot.versions(function (err, log) { | |
16 | + log.forEach(function (e, i) { | |
17 | + content.appendChild( | |
18 | + h('div.row', | |
19 | + h('a', { | |
20 | + href: '#/run:'+e.value, | |
21 | + onclick: function () { | |
22 | + WebBoot.run(e.value, function () { | |
23 | + console.log('rebooting to:', e.value) | |
24 | + }) | |
25 | + } | |
26 | + }, ' ', e.value, ' ', new Date(e.ts)), | |
27 | + !i && h('label', '(current)') | |
28 | + ) | |
29 | + ) | |
30 | + }) | |
31 | + | |
32 | + }) | |
33 | + | |
34 | + return content | |
35 | +} | |
36 | + |
Built with git-ssb-web