Skip to content

Commit

Permalink
show rating for past puzzles
Browse files Browse the repository at this point in the history
  • Loading branch information
sggts04 committed May 12, 2024
1 parent 318b0c1 commit 0a87533
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 16 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,29 @@ body {
margin: 0px 15px;
}

.solvedRating {
text-decoration: none;
color: white;
font-size: 0.3em;
margin: 0;
}

#solvedPuzzles {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
}

.solvedPuzzle {
text-decoration: none;
display: flex;
flex-direction: column;
flex-wrap: wrap;
justify-content: center;
text-align: center;
}

#but {
font-size: 2.3em;
font-weight: 600;
Expand Down
5 changes: 3 additions & 2 deletions static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ function setInfo() {
// Solved Puzzles
if (id > 0) {
let startFEN = userHistory[id - 1].puzzle.fen;
let rating = userHistory[id - 1].puzzle.rating;
let puzzleGame = new Chess(startFEN);
puzzleGame.move(userHistory[id - 1].puzzle.start);
let lichessPuzzleFEN = puzzleGame.fen().replace(/ /g,"%20");
let elem;
if (userHistory[id - 1].correct)
elem = `<a href="https://lichess.org/analysis/${lichessPuzzleFEN}" target="_blank"><img class="marks" src="img/tick.svg"></img></a>`;
elem = `<a class="solvedPuzzle" href="https://lichess.org/analysis/${lichessPuzzleFEN}" target="_blank"><img class="marks" src="img/tick.svg"></img><p class="solvedRating">${rating}</p></a>`;
else
elem = `<a href="https://lichess.org/analysis/${lichessPuzzleFEN}" target="_blank"><img class="marks" src="img/cross.svg"></img></a>`;
elem = `<a class="solvedPuzzle" href="https://lichess.org/analysis/${lichessPuzzleFEN}" target="_blank"><img class="marks" src="img/cross.svg"></img><p class="solvedRating">${rating}</p></a>`;
$('#solvedPuzzles').append(elem);
}
}
Expand Down

0 comments on commit 0a87533

Please sign in to comment.