Fix the PV check.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 14 Nov 2016 18:52:08 +0000 (19:52 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 14 Nov 2016 18:52:28 +0000 (19:52 +0100)
www/js/remoteglot.js

index 5674cf1..05ae295 100644 (file)
@@ -279,11 +279,13 @@ var request_update = function() {
 
                // Verify that the PV makes sense.
                var valid = true;
-               var hiddenboard = new Chess(new_data['position']['fen']);
-               for (var i = 0; i < new_data['pv'].length; ++i) {
-                       if (hiddenboard.move(data['pv'][i]) === null) {
-                               valid = false;
-                               break;
+               if (new_data['pv']) {
+                       var hiddenboard = new Chess(new_data['position']['fen']);
+                       for (var i = 0; i < new_data['pv'].length; ++i) {
+                               if (hiddenboard.move(new_data['pv'][i]) === null) {
+                                       valid = false;
+                                       break;
+                               }
                        }
                }