From 8042414be74c2b00b899b4bd2f5c7fca32fc7deb Mon Sep 17 00:00:00 2001 From: Andrea Rendine Date: Wed, 29 Apr 2015 23:43:43 +0200 Subject: [PATCH 1/3] 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. --- script/room.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/script/room.js b/script/room.js index 5be65d3..a6c543b 100644 --- a/script/room.js +++ b/script/room.js @@ -797,6 +797,7 @@ var Room = { $SM.set('stores["'+k+'"]', 0); } + k = _(k); // thieves? 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) { row = $('
').attr('id', id).addClass('storeRow'); - $('
').addClass('row_key').text(_(k)).appendTo(row); + $('
').addClass('row_key').text(k).appendTo(row); $('
').addClass('row_val').text(Math.floor(num)).appendTo(row); $('
').addClass('clear').appendTo(row); var curPrev = null; location.children().each(function(i) { var child = $(this); - var cName = child.attr('id').substring(4).replace('-', ' '); - if(cName < k && (curPrev == null || cName > curPrev)) { - curPrev = cName; + var cName = child.children('.row_key').text(); + if(cName < k) { + curPrev = child.attr('id'); } }); if(curPrev == null) { row.prependTo(location); } else { - row.insertAfter(location.find('#row_' + curPrev.replace(' ', '-'))); + row.insertAfter(location.find('#' + curPrev)); } newRow = true; } else if(num>= 0){ From dca3faa2f9be034e532747439c1c03ca2dea1f3e Mon Sep 17 00:00:00 2001 From: Andrea Rendine Date: Thu, 30 Apr 2015 16:57:18 +0200 Subject: [PATCH 2/3] Fixed variable name "k" still refers to the English string, while "lk" carries the translated value. --- script/room.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/room.js b/script/room.js index a6c543b..dc11abe 100644 --- a/script/room.js +++ b/script/room.js @@ -797,7 +797,7 @@ var Room = { $SM.set('stores["'+k+'"]', 0); } - k = _(k); + lk = _(k); // thieves? if(typeof $SM.get('game.thieves') == 'undefined' && num > 5000 && $SM.get('features.location.world')) { @@ -806,14 +806,14 @@ var Room = { if(row.length === 0 && num > 0) { row = $('
').attr('id', id).addClass('storeRow'); - $('
').addClass('row_key').text(k).appendTo(row); + $('
').addClass('row_key').text(lk).appendTo(row); $('
').addClass('row_val').text(Math.floor(num)).appendTo(row); $('
').addClass('clear').appendTo(row); var curPrev = null; location.children().each(function(i) { var child = $(this); var cName = child.children('.row_key').text(); - if(cName < k) { + if(cName < lk) { curPrev = child.attr('id'); } }); From 4efebe4f66d183eb059af754ce2c1fb8626c7e1d Mon Sep 17 00:00:00 2001 From: Andrea Rendine Date: Thu, 30 Apr 2015 17:26:56 +0200 Subject: [PATCH 3/3] Var Working in a hurry is bad. --- script/room.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/room.js b/script/room.js index dc11abe..0818b58 100644 --- a/script/room.js +++ b/script/room.js @@ -797,7 +797,7 @@ var Room = { $SM.set('stores["'+k+'"]', 0); } - lk = _(k); + var lk = _(k); // thieves? if(typeof $SM.get('game.thieves') == 'undefined' && num > 5000 && $SM.get('features.location.world')) {