user cookie is set when sending word
This commit is contained in:
parent
dc3ee12e48
commit
8f6b096d17
37
owe.js
37
owe.js
@ -63,18 +63,31 @@ function onReloadClicked() {
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendWord() {
|
async function sendWord() {
|
||||||
var data = new FormData();
|
try {
|
||||||
data.append('submitted', encodeURI(document.getElementById("wordinput").value));
|
var data = new FormData();
|
||||||
data.append('user', getNextPlayer());
|
var wordInput = document.getElementById("wordinput");
|
||||||
const Http = new XMLHttpRequest();
|
data.append('submitted', encodeURI(wordInput.value));
|
||||||
Http.open('POST', '.');
|
|
||||||
Http.onreadystatechange=(e)=>{
|
// Use await to get the next player asynchronously
|
||||||
document.getElementById("wordinput").value = "";
|
var nextPlayer = await getNextPlayer();
|
||||||
loadSentences(false, false);
|
data.append('user', nextPlayer);
|
||||||
resetUnread();
|
|
||||||
}
|
const Http = new XMLHttpRequest();
|
||||||
Http.send(data);
|
Http.open('POST', '.');
|
||||||
|
Http.onreadystatechange = (e) => {
|
||||||
|
wordInput.value = "";
|
||||||
|
loadSentences(false, false);
|
||||||
|
resetUnread();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set the 'owe_user' cookie with the value obtained from getNextPlayer
|
||||||
|
document.cookie = `owe_user=${encodeURIComponent(nextPlayer)}; path=/`;
|
||||||
|
|
||||||
|
Http.send(data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in sendWord:", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayNotification(word) {
|
function displayNotification(word) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user