From 4502ae098be7b289c47d1c7f6c7086662a82dfef Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 30 May 2016 00:14:26 +0200 Subject: [PATCH] Small cleanup. --- www/js/book.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/www/js/book.js b/www/js/book.js index 30a5677..2cbbcec 100644 --- a/www/js/book.js +++ b/www/js/book.js @@ -121,7 +121,7 @@ var find_last_move_score = function() { ";includetransp=0" }).done(function(data, textstatus, xhr) { var moves = data['moves']; - var root_move = sort_moves_by_common(moves, data); + var root_move = sort_move_by_frequency(moves, data); var your_move, your_index; for (var i = 0; i < moves.length; ++i) { @@ -131,7 +131,6 @@ var find_last_move_score = function() { your_index = i; } } - moves.sort(function(a, b) { return b['num'] - a['num'] }); if (your_move) { $("#yourfraction").text(format_fraction(your_move['fraction'])); @@ -167,7 +166,7 @@ var find_computer_move = function() { var candidate_moves = []; var moves = data['moves']; - var root_move = sort_moves_by_common(moves, data); + var root_move = sort_move_by_frequency(moves, data); var practice_minimum_move_fraction; if (move_override > 20) { @@ -201,7 +200,7 @@ var find_computer_move = function() { // Add deried data and then sort moves to get the most common ones (in-place). // Remove the root mode and return it. Currently usable for practice mode only! -var sort_moves_by_common = function(moves, data) +var sort_move_by_frequency = function(moves, data) { var total_num = find_total_games(moves); var root_move; -- 2.39.2