From edf8b1193d82e7976c6c819aa1d25d54cc2c1858 Mon Sep 17 00:00:00 2001 From: Ev Bogue Date: Fri, 3 Jan 2020 18:42:43 -0600 Subject: condense reply text into a ↳ symbol -- also render text of message that is being replied to MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bog.js | 12 ++++++++++++ css/style.css | 2 +- render.js | 22 +++++++++++++++++----- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/bog.js b/bog.js index 55188e5..d8ee2a8 100644 --- a/bog.js +++ b/bog.js @@ -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; } diff --git a/render.js b/render.js index 79f839a..aaea0c2 100644 --- a/render.js +++ b/render.js @@ -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) { -- cgit v1.2.3-70-g09d2