From 48ca3e8ee63787d567fd0fe1bcfea7158a6f9596 Mon Sep 17 00:00:00 2001 From: alexichi Date: Fri, 29 Apr 2016 21:06:59 +0200 Subject: add the option to not create 2 objects of the same type, doesn't work well --- js/shop.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'js') diff --git a/js/shop.js b/js/shop.js index efd6ac5..00f13af 100644 --- a/js/shop.js +++ b/js/shop.js @@ -28,14 +28,21 @@ function buildShop() { sendRequest("craftmine.php", "op=buildShop", function(ret) { displayShop(ret); debitAccount(ret.cost); + showInfo("Your shop has been successfully created"); }); } function addItem(ret) { - var itemhtml = "
  • "; - itemhtml += ""; - itemhtml += "
  • "; - + var itemhtml = ""; + if(ret[1]==1){ //si c'est la première itération de l'objet + itemhtml += "
  • "; + itemhtml += ""; + itemhtml += "
  • "; + } + else if(ret[1]>1){ // si c'est une n-ième itération + document.getElementById("nbObjet").innerHTML=ret[1]; + } + var invcontent = document.getElementById("tab3"); if(invcontent.children.length <= 1) @@ -48,13 +55,13 @@ function addItem(ret) { } else invcontent.getElementsByTagName('ul')[0].innerHTML += itemhtml; - showInfo("The "+ ret.name + " has been successfully purchased"); + showInfo("The "+ ret[0].name + " has been successfully purchased"); } function buyItem(name) { sendRequest("craftmine.php", "op=buyItem&item="+name, function(ret) { addItem(ret); - debitAccount(ret.cost); + debitAccount(ret[0].cost); }); } -- cgit v1.2.3-70-g09d2