From b1b23a45f28a675dc16dec5cdf1ae4395b1957c8 Mon Sep 17 00:00:00 2001 From: "hehihoho3@gmail.com" Date: Thu, 2 Jul 2026 12:41:20 +0900 Subject: [PATCH] =?UTF-8?q?feat(comment-cards):=20=EB=8C=93=EA=B8=80=20?= =?UTF-8?q?=EB=82=B4=EC=9A=A9=20=EC=8B=A4=EC=8B=9C=EA=B0=84=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=ED=95=84=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 필터바에 검색 입력창 추가 → 입력 즉시 댓글 내용에 그 단어가 포함된 카드만 노출 (작성자 제외, 내용만 매칭). 클라이언트 필터라 추가 API 호출 없음. JS 캐시버스터 갱신. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/main/resources/static/js/comment-cards.js | 9 +++++++-- src/main/resources/templates/comment-cards.html | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/resources/static/js/comment-cards.js b/src/main/resources/static/js/comment-cards.js index d6da77e..5b9f7e9 100644 --- a/src/main/resources/static/js/comment-cards.js +++ b/src/main/resources/static/js/comment-cards.js @@ -28,7 +28,12 @@ const sort = $('ccSort').value; const minLikes = parseInt($('ccMinLikes').value, 10) || 0; const repliesOnly = $('ccRepliesOnly').checked; - let list = cards.filter(c => (c.likeCount || 0) >= minLikes && (!repliesOnly || (c.replyCount || 0) > 0)); + const q = ($('ccSearch').value || '').trim().toLowerCase(); + let list = cards.filter(c => + (c.likeCount || 0) >= minLikes && + (!repliesOnly || (c.replyCount || 0) > 0) && + (!q || toPlainText(c.text).toLowerCase().includes(q)) // 내용에만 매칭 + ); if (sort === 'likes') list.sort((a, b) => (b.likeCount || 0) - (a.likeCount || 0)); else if (sort === 'replies') list.sort((a, b) => (b.replyCount || 0) - (a.replyCount || 0)); else if (sort === 'latest') list.sort((a, b) => new Date(b.publishedAt) - new Date(a.publishedAt)); @@ -200,7 +205,7 @@ document.addEventListener('DOMContentLoaded', () => { $('ccFetch').addEventListener('click', fetchComments); $('ccUrl').addEventListener('keydown', (e) => { if (e.key === 'Enter') fetchComments(); }); - ['ccSort', 'ccMinLikes', 'ccRepliesOnly'].forEach(id => + ['ccSearch', 'ccSort', 'ccMinLikes', 'ccRepliesOnly'].forEach(id => $(id).addEventListener('input', () => window.renderCards())); $('ccMosaic').addEventListener('click', () => { mosaicOn = !mosaicOn; diff --git a/src/main/resources/templates/comment-cards.html b/src/main/resources/templates/comment-cards.html index 04a141a..5441663 100644 --- a/src/main/resources/templates/comment-cards.html +++ b/src/main/resources/templates/comment-cards.html @@ -56,6 +56,7 @@