git ssb

16+

Dominic / patchbay



Commit 5591d62273ed583826be5ee98988e41448189131

test if we are in the browser before trying to access DOM

Dominic Tarr committed on 9/28/2016, 5:34:00 AM
Parent: 5f6e9b441698b112f61c602d52d80a419f953a73

Files changed

modules/app.jschanged
modules/theme.jschanged
modules/app.jsView
@@ -4,8 +4,17 @@
44 var screen_view = plugs.first(exports.screen_view = [])
55
66
77 exports.app = function () {
8 + document.head.appendChild(h('style', require('../style.css.json')))
9 +
10 + window.addEventListener('error', window.onError = function (e) {
11 + document.body.appendChild(h('div.error',
12 + h('h1', e.message),
13 + h('big', h('code', e.filename + ':' + e.lineno)),
14 + h('pre', e.error ? (e.error.stack || e.error.toString()) : e.toString())))
15 + })
16 +
817 function hash() {
918 return window.location.hash.substring(1)
1019 }
1120
@@ -20,8 +29,9 @@
2029 if(_view) screen.replaceChild(view, _view)
2130 else document.body.appendChild(view)
2231 }
2332
33 + document.body.appendChild(screen)
2434
2535 return screen
2636
2737 }
@@ -54,4 +64,5 @@
5464
5565
5666
5767
68 +
modules/theme.jsView
@@ -13,9 +13,11 @@
1313 }
1414
1515 var next = 'undefined' === typeof setImmediate ? setTimeout : setImmediate
1616
17-var link = document.head.appendChild(h('link', {rel: 'stylesheet'}))
17 +if('undefined' === typeof document)
18 + var link = document.head.appendChild(h('link', {rel: 'stylesheet'}))
19 +
1820 var activeTheme
1921
2022 function useTheme(id) {
2123 activeTheme = id
@@ -147,4 +149,5 @@
147149
148150 exports.screen_view = function (path) {
149151 if(path === '/theme') return theme_view()
150152 }
153 +

Built with git-ssb-web