18 lines
529 B
JavaScript
Raw Normal View History

2026-05-23 08:34:13 +02:00
import { Http } from "./Http.js";
2026-05-23 01:50:31 +02:00
export class VoteManager {
constructor() {
this.initVoteButtons();
}
initVoteButtons() {
document.querySelectorAll(".post-action-btn[data-vote]").forEach((btn) => {
2026-05-23 08:34:13 +02:00
btn.addEventListener("click", () => {
2026-05-23 01:50:31 +02:00
const targetUid = btn.dataset.target;
const targetType = btn.dataset.type || "post";
2026-05-23 08:34:13 +02:00
Http.postForm(`/votes/${targetType}/${targetUid}`, { value: btn.dataset.vote });
2026-05-23 01:50:31 +02:00
});
});
}
}