X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;h=7b030cab1cf491d9aa786fdad89aec19164ae702;hb=026c621f8c912aba3f53be9057078eefe9c92c6f;hp=c96335feb62baeacd88435fcc65c91c6375920b2;hpb=9dd737c8851cf2706b4823dc886e1311854ede64;p=remoteglot diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index c96335f..7b030ca 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -897,8 +897,11 @@ let update_refutation_lines = function() { continue; } - let move = "" + line['move'] + ""; - 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. @@ -1395,7 +1401,10 @@ let update_sparkline = function(data) { scores.push(last_score); } if (data['score']) { - scores.push(compute_plot_score(data['score'])); + let score = compute_plot_score(data['score']); + scores.push(score); + if (score < min_score) min_score = score; + if (score > max_score) max_score = score; } const h = scorespark.getBoundingClientRect().height; @@ -1441,7 +1450,7 @@ let update_sparkline = function(data) { rect.addEventListener('mouseenter', (e) => draw_hover(e, hlcolor, tooltip)); rect.addEventListener('mousemove', (e) => draw_hover(e, hlcolor, tooltip)); rect.addEventListener('mouseleave', (e) => hide_hover(e, color)); - rect.addEventListener('click', (e) => show_line(0, i + first_move_num - 1)); + rect.addEventListener('click', (e) => { hide_hover(e, color); show_line(0, i + first_move_num - 1) }); scorespark.appendChild(rect); } } @@ -1491,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; @@ -2175,6 +2184,8 @@ let onSnapEnd = function(source, target) { promotion: 'q' // NOTE: always promote to a queen for example simplicity }); + // Move ahead on the line we're on -- this includes history if we've + // gone backwards. if (current_display_line && current_display_move < current_display_line.pv.length - 1 && current_display_line.pv[current_display_move + 1] === move.san) { @@ -2184,15 +2195,16 @@ let onSnapEnd = function(source, target) { // Walk down the displayed lines until we find one that starts with // this move, then select that. Note that this gives us a good priority - // order (history first, then PV, then multi-PV lines). - for (let i = 0; i < display_lines.length; ++i) { + // order (PV, then multi-PV lines; history was already dealt with above, + // as it's the only line that originates backwards). + for (let i = 1; i < display_lines.length; ++i) { if (i == 1 && current_display_line) { // Do not choose PV if not on it. continue; } let line = display_lines[i]; if (line.pv[line.start_display_move_num] === move.san) { - show_line(i, 0); + show_line(i, line.start_display_move_num); return; } }