Add reset button
This commit is contained in:
@@ -31,14 +31,18 @@ class Backend {
|
||||
getAvailableMoves(position) {
|
||||
return post_json("http://localhost:3000/get_moves/", position);
|
||||
}
|
||||
reset() {
|
||||
return post_json("http://localhost:3000/reset/");
|
||||
}
|
||||
}
|
||||
|
||||
class Chess {
|
||||
constructor() {
|
||||
this.backend = new Backend();
|
||||
this.canvas = new visuals.Canvas();
|
||||
this.button = document.createElement("button");
|
||||
this.autoplay = false;
|
||||
|
||||
this.button = document.createElement("button");
|
||||
this.button.innerHTML = "Autoplay Off";
|
||||
this.button.onclick = () => {
|
||||
this.autoplay = !this.autoplay;
|
||||
@@ -47,6 +51,15 @@ class Chess {
|
||||
];
|
||||
};
|
||||
document.body.appendChild(this.button);
|
||||
|
||||
this.resetButton = document.createElement("button");
|
||||
this.resetButton.innerHTML = "Reset";
|
||||
this.resetButton.onclick = () => {
|
||||
this.backend.reset();
|
||||
this.updateState();
|
||||
};
|
||||
document.body.appendChild(this.resetButton);
|
||||
|
||||
this.configVis = new visuals.ConfigVis(this.backend.getConfig());
|
||||
this.configVis.draw(this.canvas);
|
||||
this.activeSquares = new visuals.ActiveSquares();
|
||||
|
||||
Reference in New Issue
Block a user