/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ var inventoryloadedfromplacepopup = false; function loadInventory(reload, target) { if (typeof target != "string") { target = "#inventory-page"; } inventoryloadedfromplacepopup = false; if ($("#place-popup").hasClass("modal-in")) { inventoryloadedfromplacepopup = true; } if (typeof reload != "boolean") { reload = false; // Make it reload if there's already stuff there, // to keep the items from disappearing and coming back if ($(target + " .item-bin .item-col").length > 0) { reload = true; } } if (reload == false) { $(target + " .item-bin .item-col").remove(); $(target + " .item-bin .bag-preloader").removeClass("display-none"); } callAPI("inventory", {}, function (resp) { if (resp.items.length == 0) { $(target + " .bag-empty").removeClass("display-none"); } else { $(target + " .bag-empty").addClass("display-none"); } var items = []; for (var i = 0; i < resp.items.length; i++) { var item = resp.items[i]; var found = false; for (var j = 0; j < items.length; j++) { if (items[j].id == item.id && items[j].json == item.json) { items[j].qty += 1; items[j].uuids.push(item.uuid); found = true; break; } } if (!found) { item["qty"] = 1; item["uuids"] = [item.uuid]; items.push(item); } } $(target + " .item-bin .item-col").remove(); if (reload == false) { $(target + " .item-bin .bag-preloader").addClass("display-none"); } items.forEach(function (item) { var usebtn = ""; if (item.classname == "healmagic" || (inventoryloadedfromplacepopup && item.classname == "artifact")) { usebtn = ''; } $(target + " .item-bin").append('