Have names go to profile
This commit is contained in:
1 parent
3f8dacfe1c
commit
dbb5aebbd3
1 file changed
+14
-5
+14
-5
@@ -49,14 +49,23 @@ function gameLink(text) {
|
||||
|
||||
// Name plates hug the board: whoever owns the pieces at the top of the board
|
||||
// gets the top plate, so they follow the flip when the user played black.
|
||||
function profileLink(username, text) {
|
||||
const a = document.createElement("a");
|
||||
a.className = "quiet-link";
|
||||
a.href = `https://www.chess.com/member/${encodeURIComponent(username)}`;
|
||||
a.target = "_blank";
|
||||
a.rel = "noopener";
|
||||
a.textContent = text;
|
||||
return a;
|
||||
}
|
||||
|
||||
function renderPlayerPlates() {
|
||||
const name = (n, rating) => (rating ? `${n} (${rating})` : n);
|
||||
const plate = (id, text) => el(id).replaceChildren(gameLink(text));
|
||||
const flip = analysis.user_color === "black";
|
||||
plate(flip ? "bottom-player" : "top-player",
|
||||
name(analysis.black, analysis.black_rating));
|
||||
plate(flip ? "top-player" : "bottom-player",
|
||||
name(analysis.white, analysis.white_rating));
|
||||
el(flip ? "bottom-player" : "top-player").replaceChildren(
|
||||
profileLink(analysis.black, name(analysis.black, analysis.black_rating)));
|
||||
el(flip ? "top-player" : "bottom-player").replaceChildren(
|
||||
profileLink(analysis.white, name(analysis.white, analysis.white_rating)));
|
||||
}
|
||||
|
||||
function renderSummary() {
|
||||
|
||||
Reference in new issue
Block a user