diff options
author | Ev Bogue <ev@evbogue.com> | 2020-01-03 18:42:43 -0600 |
---|---|---|
committer | Ev Bogue <ev@evbogue.com> | 2020-01-03 18:42:43 -0600 |
commit | edf8b1193d82e7976c6c819aa1d25d54cc2c1858 (patch) | |
tree | 676b2ed0c39c90250c227822be7587fe7ab56dad | |
parent | 9f8817829f01391567989697394417474205dace (diff) |
condense reply text into a ↳ symbol -- also render text of message that is being replied to
-rw-r--r-- | bog.js | 12 | ||||
-rw-r--r-- | css/style.css | 2 | ||||
-rw-r--r-- | render.js | 22 |
3 files changed, 30 insertions, 6 deletions
@@ -94,6 +94,18 @@ async function get (key) { } } +async function getTitle (key) { + var log = await localforage.getItem('log') + if (log != null) { + for (var i = log.length - 1; i >= 0; --i) { + if (log[i].key === key) { + return log[i].text.substring(0, 15) + '…' + } + } + } +} + + // bog.getImage function getImage (id, keys, classList) { diff --git a/css/style.css b/css/style.css index 6e26838..ba2313a 100644 --- a/css/style.css +++ b/css/style.css @@ -9,7 +9,7 @@ body { } p { - margin-top: 1ex; + margin-top: .5ex; margin-bottom: 1ex; font-size: 1em; } @@ -138,14 +138,26 @@ function render (msg, keys, preview) { } if (msg.type == 'post') { - message.appendChild(getHeader(msg, keys)) + var mini = h('span', [' ']) + + message.appendChild(getHeader(msg, keys, mini)) + + console.log(getTitle(msg.reply)) if (msg.reply) { - message.firstChild.appendChild(h('span', [ - 're: ', - h('a', {href: '#' + msg.reply}, [msg.reply.substring(0, 10) + '...']) - ])) + getTitle(msg.reply).then(title => { + if (!title) { + title = msg.reply.substring(0, 15) + '…' + } + mini.appendChild(h('span', [ + '↳ ', + h('a', {href: '#' + msg.reply}, [title]) + ])) + + }) } + + message.appendChild(h('div',{id: 'content:' + msg.key, innerHTML: marked(msg.text)})) var buttons = h('div') if (!preview) { |