Get rid of ListBox.item

This commit is contained in:
Eric Fredricksen
2010-07-12 13:53:53 -07:00
parent 38aa6bcf42
commit 8cd1b0a173
+12 -18
View File
@@ -367,7 +367,7 @@ function Put(list, key, value) {
game[list.id].push([key,value]); game[list.id].push([key,value]);
} }
PutUI(list, key, value); list.PutUI(key, value);
if (key === 'STR') if (key === 'STR')
EncumBar.reset(10 + value, EncumBar.Position()); EncumBar.reset(10 + value, EncumBar.Position());
@@ -382,15 +382,6 @@ function Put(list, key, value) {
} }
function PutUI(list, key, value) {
// Update UI
var item = list.item(key);
item.children().last().text(value);
item.addClass("selected");
item.each(function () {this.scrollIntoView();});
}
function ProgressBar(id, tmpl) { function ProgressBar(id, tmpl) {
this.id = id; this.id = id;
this.bar = $("#"+ id + " > .bar"); this.bar = $("#"+ id + " > .bar");
@@ -462,15 +453,18 @@ function ListBox(id, columns, fixedkeys) {
this.box.find("tr").removeClass("selected"); this.box.find("tr").removeClass("selected");
}; };
this.item = function (key) { this.PutUI = function (key, value) {
var result = this.rows().filter(function (index) { var item = this.rows().filter(function (index) {
return Key(this) === key; return Key(this) === key;
}); });
if (!result.length) { if (!item.length) {
result = $("<tr><td>" + key + "</td><td/></tr>"); item = $("<tr><td>" + key + "</td><td/></tr>");
this.box.append(result); this.box.append(item);
} }
return result;
item.children().last().text(value);
item.addClass("selected");
item.each(function () {this.scrollIntoView();});
}; };
this.scrollToTop = function () { this.scrollToTop = function () {
@@ -504,12 +498,12 @@ function ListBox(id, columns, fixedkeys) {
var dict = game[this.id]; var dict = game[this.id];
if (this.fixedkeys) { if (this.fixedkeys) {
$.each(this.fixedkeys, function (index, key) { $.each(this.fixedkeys, function (index, key) {
PutUI(that, key, dict[key]); that.PutUI(key, dict[key]);
}); });
} else { } else {
$.each(dict, function (index, row) { $.each(dict, function (index, row) {
if (that.columns == 2) if (that.columns == 2)
PutUI(that, row[0], row[1]); that.PutUI(row[0], row[1]);
else else
that.AddUI(row); that.AddUI(row);
}); });