From 156bc15a5ea55b47b840f3372ed33994694d264a Mon Sep 17 00:00:00 2001 From: Kensuke Matsuzaki Date: Sat, 4 Nov 2023 12:43:07 +0900 Subject: [PATCH] Fix handling of zero length moves array --- wgo_view/wgo/basicplayer.commentbox.js | 2 +- wgo_view/wgo/basicplayer.infobox.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wgo_view/wgo/basicplayer.commentbox.js b/wgo_view/wgo/basicplayer.commentbox.js index 3480e78..2845739 100644 --- a/wgo_view/wgo/basicplayer.commentbox.js +++ b/wgo_view/wgo/basicplayer.commentbox.js @@ -177,7 +177,7 @@ CommentBox.prototype.getCommentText = function(comment, formatNicks, formatMoves if (analyze.score != null) { comm += "score:"+(+analyze.score).toFixed(1)+"
"; } - if (analyze.moves) { + if (analyze.moves && analyze.moves.length > 0) { comm += "

pv

"; var info = analyze.moves[0]; if (info.move != null) { diff --git a/wgo_view/wgo/basicplayer.infobox.js b/wgo_view/wgo/basicplayer.infobox.js index 4b4d439..b164a27 100644 --- a/wgo_view/wgo/basicplayer.infobox.js +++ b/wgo_view/wgo/basicplayer.infobox.js @@ -150,7 +150,9 @@ var update = function(e) { var winrate = null; if (info.winrate != undefined) { winrate = info.winrate; - } else if (info.moves != undefined && info.moves[0].winrate != undefined) { + } else if (info.moves != undefined + && info.moves[0].length > 0 + && info.moves[0].winrate != undefined) { winrate = info.moves[0].winrate; } if (winrate != null) { @@ -162,7 +164,9 @@ var update = function(e) { var score = null; if (info.score != undefined) { score = info.score; - } else if (info.moves != undefined && info.moves[0].score != undefined) { + } else if (info.moves != undefined + && info.moves[0].length > 0 + && info.moves[0].score != undefined) { score = info.moves[0].score; } if (score != null) {