trucs cool
This commit is contained in:
parent
02774af38c
commit
92eba8d4c8
3 changed files with 53 additions and 6 deletions
12
index.html
12
index.html
|
@ -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>
|
|
@ -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
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