push @repretty_moves, $pretty;
$pos = $npos;
}
- $pos->{'result'} = $pgn->result;
+ if ($pgn->result eq '1-0' || $pgn->result eq '1/2-1/2' || $pgn->result eq '0-1') {
+ $pos->{'result'} = $pgn->result;
+ }
$pos->{'pretty_history'} = \@repretty_moves;
extract_clock($pgn, $pos);
my $white = $other_game_json->{'position'}{'player_w'} // die 'Missing white';
my $black = $other_game_json->{'position'}{'player_b'} // die 'Missing black';
- push @games, {
+ my $game = {
id => $ref->{'id'},
name => "$white–$black",
url => $ref->{'url'},
hashurl => $ref->{'hash_url'},
- score => $other_game_json->{'score'}
};
+ if (defined($other_game_json->{'position'}{'result'})) {
+ $game->{'result'} = $other_game_json->{'position'}{'result'};
+ } else {
+ $game->{'score'} = $other_game_json->{'score'};
+ }
+ push @games, $game;
};
if ($@) {
warn "Could not add external game " . $ref->{'json_path'} . ": $@";
* @type {Number}
* @const
* @private */
-var SCRIPT_VERSION = 2016032200;
+var SCRIPT_VERSION = 2016032201;
/**
* The current backend URL.
* name: string,
* url: string,
* id: string,
- * score: Object
+ * score: =Object,
+ * result: =string,
* }>}
* @private
*/
game_span.appendChild(game_a);
}
- var score = " (" + format_short_score(game['score']) + ")";
+ var score;
+ if (game['result']) {
+ score = " (" + game['result'] + ")";
+ } else {
+ score = " (" + format_short_score(game['score']) + ")";
+ }
game_span.appendChild(document.createTextNode(score));
games_div.appendChild(game_span);
// The <title> contains a very brief headline.
var title_elems = [];
- if (data['score']) {
- title_elems.push(format_short_score(data['score']).replace(/^ /, ""));
+ if (data['position'] && data['position']['result']) {
+ title_elems.push(data['position']['result']);
+ } else if (data['score']) {
+ title_elems.push(format_short_score(data['score']));
}
if (last_move !== null) {
title_elems.push(last_move);