aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authoralexichi <alexbankai96@gmail.com>2016-05-02 14:51:37 +0200
committeralexichi <alexbankai96@gmail.com>2016-05-02 14:51:37 +0200
commit556adda68fe99e3a88f59803aa9bd8892e4d34cf (patch)
tree2de7c76ad8c4c0cdfde7086c3cb179f44a665fbc /js
parent64b1663e55544e1ed0e072c4f624688625691c9f (diff)
downloadcandybox-556adda68fe99e3a88f59803aa9bd8892e4d34cf.tar.gz
candybox-556adda68fe99e3a88f59803aa9bd8892e4d34cf.tar.bz2
candybox-556adda68fe99e3a88f59803aa9bd8892e4d34cf.tar.xz
candybox-556adda68fe99e3a88f59803aa9bd8892e4d34cf.zip
fix shop item count
Diffstat (limited to 'js')
-rw-r--r--js/shop.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/js/shop.js b/js/shop.js
index 00f13af..bda3885 100644
--- a/js/shop.js
+++ b/js/shop.js
@@ -34,13 +34,14 @@ function buildShop() {
function addItem(ret) {
var itemhtml = "";
- if(ret[1]==1){ //si c'est la première itération de l'objet
+ var itemtag = document.querySelector("[data-name=\""+ret[0].name+"\"]");
+ if(!itemtag){ //si c'est la première itération de l'objet
itemhtml += "<li>";
- itemhtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"useItem('" + ret[0].name + "')\"><span class=\"item-icon\">" + ret[0].icon + "</span><br />" + ret[0].name + "(<span id=\"nbObjet\">"+ret[1]+"</span>)</button>";
+ itemhtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"useItem('" + ret[0].name + "')\"><span class=\"item-icon\">" + ret[0].icon + "</span><br />" + ret[0].name + "(<span data-name=\""+ ret[0].name + "\">"+ret[1]+"</span>)</button>";
itemhtml += "</li>";
}
- else if(ret[1]>1){ // si c'est une n-ième itération
- document.getElementById("nbObjet").innerHTML=ret[1];
+ else{ // si c'est une n-ième itération
+ itemtag.innerHTML=ret[1];
}
var invcontent = document.getElementById("tab3");