diff --git a/admin.html b/admin.html index ecf8c44..f400685 100644 --- a/admin.html +++ b/admin.html @@ -402,10 +402,13 @@

Kaikki julkaisut

-
+
@@ -884,9 +887,13 @@ // =========================== // RENDER POST LIST // =========================== + const ADMIN_PER_PAGE = 20; + let adminVisible = ADMIN_PER_PAGE; + function renderPostList() { const posts = ADMIN.posts; const el = document.getElementById('postList'); + adminVisible = ADMIN_PER_PAGE; if (!posts.length) { el.innerHTML = `

${at('empty')}

`; return; } el.innerHTML = posts.map(p => `
@@ -901,14 +908,31 @@
`).join(''); + filterPostList(); } function filterPostList() { - const q = document.getElementById('postSearch').value.toLowerCase(); - document.querySelectorAll('#postList .post-item').forEach(el => { - const text = el.querySelector('h3').textContent.toLowerCase(); - el.style.display = text.includes(q) ? '' : 'none'; + const q = document.getElementById('postSearch')?.value.toLowerCase() || ''; + const items = document.querySelectorAll('#postList .post-item'); + let matched = 0, shown = 0; + items.forEach(el => { + const text = (el.querySelector('h3')?.textContent || '').toLowerCase() + + (el.querySelector('.post-item-info p')?.textContent || '').toLowerCase(); + if (!q || text.includes(q)) { + matched++; + el.style.display = matched <= adminVisible ? '' : 'none'; + if (matched <= adminVisible) shown++; + } else { + el.style.display = 'none'; + } }); + const wrap = document.getElementById('adminLoadMore'); + if (wrap) wrap.style.display = matched > shown ? '' : 'none'; + } + + function adminShowMore() { + adminVisible += ADMIN_PER_PAGE; + filterPostList(); } // ===========================