Files: 392e50fcc67f4ad4b873fc95b096e3018404f255 / index.js
1786 bytesRaw
1 | var h = require('hyperscript') |
2 | var route = require('./views') |
3 | var avatar = require('./avatar') |
4 | |
5 | var compose = require('./compose') |
6 | |
7 | var id = require('./keys').id |
8 | |
9 | document.head.appendChild(h('style', require('./style.css.json'))) |
10 | |
11 | var screen = h('div#screen') |
12 | |
13 | var search = h('input.search', {placeholder: 'Search'}) |
14 | |
15 | var nav = h('div.navbar', |
16 | h('div.internal', |
17 | h('li', h('a', {href: '#' + id}, h('span.avatar--small', avatar.image(id)))), |
18 | h('li', h('a', {href: '#' + id}, avatar.name(id))), |
19 | h('li', h('a', 'Compose', { |
20 | onclick: function () { |
21 | if (document.getElementById('composer')) { return } |
22 | else { |
23 | var currentScreen = document.getElementById('screen') |
24 | var opts = {} |
25 | opts.type = 'post' |
26 | var composer = h('div.content#composer', h('div.message', compose(opts))) |
27 | if (currentScreen.firstChild.firstChild) { |
28 | currentScreen.firstChild.insertBefore(composer, currentScreen.firstChild.firstChild) |
29 | } else { |
30 | currentScreen.firstChild.appendChild(composer) |
31 | } |
32 | } |
33 | } |
34 | })), |
35 | h('li', h('a', {href: '#' }, 'All')), |
36 | h('li', h('a', {href: '#private' }, 'Private')), |
37 | h('li', h('a', {href: '#mentions' }, 'Mentions')), |
38 | h('li', h('a', {href: '#key' }, 'Key')), |
39 | h('li.right', h('a', {href: '#about'}, '?')), |
40 | h('form.search', { |
41 | onsubmit: function (e) { |
42 | window.location.hash = '?' + search.value |
43 | e.preventDefault() |
44 | }}, |
45 | search |
46 | ) |
47 | ) |
48 | ) |
49 | |
50 | document.body.appendChild(nav) |
51 | document.body.appendChild(screen) |
52 | route() |
53 | |
54 | window.onhashchange = function () { |
55 | var oldscreen = document.getElementById('screen') |
56 | var newscreen = h('div#screen') |
57 | oldscreen.parentNode.replaceChild(newscreen, oldscreen) |
58 | route() |
59 | } |
60 | |
61 |
Built with git-ssb-web