modif d'insertion

This commit is contained in:
Axel O 2023-01-05 10:32:29 +01:00
parent 0c9ef72177
commit a9258dd209

View file

@ -2,48 +2,67 @@ export class Gamer {
constructor(Name, Score){ constructor(Name, Score){
this.name = Name; this.name = Name;
this.score = Score; this.score = Score;
this.gamers = []
} }
} Scoreboard()
{
let alias = prompt("Entre ton nom", "User");
//let gamers = [];
//self.gamers
this.gamers.push( new Gamer(alias, 0));
//console.log(gamers);
//let game = new Gamer ("test", 0);
//let table = document.getElementById("scoreTable");
export function Scoreboard() //console.log(table);
{ //console.log(tableau);
let alias = prompt("Entre ton nom", "User"); this.renderArray();
let gamers = [];
gamers.push( new Gamer(alias, 0));
console.log(gamers);
//let table = document.getElementById("scoreTable");
//console.log(table); }
//console.log(tableau);
renderArray(gamers);
} addGamer()
{
}
removeGamer(ev)
{
this.gamers.splice(ev.target.getAttribute("array-index"), 1);
renderArray();
}
export function renderArray(gamers) renderArray()
{ {
let tableau= document.getElementById("scoreTable"); let tableau= document.getElementById("scoreTable");
console.log(tableau); //console.log(tableau);
tableau.innerText = ""; tableau.innerText = "";
gamers.forEach((gamer, index) => { this.gamers.forEach((gamer, index) => {
let tableRow = document.createElement("tr"); let tableRow = document.createElement("tr");
let nameTd = document.createElement("td"); let nameTd = document.createElement("td");
let scoreTd = document.createElement("td"); let scoreTd = document.createElement("td");
//rmvTd = document.createElement("td"); let rmvTd = document.createElement("td");
//rmvButton = document.createElement("button"); let rmvButton = document.createElement("button");
//rmvButton.innerText = "delete"; rmvButton.innerText = "delete";
//rmvButton.setAttribute("array-index", index); rmvButton.setAttribute("array-index", index);
//rmvButton.addEventListener("click", removeStudent); rmvButton.addEventListener("click", gamer.removeGamer);
//rmvTd.appendChild(rmvButton); rmvTd.appendChild(rmvButton);
nameTd.innerText = gamer.name; nameTd.innerText = gamer.name;
scoreTd.innerText = gamer.score; scoreTd.innerText = gamer.score;
tableRow.appendChild(nameTd);
tableRow.appendChild(scoreTd);
tableRow.appendChild(rmvTd);
tableau.appendChild(tableRow);
});
//console.log(tableau);
}
UpdateScore()
{
}
tableRow.appendChild(nameTd);
tableRow.appendChild(scoreTd);
//tableRow.appendChild(rmvTd);
tableau.appendChild(tableRow);
});
console.log(tableau);
} }