You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.1 KiB
HTML
60 lines
2.1 KiB
HTML
<div class="scrollable-box">
|
|
<div class="list-group" id="inventory-list">
|
|
<div class="list-group-item">
|
|
<i class="fa fa-spinner fa-pulse fa-fw"></i> Loading...
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function useitem(uuid) {
|
|
$.getJSON(mkApiUrl('useitem', 'gs'), {
|
|
itemuuid: uuid
|
|
}, function (data) {
|
|
if (data.status === 'OK') {
|
|
loadinventory();
|
|
syncStats();
|
|
} else {
|
|
navigator.notification.alert(data.message, null, "Error", 'OK');
|
|
}
|
|
}).fail(function () {
|
|
navigator.notification.alert("Cannot use item. Try again.", null, "Error", 'OK');
|
|
});
|
|
}
|
|
|
|
function getitemhtmlfromjson(item) {
|
|
var itemhtml = "\
|
|
<div class='list-group-item inventory-item' id='item-" + item.itemuuid + "'>\
|
|
<h4 class='itemname'>" + item.itemname + "</h4>\
|
|
<p class='itemdesc'>" + item.itemdesc + "</p>";
|
|
if (item.classname == "healmagic") {
|
|
itemhtml += "<span class='btn btn-success' onclick=\"useitem('" + item.itemuuid + "')\">\
|
|
Use Item\
|
|
</span>";
|
|
}
|
|
itemhtml += "<span class='itemid' style='display: none;'>" + item.itemid + "</span>\
|
|
<span class='itemclassid' style='display: none;'>" + item.classid + "</span>\
|
|
<span class='itemjson' style='display: none;'>" + item.itemjson + "</span>\
|
|
</div>";
|
|
return itemhtml;
|
|
}
|
|
|
|
function loadinventory() {
|
|
$.getJSON(mkApiUrl('inventory'), {
|
|
user: username
|
|
}, function (data) {
|
|
var content = "";
|
|
if (data.status == 'OK') {
|
|
items = data.items;
|
|
items.forEach(function (item) {
|
|
content += getitemhtmlfromjson(item);
|
|
});
|
|
} else {
|
|
content = "<div class='list-group-item'>An error occurred.</div>";
|
|
}
|
|
$('#inventory-list').html(content);
|
|
});
|
|
}
|
|
|
|
loadinventory();
|
|
</script> |