]> git.sesse.net Git - remoteglot/blobdiff - www/js/remoteglot.js
Remove the option to sort by name; fewer options is good, and few people probably...
[remoteglot] / www / js / remoteglot.js
index 34e1863624ffdc7afd34a7913e54acd35bbc6028..d614c7ea1016a44f8b92afa841eb42c09b5a81b0 100644 (file)
@@ -94,9 +94,6 @@ var toplay = 'W';
 /** @type {number} @private */
 var ims = 0;
 
-/** @type {boolean} @private */
-var sort_refutation_lines_by_score = true;
-
 /** @type {boolean} @private */
 var truncate_display_history = true;
 
@@ -569,15 +566,6 @@ var create_arrow = function(from_square, to_square, fg_color, line_width, arrow_
        arrows.push(arrow);
 }
 
-// Note: invert is ignored.
-var compare_by_name = function(refutation_lines, invert, a, b) {
-       var ska = refutation_lines[a]['move'];
-       var skb = refutation_lines[b]['move'];
-       if (ska < skb) return -1;
-       if (ska > skb) return 1;
-       return 0;
-};
-
 var compare_by_score = function(refutation_lines, invert, a, b) {
        var sa = compute_score_sort_key(refutation_lines[b]['score'], refutation_lines[b]['depth'], invert);
        var sb = compute_score_sort_key(refutation_lines[a]['score'], refutation_lines[a]['depth'], invert);
@@ -801,8 +789,7 @@ var update_refutation_lines = function() {
        if (current_display_line && current_display_move % 2 == 0) {
                invert = !invert;
        }
-       var compare = sort_refutation_lines_by_score ? compare_by_score : compare_by_name;
-       moves = moves.sort(function(a, b) { return compare(refutation_lines, invert, a, b) });
+       moves = moves.sort(function(a, b) { return compare_by_score(refutation_lines, invert, a, b) });
        for (var i = 0; i < moves.length; ++i) {
                var line = refutation_lines[moves[i]];
 
@@ -863,15 +850,6 @@ var update_refutation_lines = function() {
                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(false)\">Move</a>");
-               $("#sortbyscore1").html("<strong>Score</strong>");
-       } else {
-               $("#sortbyscore0").html("<strong>Move</strong>");
-               $("#sortbyscore1").html("<a href=\"javascript:resort_refutation_lines(true)\">Score</a>");
-       }
-
        // Update the move highlight, as we've rewritten all the HTML.
        update_move_highlight();
 }
@@ -1540,18 +1518,6 @@ var format_tooltip = function(data, halfmove_num) {
        }
 }
 
-/**
- * @param {boolean} sort_by_score
- */
-var resort_refutation_lines = function(sort_by_score) {
-       sort_refutation_lines_by_score = sort_by_score;
-       if (supports_html5_storage()) {
-               localStorage['sort_refutation_lines_by_score'] = sort_by_score ? 1 : 0;
-       }
-       update_refutation_lines();
-}
-window['resort_refutation_lines'] = resort_refutation_lines;
-
 /**
  * @param {boolean} truncate_history
  */
@@ -2201,11 +2167,6 @@ var init = function() {
        } else {
                set_sound(false);
        }
-       if (supports_html5_storage() && localStorage['sort_refutation_lines_by_score']) {
-               sort_refutation_lines_by_score = parseInt(localStorage['sort_refutation_lines_by_score']);
-       } else {
-               sort_refutation_lines_by_score = true;
-       }
 
        // Create board.
        board = new window.ChessBoard('board', {