]> git.sesse.net Git - remoteglot/commitdiff
Fix some issues with things crashing when we had no position.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 22 Mar 2016 21:28:27 +0000 (22:28 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 22 Mar 2016 21:28:27 +0000 (22:28 +0100)
www/js/remoteglot.js

index c9b6772cf776952814b80bedf173ca5323965aa2..48f23b00dc15e324735a37c3b5c9a400b1982747 100644 (file)
@@ -899,13 +899,15 @@ var update_game_list = function(games) {
                        // This game.
                        game_span.appendChild(game_name);
 
                        // 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");
                } 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;
        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') {
        if (data['position']) {
                var result = data['position']['result'];
                if (result === '1-0') {