aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authoralexichi <alexbankai96@gmail.com>2016-04-27 12:59:51 +0200
committeralexichi <alexbankai96@gmail.com>2016-04-27 12:59:51 +0200
commit349c6fe7ecf10e5929dc27c2446853f0fe416077 (patch)
treeccb968ac0c1b507f0b88b42d42b47866c893b225 /js
parent8140617aeb2f32f7095a443ca743c6d6915739c6 (diff)
downloadcandybox-349c6fe7ecf10e5929dc27c2446853f0fe416077.tar.gz
candybox-349c6fe7ecf10e5929dc27c2446853f0fe416077.tar.bz2
candybox-349c6fe7ecf10e5929dc27c2446853f0fe416077.tar.xz
candybox-349c6fe7ecf10e5929dc27c2446853f0fe416077.zip
add loadShop() and categories in the xml file and modify the presentation of the items in the shop
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) {