le tableau qui tableau
This commit is contained in:
parent
5456271202
commit
8ab2691546
2 changed files with 26 additions and 4 deletions
21
js/main.js
21
js/main.js
|
@ -1,6 +1,6 @@
|
|||
function remplirMagasin(){
|
||||
|
||||
|
||||
|
||||
const table= document.getElementById("table_magasin_body")
|
||||
|
||||
|
||||
|
@ -19,10 +19,27 @@ function remplirMagasin(){
|
|||
const cout = document.createElement("td")
|
||||
cout.innerText = el.cout
|
||||
|
||||
const test = document.createElement("td")
|
||||
const btn_acheter = document.createElement("button")
|
||||
let tmp = key
|
||||
btn_acheter.addEventListener("click", (event) =>{
|
||||
console.log("clé : ",tmp)
|
||||
let t = new Technologie(tmp)
|
||||
t.chargerDepuisBdd(true)
|
||||
})
|
||||
|
||||
btn_acheter.innerText = "Acheter"
|
||||
|
||||
test.appendChild(btn_acheter)
|
||||
|
||||
|
||||
tr.appendChild(nom)
|
||||
tr.appendChild(boost)
|
||||
tr.appendChild(cout)
|
||||
tr.appendChild(test)
|
||||
|
||||
table.appendChild(tr)
|
||||
|
||||
});
|
||||
})
|
||||
|
||||
|
@ -30,4 +47,4 @@ function remplirMagasin(){
|
|||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,20 @@ class Technologie{
|
|||
this.nom = nom
|
||||
}
|
||||
|
||||
chargerDepuisBdd(){
|
||||
chargerDepuisBdd( style){
|
||||
fetch("../bdd/arbre.json").then((data)=>{
|
||||
data.json().then((data)=>{
|
||||
console.log(data)
|
||||
console.log("clé dans technologie :",this.nom)
|
||||
this.props = data["technologies"][this.nom]
|
||||
this.cout = this.props.cout
|
||||
this.boost = this.props.boost
|
||||
if(style){
|
||||
this.appliquerAmeliorationStyle()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue