Add ability to use items from inventory
This commit is contained in:
parent
332ed3e38a
commit
50ca5a1c69
@ -5,9 +5,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function loadInventory() {
|
function loadInventory(reload) {
|
||||||
$("#item-bin #bag-preloader").removeClass("display-none");
|
if (typeof reload != "boolean") {
|
||||||
$("#item-bin .item-col").remove();
|
reload = false;
|
||||||
|
}
|
||||||
|
if (reload == false) {
|
||||||
|
$("#item-bin .item-col").remove();
|
||||||
|
$("#item-bin #bag-preloader").removeClass("display-none");
|
||||||
|
}
|
||||||
callAPI("inventory", {
|
callAPI("inventory", {
|
||||||
username: localStorage.getItem("username"),
|
username: localStorage.getItem("username"),
|
||||||
password: localStorage.getItem("password")
|
password: localStorage.getItem("password")
|
||||||
@ -31,15 +36,19 @@ 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) {
|
items.forEach(function (item) {
|
||||||
$("#item-bin").append('<div class="col-100 tablet-33 desktop-25 item-col">'
|
$("#item-bin").append('<div class="col-100 tablet-33 desktop-25 item-col">'
|
||||||
+ '<div class="item padding margin" data-uuids="' + item.uuids + '" data-qty="' + item.qty + '">'
|
+ '<div class="item padding margin" data-uuids="' + item.uuids.join("|") + '" data-qty="' + item.qty + '">'
|
||||||
+ '<i class="item-icon ' + item.icon + ' text-color-' + item.color + '"></i><br />'
|
+ '<i class="item-icon ' + item.icon + ' text-color-' + item.color + '"></i><br />'
|
||||||
+ (item.qty > 1 ? '<span class="badge color-green text-color-black padding">x' + item.qty + '</span>' : "")
|
+ (item.qty > 1 ? '<span class="badge color-green text-color-black padding">x' + item.qty + '</span>' : "")
|
||||||
+ '<h3>' + item.name + '</h3>'
|
+ '<h3>' + item.name + '</h3>'
|
||||||
+ item.description
|
+ item.description
|
||||||
|
+ (item.classname == "healmagic" ? '<button class="button button-fill margin-top useitem-button">Use</button>' : '')
|
||||||
+ '</div>'
|
+ '</div>'
|
||||||
+ '</div>');
|
+ '</div>');
|
||||||
})
|
})
|
||||||
@ -47,3 +56,27 @@ function loadInventory() {
|
|||||||
app.dialog.alert(msg, "Error");
|
app.dialog.alert(msg, "Error");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("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: '<i class="game-icon game-icon-school-bag"></i> ' + success.msg,
|
||||||
|
position: "center",
|
||||||
|
destroyOnClose: true,
|
||||||
|
closeTimeout: 5000
|
||||||
|
});
|
||||||
|
loadInventory(true);
|
||||||
|
}, function (error) {
|
||||||
|
app.dialog.alert(error, "Error");
|
||||||
|
});
|
||||||
|
});
|
@ -59,7 +59,7 @@
|
|||||||
<div class="popup display-flex justify-content-center align-items-center dark-popup" id="menu-popup">
|
<div class="popup display-flex justify-content-center align-items-center dark-popup" id="menu-popup">
|
||||||
<div class="row" id="mainmenu-items">
|
<div class="row" id="mainmenu-items">
|
||||||
<div class="col-50 mainmenu-item popup-close" onclick="router.navigate('/inventory');">
|
<div class="col-50 mainmenu-item popup-close" onclick="router.navigate('/inventory');">
|
||||||
<i class="game-icon game-icon-light-backpack fa-4x"></i><br />
|
<i class="game-icon game-icon-school-bag fa-4x"></i><br />
|
||||||
Items
|
Items
|
||||||
</div>
|
</div>
|
||||||
<div class="col-50 mainmenu-item">
|
<div class="col-50 mainmenu-item">
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="navbar-inner">
|
<div class="navbar-inner">
|
||||||
<div class="title"><i class="game-icon game-icon-light-backpack"></i> Items</div>
|
<div class="title"><i class="game-icon game-icon-school-bag"></i> Items</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user