From 88bf75295ae89f775d88dc9cce5be93895e324d5 Mon Sep 17 00:00:00 2001 From: dewanakl Date: Mon, 30 Dec 2024 09:10:04 +0700 Subject: [PATCH] fix: show more on comment length --- js/card.js | 2 +- js/comment.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/js/card.js b/js/card.js index 6ced81c..72a3833 100644 --- a/js/card.js +++ b/js/card.js @@ -149,7 +149,7 @@ export const card = (() => {

${moreThanMaxLength ? (original.slice(0, maxCommentLength) + '...') : original}

- ${moreThanMaxLength ? `

Selengkapnya

` : ''}`; + ${moreThanMaxLength ? `

Selengkapnya

` : ''}`; }; const renderContent = (comment, is_parent) => { diff --git a/js/comment.js b/js/comment.js index d18583d..2cae54b 100644 --- a/js/comment.js +++ b/js/comment.js @@ -118,9 +118,18 @@ export const comment = (() => { const original = card.convertMarkdownToHTML(util.escapeHtml(form.value)); const content = document.getElementById(`content-${id}`); - content.innerHTML = show && show.getAttribute('data-show') == 'false' ? original.slice(0, card.maxCommentLength) + '...' : original; if (original.length > card.maxCommentLength) { + content.innerHTML = show?.getAttribute('data-show') === 'false' ? original.slice(0, card.maxCommentLength) + '...' : original; content.setAttribute('data-comment', util.base64Encode(original)); + if (show?.style.display === 'none') { + show.style.display = 'block'; + } + } else { + content.innerHTML = original; + content.removeAttribute('data-comment'); + if (show?.style.display === 'block') { + show.style.display = 'none'; + } } if (presence) {