gomoku/public/scripts/send-ws-messages.js

20 lines
478 B
JavaScript

document.addEventListener('htmx:wsConfigSend', function (e) {
if (e.target.classList.contains('intersection')) {
const row = parseInt(e.target.dataset.row);
const col = parseInt(e.target.dataset.col);
console.log(e.target.id);
// Set the custom JSON data
e.detail.parameters = {
type: 'make_move',
row: row,
col: col,
};
} else if (e.target.id == 'resign-button') {
e.detail.parameters = {
type: 'resign'
};
}
});