Add implementation

This commit is contained in:
yannickschuchmann
2026-03-08 18:01:28 +00:00
parent cc5394c3db
commit b936095286
56 changed files with 68376 additions and 49 deletions

39
dist/server/ssr/assets/poll-R5-eIJ_b.js vendored Normal file
View File

@@ -0,0 +1,39 @@
function createPoll(title) {
return {
title,
options: []
};
}
function addOption(poll, text) {
poll.options.push({
id: crypto.randomUUID(),
text,
votes: []
});
}
function hasVoted(poll, optionId, peerId) {
const option = poll.options.find((o) => o.id === optionId);
if (!option) return false;
return option.votes.includes(peerId);
}
function vote(poll, optionId, peerId) {
const option = poll.options.find((o) => o.id === optionId);
if (!option) return;
if (option.votes.includes(peerId)) return;
option.votes.push(peerId);
}
function unvote(poll, optionId, peerId) {
const option = poll.options.find((o) => o.id === optionId);
if (!option) return;
const idx = option.votes.indexOf(peerId);
if (idx !== -1) {
option.votes.splice(idx, 1);
}
}
export {
addOption as a,
createPoll as c,
hasVoted as h,
unvote as u,
vote as v
};