Files: 5ad997b45961f9143176e86d336daddac8c2aa0f / modules_basic / timestamp.js
613 bytesRaw
1 | var h = require('hyperscript') |
2 | var human = require('human-time') |
3 | |
4 | exports.needs = {} |
5 | |
6 | exports.gives = 'message_meta' |
7 | |
8 | exports.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