+var update_highlight = function() {
+ $("#board").find('.square-55d63').removeClass('nonuglyhighlight');
+ if (current_display_line === null && highlight_from !== undefined && highlight_to !== undefined) {
+ $("#board").find('.square-' + highlight_from).addClass('nonuglyhighlight');
+ $("#board").find('.square-' + highlight_to).addClass('nonuglyhighlight');
+ }
+}
+
+var update_refutation_lines = function(board) {
+ if (display_lines.length > 1) {
+ display_lines = [ display_lines[0] ];
+ }
+
+ var tbl = $("#refutationlines");
+ tbl.empty();
+
+ moves = [];
+ for (var move in refutation_lines) {
+ moves.push(move);
+ }
+ var compare = sort_refutation_lines_by_score ? compare_by_score : compare_by_sort_key;
+ moves = moves.sort(function(a, b) { return compare(refutation_lines, a, b) });
+ for (var i = 0; i < moves.length; ++i) {
+ var line = refutation_lines[moves[i]];
+
+ var tr = document.createElement("tr");
+
+ var move_td = document.createElement("td");
+ tr.appendChild(move_td);
+ $(move_td).addClass("move");
+ if (line.pv_uci.length == 0) {
+ $(move_td).text(line.pretty_move);
+ } else {
+ var move = "<a class=\"move\" href=\"javascript:show_line(" + display_lines.length + ", " + 0 + ");\">" + line.pretty_move + "</a>";
+ $(move_td).html(move);
+ }
+
+ var score_td = document.createElement("td");
+ tr.appendChild(score_td);
+ $(score_td).addClass("score");
+ $(score_td).text(line.pretty_score);
+
+ var depth_td = document.createElement("td");
+ tr.appendChild(depth_td);
+ $(depth_td).addClass("depth");
+ $(depth_td).text("d" + line.depth);
+
+ var pv_td = document.createElement("td");
+ tr.appendChild(pv_td);
+ $(pv_td).addClass("pv");
+ $(pv_td).html(print_pv(fen, line.pv_uci, line.pv_pretty, move_num, toplay, 10));
+
+ tbl.append(tr);
+ }
+
+ // Make one of the links clickable and the other nonclickable.
+ if (sort_refutation_lines_by_score) {
+ $("#sortbyscore0").html("<a href=\"javascript:resort_refutation_lines(0)\">Move</a>");
+ $("#sortbyscore1").html("<strong>Score</strong>");
+ } else {
+ $("#sortbyscore0").html("<strong>Move</strong>");
+ $("#sortbyscore1").html("<a href=\"javascript:resort_refutation_lines(1)\">Score</a>");
+ }
+}
+
+var update_board = function(board, data, num_viewers) {
+ display_lines = [];