Files: 37f3988939c642326f7aebf2dadb5fc1b87581f1 / modules / app.js
1090 bytesRaw
1 | var h = require('hyperscript') |
2 | |
3 | module.exports = { |
4 | needs: {screen_view: 'first'}, |
5 | gives: 'app', |
6 | create: function (api) { |
7 | return function () { |
8 | document.head.appendChild(h('style', require('minbase/style.css.json'))) |
9 | document.head.appendChild(h('style', require('../deck.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