Files: cd6e506aae3237ded96821ca6f44a51db495f302 / modules_core / app.js
1158 bytesRaw
1 | var plugs = require('../plugs') |
2 | var h = require('hyperscript') |
3 | var insertCss = require('insert-css') |
4 | |
5 | module.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