git ssb

3+

dangerousbeans / scuttle-vue



Tree: 8dc25143a3f37f1618f7a92b3c46dec512b43bfd

Files: 8dc25143a3f37f1618f7a92b3c46dec512b43bfd / modules / timestamp.js

592 bytesRaw
1var h = require('hyperscript')
2var human = require('human-time')
3
4exports.gives = 'message_meta'
5
6exports.create = function () {
7
8 function updateTimestampEl(el) {
9 el.firstChild.nodeValue = human(new Date(el.timestamp))
10 return el
11 }
12
13 setInterval(function () {
14 var els = [].slice.call(document.querySelectorAll('.timestamp'))
15 els.forEach(updateTimestampEl)
16 }, 60e3)
17
18 return function (msg) {
19 return updateTimestampEl(h('a.enter.timestamp', {
20 href: '#'+msg.key,
21 timestamp: msg.value.timestamp,
22 title: new Date(msg.value.timestamp)
23 }, ''))
24 }
25}
26

Built with git-ssb-web