trucs cool

This commit is contained in:
Theo Mougnibas 2024-11-21 11:28:59 +01:00
parent 02774af38c
commit 92eba8d4c8
3 changed files with 53 additions and 6 deletions

View file

@ -6,8 +6,18 @@
<title>Prog Web Legend</title>
</head>
<body>
<p>Ecris une ligne</p>
<p>Click</p>
<script src="./js/intro.js" deref></script>
<script src="./js/element.js"></script>
<table>
<thead>
<th>nom</th>
<th>boost</th>
</thead>
<tbody id="table_technologies_body">
</tbody>
</table>
</body>
</html>

View file

@ -1,15 +1,34 @@
class element{
class Element{
constructor(techno,tag) {
this.tag = tag
this.techno = techno
}
charger_depuis_bdd(){
fetch("../bdd/arbre.json").then((data,r)=>{
let props = data["technologies"][this.techno][this.tag]
this.cout = props.cout
this.boost = props.boost
fetch("../bdd/arbre.json").then((data)=>{
data.json().then((data)=>{
this.props = data["technologies"][this.techno]["elements"][this.tag]
this.cout = this.props.cout
this.nom = this.props.nom
this.boost = this.props.boost
})
})
}
afficher_props_dans_html(){
const table= document.getElementById("table_technologies_body")
const tr = document.createElement("tr")
const nom = document.createElement("td")
nom.innerText = this.nom
const boost = document.createElement("td")
boost.innerText = this.boost
tr.appendChild(nom)
tr.appendChild(boost)
table.appendChild(tr)
}
}

18
js/technologie.js Normal file
View file

@ -0,0 +1,18 @@
class Technologie{
constructor(nom) {
this.nom = nom
}
charger_depuis_bdd(){
fetch("../bdd/arbre.json").then((data)=>{
data.json().then((data)=>{
console.log(data)
this.props = data[this.nom]
this.cout = this.props.cout
this.boost = this.props.boost
})
})
}
}