git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit 5404eb9aac0d3f76707c6bf2fa5b57c55f46cb64

show menu for fixed tabs

Dominic Tarr committed on 8/14/2016, 2:11:23 AM
Parent: 7aaa1d8740dd0cb389adc4a35856345b8b7b8211

Files changed

modules/app.jschanged
modules/network.jschanged
modules/query.jschanged
modules/tabs.jschanged
modules/versions.jsadded
modules/app.jsView
@@ -1,11 +1,21 @@
11 var plugs = require('../plugs')
22 var h = require('hyperscript')
33
44 var screen_view = plugs.first(exports.screen_view = [])
5+var menu_items = plugs.map(exports.menu_items = [])
56
67 var status = h('div.status.error') //start off disconnected
8+var list = h('div.column', {style: 'display: none;'})
79
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+
818 exports.connection_status = function (err) {
919 if(err) status.classList.add('error')
1020 else status.classList.remove('error')
1121 }
@@ -16,18 +26,23 @@
1626 }
1727
1828 var view = screen_view(hash() || 'tabs')
1929
20- var screen = h('div.screen.column', status, view)
30+ var screen = h('div.screen.column', menu, view)
2131
32+ menu_items().forEach(function (el) {
33+ list.appendChild(el)
34+ })
35+
2236 window.onhashchange = function (ev) {
2337 var _view = view
2438 view = screen_view(hash() || 'tabs')
2539
2640 if(_view) screen.replaceChild(view, _view)
2741 else document.body.appendChild(view)
2842 }
2943
44+
3045 return screen
3146
3247 }
3348
@@ -49,4 +64,9 @@
4964
5065
5166
5267
68+
69+
70+
71+
72+
modules/network.jsView
@@ -12,8 +12,12 @@
1212 function legacyToMultiServer(addr) {
1313 return 'net:'+addr.host + ':'+addr.port + '~shs:'+addr.key.substring(1).replace('.ed25519','')
1414 }
1515
16+exports.menu_items = function () {
17+ return h('a', {href: '#/network'}, '/network')
18+}
19+
1620 exports.screen_view = function (path) {
1721
1822 if(path !== '/network') return
1923
modules/query.jsView
@@ -3,8 +3,12 @@
33 var HJSON = require('hjson')
44
55 var sbot_query = require('../plugs').first(exports.sbot_query = [])
66
7+exports.menu_items = function () {
8+ return h('a', {href:'#/query'}, '/query')
9+}
10+
711 exports.screen_view = function (path) {
812 if(path != '/query') return
913 var output, status, editor, stream, query
1014
modules/tabs.jsView
@@ -60,9 +60,9 @@
6060
6161 // tabs.select(sessionStorage.selectedTab || saved[0] || '/public')
6262 tabs.select('/public')
6363
64- tabs.onclick = function (ev) {
64+ window.onclick = function (ev) {
6565 var link = ancestor(ev.target)
6666 if(!link) return
6767 var path = link.hash.substring(1)
6868
@@ -103,9 +103,9 @@
103103 return tabs.selectedTab.scroll(-1)
104104
105105 // close a tab
106106 case 88: // x
107- if (tabs.selected && tabs.selected[0] !== '/') {
107+ if (tabs.selected/* && tabs.selected[0] !== '/'*/) {
108108 var sel = tabs.selected
109109 tabs.selectRelative(-1)
110110 tabs.remove(sel)
111111 // localStorage.openTabs = JSON.stringify(tabs.tabs)
modules/versions.jsView
@@ -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