Stores alphabetical sorting

The bulk of this small change was to sort stores by alphabetical order according to translated names, instead of english strings.
This meant removing the ID splitting as well as hyphen/space replacing, as the ID is not considered for the test.
Also changed:
1. line 800: as the original english string is no longer necessary in the iteration, k takes the value of translated string. k is then used for alphabetical comparison (as before) with the right value.
2. line 816: removed the test on curPrev variable. Items already listed have been placed in alphabetical order, so there is no need to check whether each item actually follows value of control variable.
This commit is contained in:
Andrea Rendine
2015-04-29 23:43:43 +02:00
parent c3f7b620f5
commit 8042414be7
+6 -5
View File
@@ -797,6 +797,7 @@ var Room = {
$SM.set('stores["'+k+'"]', 0); $SM.set('stores["'+k+'"]', 0);
} }
k = _(k);
// thieves? // thieves?
if(typeof $SM.get('game.thieves') == 'undefined' && num > 5000 && $SM.get('features.location.world')) { if(typeof $SM.get('game.thieves') == 'undefined' && num > 5000 && $SM.get('features.location.world')) {
@@ -805,21 +806,21 @@ var Room = {
if(row.length === 0 && num > 0) { if(row.length === 0 && num > 0) {
row = $('<div>').attr('id', id).addClass('storeRow'); row = $('<div>').attr('id', id).addClass('storeRow');
$('<div>').addClass('row_key').text(_(k)).appendTo(row); $('<div>').addClass('row_key').text(k).appendTo(row);
$('<div>').addClass('row_val').text(Math.floor(num)).appendTo(row); $('<div>').addClass('row_val').text(Math.floor(num)).appendTo(row);
$('<div>').addClass('clear').appendTo(row); $('<div>').addClass('clear').appendTo(row);
var curPrev = null; var curPrev = null;
location.children().each(function(i) { location.children().each(function(i) {
var child = $(this); var child = $(this);
var cName = child.attr('id').substring(4).replace('-', ' '); var cName = child.children('.row_key').text();
if(cName < k && (curPrev == null || cName > curPrev)) { if(cName < k) {
curPrev = cName; curPrev = child.attr('id');
} }
}); });
if(curPrev == null) { if(curPrev == null) {
row.prependTo(location); row.prependTo(location);
} else { } else {
row.insertAfter(location.find('#row_' + curPrev.replace(' ', '-'))); row.insertAfter(location.find('#' + curPrev));
} }
newRow = true; newRow = true;
} else if(num>= 0){ } else if(num>= 0){