implemented new model for database, new routes for save. Fixed logout not allowing post requests
This commit is contained in:
@@ -196,4 +196,39 @@ function updateQueenList() {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function saveGame() {
|
||||
await fetch("/save", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
board: board,
|
||||
mode: mode
|
||||
})
|
||||
});
|
||||
|
||||
alert("💾 Spiel gespeichert!");
|
||||
}
|
||||
|
||||
async function loadGame() {
|
||||
const res = await fetch("/load");
|
||||
const data = await res.json();
|
||||
|
||||
board = data.board;
|
||||
mode = data.mode;
|
||||
|
||||
// Buttons richtig setzen
|
||||
document.getElementById("btnQueens").classList.remove("active");
|
||||
document.getElementById("btnRooks").classList.remove("active");
|
||||
|
||||
if (mode === "queens") {
|
||||
document.getElementById("btnQueens").classList.add("active");
|
||||
} else {
|
||||
document.getElementById("btnRooks").classList.add("active");
|
||||
}
|
||||
|
||||
drawBoard();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user