git ssb

16+

Dominic / patchbay



Tree: 7470f29e565172555b9c2e102a58e88dd52a2d6a

Files: 7470f29e565172555b9c2e102a58e88dd52a2d6a / modules_core / app.js

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

Built with git-ssb-web