Files: 8dc25143a3f37f1618f7a92b3c46dec512b43bfd / modules / timestamp.js
592 bytesRaw
1 | var h = require('hyperscript') |
2 | var human = require('human-time') |
3 | |
4 | exports.gives = 'message_meta' |
5 | |
6 | exports.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