christopher commited on
Commit
b6dd819
·
1 Parent(s): a69b86a

Update static/app.js

Browse files
Files changed (1) hide show
  1. static/app.js +21 -20
static/app.js CHANGED
@@ -39,26 +39,27 @@ function search() {
39
  }
40
 
41
  function displayPage() {
42
- const start = currentPage * RESULTS_PER_PAGE,
43
- end = start + RESULTS_PER_PAGE,
44
- pageResults = allResults.slice(start, end),
45
- totalPages = Math.ceil(allResults.length / RESULTS_PER_PAGE);
46
- let html = `<p>Found ${allResults.length} puzzles${allResults.length > 0 ? ` in ${window.searchTimeMs.toFixed(0)}ms (page ${currentPage + 1} of ${totalPages})` : ""}</p>`;
47
- if (allResults.length > 0)
48
- html += `<div class="pagination"><button onclick="prevPage()" ${currentPage === 0 ? "disabled" : ""}>&lt;</button><button onclick="nextPage()" ${end >= allResults.length ? "disabled" : ""}>&gt;</button></div>`;
49
- html += `<div class="puzzle-grid">`;
50
- pageResults.forEach((p, i) => {
51
- const idx = start + i;
52
- 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>`;
53
- });
54
- html += `</div>`;
55
- document.getElementById("results").innerHTML = html;
56
- pageResults.forEach((p, i) =>
57
- Chessboard(`result-board-${start + i}`, {
58
- position: p.FEN,
59
- pieceTheme: "/static/img/chesspieces/wikipedia/{piece}.png",
60
- }),
61
- );
 
62
  }
63
 
64
  function nextPage() {
 
39
  }
40
 
41
  function displayPage() {
42
+ const start = currentPage * RESULTS_PER_PAGE,
43
+ end = start + RESULTS_PER_PAGE,
44
+ pageResults = allResults.slice(start, end),
45
+ totalPages = Math.ceil(allResults.length / RESULTS_PER_PAGE);
46
+ const paginationHtml = allResults.length > 0 ? `<div class="pagination"><button onclick="prevPage()" ${currentPage === 0 ? "disabled" : ""}>&lt;</button><button onclick="nextPage()" ${end >= allResults.length ? "disabled" : ""}>&gt;</button></div>` : "";
47
+ let html = `<p>Found ${allResults.length} puzzles${allResults.length > 0 ? ` in ${window.searchTimeMs.toFixed(0)}ms (page ${currentPage + 1} of ${totalPages})` : ""}</p>`;
48
+ html += paginationHtml;
49
+ html += `<div class="puzzle-grid">`;
50
+ pageResults.forEach((p, i) => {
51
+ const idx = start + i;
52
+ 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>`;
53
+ });
54
+ html += `</div>`;
55
+ html += paginationHtml;
56
+ document.getElementById("results").innerHTML = html;
57
+ pageResults.forEach((p, i) =>
58
+ Chessboard(`result-board-${start + i}`, {
59
+ position: p.FEN,
60
+ pieceTheme: "/static/img/chesspieces/wikipedia/{piece}.png",
61
+ })
62
+ );
63
  }
64
 
65
  function nextPage() {