]> git.sesse.net Git - remoteglot-book/commitdiff
Make display on unreachable and terminal positions prettier.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 16 Dec 2014 00:35:56 +0000 (01:35 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 16 Dec 2014 00:35:56 +0000 (01:35 +0100)
www/js/book.js

index a100fc85afc1e48fd9953a16b4936bc23e23a9d7..2821ae1a00e3de059402d77411b5099a434c4f50 100644 (file)
@@ -236,11 +236,19 @@ var show_lines = function(data, game) {
                                td.appendChild(move_a);
                                $(move_a).text(line[j]);
                        } else if (headings[j][1] == TYPE_INTEGER) {
-                               add_td(tr, line[j]);
+                               add_td(tr, line[j] || 0);
                        } else if (headings[j][1] == TYPE_FLOAT) {
-                               add_td(tr, line[j].toFixed(1));
+                               if (isNaN(line[j]) || !isFinite(line[j])) {
+                                       add_td(tr, '');
+                               } else {
+                                       add_td(tr, line[j].toFixed(1));
+                               }
                        } else {
-                               add_td(tr, (100.0 * line[j]).toFixed(1) + "%");
+                               if (isNaN(line[j]) || !isFinite(line[j])) {
+                                       add_td(tr, '');
+                               } else {
+                                       add_td(tr, (100.0 * line[j]).toFixed(1) + "%");
+                               }
                        }
                }