50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
function remplirMagasin(){
|
|
|
|
|
|
const table= document.getElementById("table_magasin_body")
|
|
|
|
|
|
fetch("../bdd/arbre.json").then((data)=>{
|
|
data.json().then((data)=>{
|
|
console.log(data)
|
|
let tech = data["technologies"]
|
|
|
|
Object.keys(tech).forEach(key => {
|
|
el = tech[key]
|
|
const tr = document.createElement("tr")
|
|
const nom = document.createElement("td")
|
|
nom.innerText = el.nom
|
|
const boost = document.createElement("td")
|
|
boost.innerText = el.boost
|
|
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)
|
|
|
|
});
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|