From: Steinar H. Gunderson Date: Tue, 22 Mar 2016 21:28:27 +0000 (+0100) Subject: Fix some issues with things crashing when we had no position. X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=c7ae0df4abc9ca2168839e94535c1bd39715a57f Fix some issues with things crashing when we had no position. --- diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index c9b6772..48f23b0 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -899,13 +899,15 @@ var update_game_list = function(games) { // This game. game_span.appendChild(game_name); - var score; - if (current_analysis_data['position']['result']) { - score = " (" + current_analysis_data['position']['result'] + ")"; - } else { - score = " (" + format_short_score(current_analysis_data['score']) + ")"; + if (current_analysis_data && current_analysis_data['position']) { + var score; + if (current_analysis_data['position']['result']) { + score = " (" + current_analysis_data['position']['result'] + ")"; + } else { + score = " (" + format_short_score(current_analysis_data['score']) + ")"; + } + game_span.appendChild(document.createTextNode(score)); } - game_span.appendChild(document.createTextNode(score)); } else { // Some other game. var game_a = document.createElement("a"); @@ -1291,6 +1293,8 @@ var update_clock = function() { clearTimeout(clock_timer); var data = displayed_analysis_data || current_analysis_data; + if (!data) return; + if (data['position']) { var result = data['position']['result']; if (result === '1-0') {