From 92eba8d4c8d90ca130122c4ea2af189889e70c96 Mon Sep 17 00:00:00 2001 From: mougnibas Date: Thu, 21 Nov 2024 11:28:59 +0100 Subject: [PATCH] trucs cool --- index.html | 12 +++++++++++- js/element.js | 29 ++++++++++++++++++++++++----- js/technologie.js | 18 ++++++++++++++++++ 3 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 js/technologie.js diff --git a/index.html b/index.html index 773587e..ffaa0f5 100755 --- a/index.html +++ b/index.html @@ -6,8 +6,18 @@ Prog Web Legend -

Ecris une ligne

+

Click

+ + + + + + + + + +
nomboost
\ No newline at end of file diff --git a/js/element.js b/js/element.js index 867a3a3..55a867d 100644 --- a/js/element.js +++ b/js/element.js @@ -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) + + } + } \ No newline at end of file diff --git a/js/technologie.js b/js/technologie.js new file mode 100644 index 0000000..6c58b0b --- /dev/null +++ b/js/technologie.js @@ -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 + }) + + }) + } + +} \ No newline at end of file