Compare commits
2 commits
29c674c86d
...
36ffefcfb7
Author | SHA1 | Date | |
---|---|---|---|
36ffefcfb7 | |||
8ab2691546 |
2 changed files with 25 additions and 4 deletions
20
js/main.js
20
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)
|
||||
|
||||
});
|
||||
})
|
||||
|
||||
|
@ -31,4 +48,3 @@ 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