]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Evidently clearTimeout() is expensive (~3 ms used on load), so do not call it unless...
[remoteglot] / www / js / remoteglot.js
index ee7495f1b138329f857fe0db1e9e8d2a58461176..7b030cab1cf491d9aa786fdad89aec19164ae702 100644 (file)
@@ -897,8 +897,11 @@ let update_refutation_lines = function() {
                        continue;
                }
 
-               let move = "<a class=\"move\" href=\"javascript:show_line(" + display_lines.length + ", " + 0 + ");\">" + line['move'] + "</a>";
-               move_td.innerHTML = move;
+               let move_link = document.createElement("a");
+               move_link.classList.add("move");
+               move_link.setAttribute("href", "javascript:show_line(" + display_lines.length + ", 0)");
+               move_link.textContent = line['move'];
+               move_td.appendChild(move_link);
 
                let score_td = document.createElement("td");
                tr.appendChild(score_td);
@@ -1223,6 +1226,9 @@ let update_board = function() {
                return;
        }
 
+       if (clock_timer !== null) {
+               clearTimeout(clock_timer);
+       }
        update_clock();
 
        // The score.
@@ -1494,7 +1500,7 @@ let update_num_viewers = function(num_viewers) {
 }
 
 let update_clock = function() {
-       clearTimeout(clock_timer);
+       clock_timer = null;
 
        let data = displayed_analysis_data || current_analysis_data;
        if (!data) return;