git ssb

16+

Dominic / patchbay



Tree: 010c28ba45ecc8a029b813a3cd9e7edc8e098059

Files: 010c28ba45ecc8a029b813a3cd9e7edc8e098059 / modules_core / app.js

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

Built with git-ssb-web