Compare commits
2 commits
2b72155ee2
...
ea464e791a
Author | SHA1 | Date | |
---|---|---|---|
ea464e791a | |||
92eba8d4c8 |
3 changed files with 52 additions and 5 deletions
10
index.html
10
index.html
|
@ -9,5 +9,15 @@
|
||||||
<p>Click</p>
|
<p>Click</p>
|
||||||
<script src="./js/intro.js" deref></script>
|
<script src="./js/intro.js" deref></script>
|
||||||
<script src="./js/element.js"></script>
|
<script src="./js/element.js"></script>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<th>nom</th>
|
||||||
|
<th>boost</th>
|
||||||
|
</thead>
|
||||||
|
<tbody id="table_technologies_body">
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,15 +1,34 @@
|
||||||
class element{
|
class Element{
|
||||||
constructor(techno,tag) {
|
constructor(techno,tag) {
|
||||||
this.tag = tag
|
this.tag = tag
|
||||||
this.techno = techno
|
this.techno = techno
|
||||||
}
|
}
|
||||||
|
|
||||||
charger_depuis_bdd(){
|
charger_depuis_bdd(){
|
||||||
fetch("../bdd/arbre.json").then((data,r)=>{
|
fetch("../bdd/arbre.json").then((data)=>{
|
||||||
let props = data["technologies"][this.techno][this.tag]
|
data.json().then((data)=>{
|
||||||
this.cout = props.cout
|
this.props = data["technologies"][this.techno]["elements"][this.tag]
|
||||||
this.boost = props.boost
|
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
18
js/technologie.js
Normal 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
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue