X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;h=f4581cf72644032c0b4a6515e1320c7926648222;hb=d35c6f46dc92565c54213c4ea17c67f0e0938531;hp=d6292c3c8077e63ee5371347fa3d303a8602d08c;hpb=b8d98f5af526cd395b7ef7f47c7d87e40e80a107;p=remoteglot diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index d6292c3..f4581cf 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); @@ -2178,6 +2181,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) { @@ -2187,15 +2192,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; } }