Add draw requests and rematches
This commit is contained in:
parent
1a221bf680
commit
2f46d86947
6 changed files with 297 additions and 7 deletions
6
public/scripts/handle-redirects.js
Normal file
6
public/scripts/handle-redirects.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
document.addEventListener('htmx:wsAfterMessage', function (e) {
|
||||
const message = JSON.parse(e.detail.message);
|
||||
if (message.type === 'redirect_to_game') {
|
||||
window.location.href = '/?gameId=' + message.gameId;
|
||||
}
|
||||
});
|
||||
|
|
@ -27,5 +27,29 @@ document.addEventListener('htmx:wsConfigSend', function (e) {
|
|||
e.detail.parameters = {
|
||||
type: 'decline_takeback',
|
||||
};
|
||||
} else if (e.target.id == 'draw-button') {
|
||||
e.detail.parameters = {
|
||||
type: 'request_draw',
|
||||
};
|
||||
} else if (e.target.id == 'accept-draw-button') {
|
||||
e.detail.parameters = {
|
||||
type: 'accept_draw',
|
||||
};
|
||||
} else if (e.target.id == 'decline-draw-button') {
|
||||
e.detail.parameters = {
|
||||
type: 'decline_draw',
|
||||
};
|
||||
} else if (e.target.id == 'rematch-button') {
|
||||
e.detail.parameters = {
|
||||
type: 'request_rematch',
|
||||
};
|
||||
} else if (e.target.id == 'accept-rematch-button') {
|
||||
e.detail.parameters = {
|
||||
type: 'accept_rematch',
|
||||
};
|
||||
} else if (e.target.id == 'decline-rematch-button') {
|
||||
e.detail.parameters = {
|
||||
type: 'decline_rematch',
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue