modif d'insertion
这个提交包含在:
父节点
0c9ef72177
当前提交
a9258dd209
共有 1 个文件被更改,包括 55 次插入 和 36 次删除
|
|
@ -2,48 +2,67 @@ export class Gamer {
|
|||
constructor(Name, Score){
|
||||
this.name = Name;
|
||||
this.score = Score;
|
||||
this.gamers = []
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export function Scoreboard()
|
||||
{
|
||||
Scoreboard()
|
||||
{
|
||||
let alias = prompt("Entre ton nom", "User");
|
||||
let gamers = [];
|
||||
gamers.push( new Gamer(alias, 0));
|
||||
console.log(gamers);
|
||||
//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");
|
||||
|
||||
//console.log(table);
|
||||
//console.log(tableau);
|
||||
renderArray(gamers);
|
||||
this.renderArray();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export function renderArray(gamers)
|
||||
{
|
||||
addGamer()
|
||||
{
|
||||
|
||||
}
|
||||
removeGamer(ev)
|
||||
{
|
||||
this.gamers.splice(ev.target.getAttribute("array-index"), 1);
|
||||
renderArray();
|
||||
}
|
||||
|
||||
renderArray()
|
||||
{
|
||||
let tableau= document.getElementById("scoreTable");
|
||||
console.log(tableau);
|
||||
//console.log(tableau);
|
||||
tableau.innerText = "";
|
||||
gamers.forEach((gamer, index) => {
|
||||
this.gamers.forEach((gamer, index) => {
|
||||
let tableRow = document.createElement("tr");
|
||||
let nameTd = document.createElement("td");
|
||||
let scoreTd = document.createElement("td");
|
||||
//rmvTd = document.createElement("td");
|
||||
//rmvButton = document.createElement("button");
|
||||
//rmvButton.innerText = "delete";
|
||||
//rmvButton.setAttribute("array-index", index);
|
||||
//rmvButton.addEventListener("click", removeStudent);
|
||||
//rmvTd.appendChild(rmvButton);
|
||||
let rmvTd = document.createElement("td");
|
||||
let rmvButton = document.createElement("button");
|
||||
rmvButton.innerText = "delete";
|
||||
rmvButton.setAttribute("array-index", index);
|
||||
rmvButton.addEventListener("click", gamer.removeGamer);
|
||||
rmvTd.appendChild(rmvButton);
|
||||
|
||||
nameTd.innerText = gamer.name;
|
||||
scoreTd.innerText = gamer.score;
|
||||
|
||||
tableRow.appendChild(nameTd);
|
||||
tableRow.appendChild(scoreTd);
|
||||
//tableRow.appendChild(rmvTd);
|
||||
tableRow.appendChild(rmvTd);
|
||||
tableau.appendChild(tableRow);
|
||||
|
||||
});
|
||||
console.log(tableau);
|
||||
//console.log(tableau);
|
||||
}
|
||||
|
||||
|
||||
UpdateScore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
正在加载…
在新工单中引用