git ssb

16+

Dominic / patchbay



Tree: 4cda013d06b86a002895df3cbed747f6baf1085c

Files: 4cda013d06b86a002895df3cbed747f6baf1085c / 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