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);
|
||||
}
|
||||
|
||||
function sendWord() {
|
||||
var data = new FormData();
|
||||
data.append('submitted', encodeURI(document.getElementById("wordinput").value));
|
||||
data.append('user', getNextPlayer());
|
||||
const Http = new XMLHttpRequest();
|
||||
Http.open('POST', '.');
|
||||
Http.onreadystatechange=(e)=>{
|
||||
document.getElementById("wordinput").value = "";
|
||||
loadSentences(false, false);
|
||||
resetUnread();
|
||||
}
|
||||
Http.send(data);
|
||||
async function sendWord() {
|
||||
try {
|
||||
var data = new FormData();
|
||||
var wordInput = document.getElementById("wordinput");
|
||||
data.append('submitted', encodeURI(wordInput.value));
|
||||
|
||||
// Use await to get the next player asynchronously
|
||||
var nextPlayer = await getNextPlayer();
|
||||
data.append('user', nextPlayer);
|
||||
|
||||
const Http = new XMLHttpRequest();
|
||||
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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user