git ssb

16+

Dominic / patchbay



Tree: e33a98abcc85d3a3b35c0b2db5b98200b0614954

Files: e33a98abcc85d3a3b35c0b2db5b98200b0614954 / modules_basic / timestamp.js

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

Built with git-ssb-web