From 8cd1b0a1730482e2b8ad1a45ce014eefb14dd4f3 Mon Sep 17 00:00:00 2001 From: Eric Fredricksen Date: Mon, 12 Jul 2010 13:53:53 -0700 Subject: [PATCH] Get rid of ListBox.item --- main.js | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/main.js b/main.js index bd82f43..8bd30f2 100644 --- a/main.js +++ b/main.js @@ -367,7 +367,7 @@ function Put(list, key, value) { game[list.id].push([key,value]); } - PutUI(list, key, value); + list.PutUI(key, value); if (key === 'STR') 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) { this.id = id; this.bar = $("#"+ id + " > .bar"); @@ -462,15 +453,18 @@ function ListBox(id, columns, fixedkeys) { this.box.find("tr").removeClass("selected"); }; - this.item = function (key) { - var result = this.rows().filter(function (index) { + this.PutUI = function (key, value) { + var item = this.rows().filter(function (index) { return Key(this) === key; }); - if (!result.length) { - result = $("" + key + ""); - this.box.append(result); + if (!item.length) { + item = $("" + key + ""); + this.box.append(item); } - return result; + + item.children().last().text(value); + item.addClass("selected"); + item.each(function () {this.scrollIntoView();}); }; this.scrollToTop = function () { @@ -504,12 +498,12 @@ function ListBox(id, columns, fixedkeys) { var dict = game[this.id]; if (this.fixedkeys) { $.each(this.fixedkeys, function (index, key) { - PutUI(that, key, dict[key]); + that.PutUI(key, dict[key]); }); } else { $.each(dict, function (index, row) { if (that.columns == 2) - PutUI(that, row[0], row[1]); + that.PutUI(row[0], row[1]); else that.AddUI(row); });