diff --git a/www/js/inventory.js b/www/js/inventory.js
index 585e4fa..5d64504 100644
--- a/www/js/inventory.js
+++ b/www/js/inventory.js
@@ -5,9 +5,14 @@
*/
-function loadInventory() {
- $("#item-bin #bag-preloader").removeClass("display-none");
- $("#item-bin .item-col").remove();
+function loadInventory(reload) {
+ if (typeof reload != "boolean") {
+ reload = false;
+ }
+ if (reload == false) {
+ $("#item-bin .item-col").remove();
+ $("#item-bin #bag-preloader").removeClass("display-none");
+ }
callAPI("inventory", {
username: localStorage.getItem("username"),
password: localStorage.getItem("password")
@@ -31,19 +36,47 @@ function loadInventory() {
}
}
- $("#item-bin #bag-preloader").addClass("display-none");
+ $("#item-bin .item-col").remove();
+ if (reload == false) {
+ $("#item-bin #bag-preloader").addClass("display-none");
+ }
items.forEach(function (item) {
$("#item-bin").append('
'
- + '
'
+ + '
'
+ '
'
+ (item.qty > 1 ? 'x' + item.qty + '' : "")
+ '
' + item.name + '
'
+ item.description
+ + (item.classname == "healmagic" ? '' : '')
+ ''
+ '
');
})
}, function (msg) {
app.dialog.alert(msg, "Error");
});
-}
\ No newline at end of file
+}
+
+$("body").on("click", ".useitem-button", function () {
+ var itemdom = $(this).parent(".item");
+ var uuids = itemdom.data("uuids") + "";
+ console.log(uuids);
+ console.log(uuids.split("|")[0]);
+ var qty = itemdom.data("qty");
+ var uuid = uuids.split("|")[0];
+ callAPI("useitem", {
+ username: localStorage.getItem("username"),
+ password: localStorage.getItem("password"),
+ uuid: uuid
+ }, function (success) {
+ app.toast.show({
+ text: '
' + success.msg,
+ position: "center",
+ destroyOnClose: true,
+ closeTimeout: 5000
+ });
+ loadInventory(true);
+ }, function (error) {
+ app.dialog.alert(error, "Error");
+ });
+});
\ No newline at end of file
diff --git a/www/pages/home.html b/www/pages/home.html
index 7a6bc06..1544d58 100644
--- a/www/pages/home.html
+++ b/www/pages/home.html
@@ -59,7 +59,7 @@