git ssb

0+

ev / minbase



Tree: b62ecd6f843b26f37e70c7b6d65c71db35bbf922

Files: b62ecd6f843b26f37e70c7b6d65c71db35bbf922 / modules / app.js

1044 bytesRaw
1var plugs = require('../plugs')
2var h = require('hyperscript')
3
4module.exports = {
5 needs: {screen_view: 'first'},
6 gives: 'app',
7 create: function (api) {
8 return function () {
9 document.head.appendChild(h('style', require('../style.css.json')))
10
11 window.addEventListener('error', window.onError = function (e) {
12 document.body.appendChild(h('div.error',
13 h('h1', e.message),
14 h('big', h('code', e.filename + ':' + e.lineno)),
15 h('pre', e.error ? (e.error.stack || e.error.toString()) : e.toString())))
16 })
17
18 function hash() {
19 return window.location.hash.substring(1)
20 }
21
22 var view = api.screen_view(hash() || 'tabs')
23
24 var screen = h('div.screen.column', view)
25
26 window.onhashchange = function (ev) {
27 var _view = view
28 view = api.screen_view(hash() || 'tabs')
29 if(_view) screen.replaceChild(view, _view)
30 else document.body.appendChild(view)
31 }
32
33 document.body.appendChild(screen)
34 return screen
35 }
36 }
37}
38
39
40

Built with git-ssb-web