Skip to content

Commit

Permalink
Merge pull request doublespeakgames#346 from AndySky21/buildings-az-s…
Browse files Browse the repository at this point in the history
…orting

Buildings alphabetical sorting
  • Loading branch information
Continuities committed Apr 30, 2015
2 parents c725b58 + 9c1ebec commit 5c37074
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions script/outside.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,26 +364,27 @@ var Outside = {

updateVillageRow: function(name, num, village) {
var id = 'building_row_' + name.replace(' ', '-');
name = _(name);
var row = $('div#' + id, village);
if(row.length === 0 && num > 0) {
row = $('<div>').attr('id', id).addClass('storeRow');
$('<div>').addClass('row_key').text(_(name)).appendTo(row);
$('<div>').addClass('row_key').text(name).appendTo(row);
$('<div>').addClass('row_val').text(num).appendTo(row);
$('<div>').addClass('clear').appendTo(row);
var curPrev = null;
village.children().each(function(i) {
var child = $(this);
if(child.attr('id') != 'population') {
var cName = child.attr('id').substring(13).replace('-', ' ');
if(cName < name && (curPrev == null || cName > curPrev)) {
curPrev = cName;
var cName = child.children('.row_key').text();
if(cName < name) {
curPrev = child.attr('id');
}
}
});
if(curPrev == null) {
row.prependTo(village);
} else {
row.insertAfter('#building_row_' + curPrev.replace(' ', '-'));
row.insertAfter('#' + curPrev);
}
} else if(num > 0) {
$('div#' + row.attr('id') + ' > div.row_val', village).text(num);
Expand Down

0 comments on commit 5c37074

Please sign in to comment.