From 6c60ac6e55da99aac1958c87ee36a6acb4d399b6 Mon Sep 17 00:00:00 2001 From: Ev Bogue Date: Fri, 19 Apr 2019 16:10:15 -0500 Subject: move some stuff around and try to get it to work --- lib.js | 60 ++++++++++++++++++------------------------------------------ 1 file changed, 18 insertions(+), 42 deletions(-) (limited to 'lib.js') diff --git a/lib.js b/lib.js index 308c081..5351f95 100644 --- a/lib.js +++ b/lib.js @@ -1,6 +1,4 @@ - - -function requestFeed (src, server, requester) { +/*function requestFeed (src, server, requester) { console.log(src) console.log(server) @@ -57,7 +55,7 @@ function requestFeed (src, server, requester) { } } }) -} +}*/ // publish new messages to your log function publish (toPublish, keys) { @@ -210,45 +208,23 @@ function getName (id) { return name } -// human-time by Dave Eddy https://github.com/bahamas10/human - -function human(seconds) { - if (seconds instanceof Date) - seconds = Math.round((Date.now() - seconds) / 1000); - var suffix = seconds < 0 ? 'from now' : 'ago'; - seconds = Math.abs(seconds); - - var times = [ - seconds / 60 / 60 / 24 / 365, // years - seconds / 60 / 60 / 24 / 30, // months - seconds / 60 / 60 / 24 / 7, // weeks - seconds / 60 / 60 / 24, // days - seconds / 60 / 60, // hours - seconds / 60, // minutes - seconds // seconds - ]; - var names = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second']; - - for (var i = 0; i < names.length; i++) { - var time = Math.floor(times[i]); - var name = names[i]; - if (time > 1) - name += 's'; - - if (time >= 1) - return time + ' ' + name + ' ' + suffix; +function getHeader (post, mini) { + var inner + if (mini) { + var inner = mini } - return '0 seconds ' + suffix; -} -// hscrpt by Dominic Tarr https://github.com/dominictarr/hscrpt/blob/master/LICENSE -function h (tag, attrs, content) { - if(Array.isArray(attrs)) content = attrs, attrs = {} - var el = document.createElement(tag) - for(var k in attrs) el[k] = attrs[k] - if(content) content.forEach(function (e) { - if(e) el.appendChild('string' == typeof e ? document.createTextNode(e) : e) - }) - return el + var head = h('span', [ + h('a', {href: '#' + post.key}, [ + h('p', {classList: 'right'}, [human(new Date(post.content.timestamp))]), + ]), + h('p', [ + h('a', {href: '#' + post.content.author}, [ + getName(post.content.author) + ]), + inner + ]) + ]) + return head } -- cgit v1.2.3-70-g09d2