diff --git a/static/search-box.js b/static/search-box.js index 6531fce..3bac4a5 100644 --- a/static/search-box.js +++ b/static/search-box.js @@ -80,22 +80,29 @@ function _codigoparallevar_enable_search_box(selector, options) { } resultsList.innerHTML = ''; - for (const note of body.results.notes) { - if (note.is_todo === "1") { - continue; + for (const list of [ + body.results.notes.filter(n => n.is_todo !== "1"), + body.results.notes.filter(n => n.is_todo === "1"), + ]){ + for (const note of list) { + const resultCard = document.createElement('li'); + + const resultContents = document.createElement('a'); + resultContents.setAttribute('href', './' + note.id + '.node.html'); + + const resultTitle = document.createElement('h2'); + resultTitle.innerText = `${note.title} (${note.top_level_title})`; + if (note.is_todo === "1") { + resultTitle.setAttribute('class', 'is-todo'); + } + else if (note.is_done === "1") { + resultTitle.setAttribute('class', 'is-done'); + } + + resultContents.appendChild(resultTitle); + resultCard.appendChild(resultContents); + resultsList.appendChild(resultCard); } - - const resultCard = document.createElement('li'); - - const resultContents = document.createElement('a'); - resultContents.setAttribute('href', './' + note.id + '.node.html'); - - const resultTitle = document.createElement('h2'); - resultTitle.innerText = `${note.title} (${note.top_level_title})`; - - resultContents.appendChild(resultTitle); - resultCard.appendChild(resultContents); - resultsList.appendChild(resultCard); } if (body.results.notes.length == 0) { noResultsBox.classList.remove('hidden'); diff --git a/static/style.css b/static/style.css index a4ad7ac..8c9550b 100644 --- a/static/style.css +++ b/static/style.css @@ -87,6 +87,11 @@ body nav input { margin: 0; } +.results-box li h2.is-todo::before { + content: ' [TODO] '; + color: #D00; +} + .no-results-box { padding: 1rem; }