This commit is contained in:
2026-03-05 22:33:06 +02:00
parent 637b5f0167
commit f9843744c7
3 changed files with 46 additions and 8 deletions

View File

@@ -16,8 +16,8 @@ const participantList = document.getElementById('participant-list');
const adminControls = document.getElementById('admin-controls');
const revealBtn = document.getElementById('reveal-btn');
const resetBtn = document.getElementById('reset-btn');
const participantLinkInput = document.getElementById('participant-link');
const adminLinkInput = document.getElementById('admin-link');
const shareLinkInput = document.getElementById('share-link');
const shareAdminToggle = document.getElementById('share-admin-toggle');
const roomStatus = document.getElementById('room-status');
const joinPanel = document.getElementById('join-panel');
@@ -30,6 +30,7 @@ const joinError = document.getElementById('join-error');
let participantID = params.get('participantId') || '';
let adminToken = params.get('adminToken') || '';
let eventSource = null;
let latestLinks = { participantLink: '', adminLink: '' };
const savedUsername = localStorage.getItem(USERNAME_KEY) || '';
joinUsernameInput.value = savedUsername;
@@ -247,8 +248,8 @@ function renderState(state) {
renderCards(state.cards, state.participants, state.revealed);
renderSummary(state);
participantLinkInput.value = `${window.location.origin}${state.links.participantLink}`;
adminLinkInput.value = state.links.adminLink ? `${window.location.origin}${state.links.adminLink}` : '';
latestLinks = state.links || { participantLink: '', adminLink: '' };
updateShareLink();
if (state.viewerIsAdmin) {
adminControls.classList.remove('hidden');
@@ -261,6 +262,12 @@ function renderState(state) {
roomStatus.textContent = `Votes: ${votedCount}/${totalParticipants}`;
}
function updateShareLink() {
const useAdmin = shareAdminToggle.checked && latestLinks.adminLink;
const raw = useAdmin ? latestLinks.adminLink : latestLinks.participantLink;
shareLinkInput.value = raw ? `${window.location.origin}${raw}` : '';
}
function connectSSE() {
if (eventSource) {
eventSource.close();
@@ -326,6 +333,7 @@ async function adminAction(action) {
revealBtn.addEventListener('click', () => adminAction('reveal'));
resetBtn.addEventListener('click', () => adminAction('reset'));
shareAdminToggle.addEventListener('change', updateShareLink);
joinForm.addEventListener('submit', async (event) => {
event.preventDefault();