Spaces:
Running
Running
Commit
·
edd78c3
1
Parent(s):
c4f8a1f
Update static/app.js
Browse files- static/app.js +2 -2
static/app.js
CHANGED
|
@@ -36,8 +36,8 @@ function search() {
|
|
| 36 |
|
| 37 |
function displayPage() {
|
| 38 |
const start = currentPage * RESULTS_PER_PAGE, end = start + RESULTS_PER_PAGE, pageResults = allResults.slice(start, end), totalPages = Math.ceil(allResults.length / RESULTS_PER_PAGE);
|
| 39 |
-
let html = `<
|
| 40 |
-
html += `<div class="puzzle-grid">`;
|
| 41 |
pageResults.forEach((p, i) => { const idx = start + i; html += `<div class="puzzle"><div class="puzzle-board" id="result-board-${idx}"></div><div class="puzzle-info"><h3><a href="https://lichess.org/training/${p.PuzzleId}" target="_blank">${p.PuzzleId}</a></h3><p>Rating: ${p.Rating} | Pop: ${p.Popularity}%</p><div class="themes">${p.Themes.map(t => `<span class="theme">${t}</span>`).join(' ')}</div><p>Move ${p.MatchedMove}</p></div></div>`; });
|
| 42 |
html += `</div>`;
|
| 43 |
document.getElementById('results').innerHTML = html;
|
|
|
|
| 36 |
|
| 37 |
function displayPage() {
|
| 38 |
const start = currentPage * RESULTS_PER_PAGE, end = start + RESULTS_PER_PAGE, pageResults = allResults.slice(start, end), totalPages = Math.ceil(allResults.length / RESULTS_PER_PAGE);
|
| 39 |
+
let html = `<p>Found ${allResults.length} puzzles${allResults.length > 0 ? ` in ${window.searchTimeMs.toFixed(0)}ms (page ${currentPage + 1} of ${totalPages})` : ''}</p>`;
|
| 40 |
+
if (allResults.length > 0) html += `<div class="pagination"><button onclick="prevPage()" ${currentPage === 0 ? 'disabled' : ''}>Previous</button><button onclick="nextPage()" ${end >= allResults.length ? 'disabled' : ''}>Next</button></div>`; html += `<div class="puzzle-grid">`;
|
| 41 |
pageResults.forEach((p, i) => { const idx = start + i; html += `<div class="puzzle"><div class="puzzle-board" id="result-board-${idx}"></div><div class="puzzle-info"><h3><a href="https://lichess.org/training/${p.PuzzleId}" target="_blank">${p.PuzzleId}</a></h3><p>Rating: ${p.Rating} | Pop: ${p.Popularity}%</p><div class="themes">${p.Themes.map(t => `<span class="theme">${t}</span>`).join(' ')}</div><p>Move ${p.MatchedMove}</p></div></div>`; });
|
| 42 |
html += `</div>`;
|
| 43 |
document.getElementById('results').innerHTML = html;
|