aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/shop.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/js/shop.js b/js/shop.js
index 22ca85f..efd6ac5 100644
--- a/js/shop.js
+++ b/js/shop.js
@@ -1,12 +1,20 @@
function displayShop(ret) {
- var tmphtml = "<h4> Select an item to buy it:</h4>";
- tmphtml += "<ul class=\"list-inline\">";
- for(var i=0; i < ret.items.length; i++) {
- tmphtml += "<li>";
- tmphtml += "<button type=\"submit\" class=\"btn btn-primary\" onclick=\"buyItem('" + ret.items[i].name + "')\"><span class=\"item-icon\">" + ret.items[i].icon + "</span><br />" + ret.items[i].name + "</button>";
- tmphtml += "</li>";
+ var tmphtml = "<h3> Select an item to buy it:</h3>";
+ for(var key in ret.items){
+ if(ret.items.hasOwnProperty(key)){
+ var category = ret.items[key];
+ tmphtml += "<div class=\"row\">";
+ tmphtml += "<h4>"+key+"</h4>";
+ tmphtml += "<ul class=\"list-inline\">";
+ for(var i=0; i < category.length; i++) {
+ tmphtml += "<li>";
+ tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"buyItem('" + category[i].name + "')\"><span class=\"item-icon\">" + category[i].icon + "</span><br />" + category[i].name + "</button>";
+ tmphtml += "</li>";
+ }
+ tmphtml += "</ul>";
+ tmphtml += "</div>";
+ }
}
- tmphtml += "</ul>"
document.getElementById("tab2").innerHTML = tmphtml;
}
@@ -40,7 +48,7 @@ function addItem(ret) {
} else
invcontent.getElementsByTagName('ul')[0].innerHTML += itemhtml;
- showInfo(ret.desc);
+ showInfo("The "+ ret.name + " has been successfully purchased");
}
function buyItem(name) {