Files: afe7de9580840925af61711b5ab0d6c57d1131a4 / modules / menu.js
716 bytesRaw
1 | var plugs = require('../plugs') |
2 | var h = require('hyperscript') |
3 | |
4 | module.exports = { |
5 | needs: {menu_items: 'map'}, |
6 | gives: {connection_status: true, menu: true}, |
7 | create: function (api) { |
8 | var menu_items = api.menu_items |
9 | |
10 | var status = h('div.status.error') |
11 | var list = h('div.menu.column') |
12 | |
13 | var menu = h('div.column', status, list) |
14 | |
15 | setTimeout(function () { |
16 | menu_items().forEach(function (el) { |
17 | if(el) |
18 | list.appendChild(el) |
19 | }) |
20 | }, 0) |
21 | |
22 | return { |
23 | connection_status: function (err) { |
24 | if(err) status.classList.add('error') |
25 | else status.classList.remove('error') |
26 | }, |
27 | menu: function () { |
28 | return menu |
29 | } |
30 | } |
31 | } |
32 | } |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 |
Built with git-ssb-web