git ssb

1+

ev / minbay



Tree: afe7de9580840925af61711b5ab0d6c57d1131a4

Files: afe7de9580840925af61711b5ab0d6c57d1131a4 / modules / app.js

1089 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 // console.log(hash() || 'tabs')
23 var view = api.screen_view(hash() || 'tabs')
24
25 var screen = h('div.screen.column', view)
26
27 window.onhashchange = function (ev) {
28 var _view = view
29 view = api.screen_view(hash() || 'tabs')
30
31 if(_view) screen.replaceChild(view, _view)
32 else document.body.appendChild(view)
33 }
34
35 document.body.appendChild(screen)
36 return screen
37 }
38 }
39}
40
41
42

Built with git-ssb-web