Files
HiActs-Conference-Poll/templates/poll.html
T
beantownbabeandClaude Sonnet 4.6 27a59671fc Initial commit: HiActs Conference Poll app
Flask poll app for the Hi-Acts 3rd Network Meeting at DESY Hamburg,
10 June 2026. Includes 11-question poll, live D3 bubble chart display,
7-page PDF analysis report, admin dashboard, and CSV export.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-05 15:38:17 +02:00

438 lines
20 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<!--
poll.html — Attendee Poll Page
This is the page attendees see when they scan the QR code.
They answer all questions one by one and reach a thank-you screen at the end.
No sidebar on this page — designed for phone and tablet use.
-->
<head>
<meta charset="UTF-8">
<!-- Prevents the phone from zooming in when tapping answer buttons -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>HiActs Innovation Challenge</title>
<style>
/* ── RESET ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* ── BODY: full height, column layout ── */
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
background: #f0f4f8;
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* ── TOP BAR: event branding left, tagline right, no button ── */
.top-bar {
flex-shrink: 0;
background: white; border-bottom: 1px solid #dde5ee;
display: grid; grid-template-columns: auto 1fr; align-items: stretch; gap: 0;
}
.top-bar-event {
background: linear-gradient(160deg, #0f2744 0%, #1a4a8a 60%, #1d6fa8 100%);
color: white; padding: 12px 16px; text-align: center;
display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.top-bar-event-title { font-size: 13px; font-weight: 900; line-height: 1.15; letter-spacing: -0.3px; }
.top-bar-event-title span { color: #5db8f5; }
.top-bar-event-meta { font-size: 8px; color: #f5c842; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; line-height: 1.5; }
.top-bar-center { text-align: right; padding: 10px 16px; display: flex; flex-direction: column; justify-content: center; }
.top-bar h1 { font-size: 16px; font-weight: 700; color: #1a365d; }
.top-bar .meta { font-size: 13px; color: #8a9baf; margin-top: 3px; }
/* ── MOBILE: phones and small tablets ── */
@media (max-width: 600px) {
.question-card { padding: 20px 16px 16px; }
.question-text { font-size: 19px; }
.option-btn { font-size: 15px; padding: 13px 16px; }
.submit-btn { font-size: 16px; padding: 15px; }
.thankyou h2 { font-size: 22px; }
.results-btn { font-size: 15px; padding: 14px 24px; }
}
/* Button linking to the live results page */
.live-results-btn {
background: linear-gradient(135deg, #2563eb, #7c3aed);
color: white; border: none; border-radius: 8px;
padding: 7px 14px; font-size: 12px; font-weight: 700;
cursor: pointer; font-family: inherit; text-decoration: none;
white-space: nowrap; display: inline-block;
}
/* ── PROGRESS BAR: thin coloured strip showing how far through the poll ── */
.progress-bar { height: 5px; background: #d0dae6; }
.progress-fill {
height: 100%;
background: linear-gradient(90deg, #4A9EFF, #5CDB95);
transition: width 0.5s ease;
border-radius: 0 3px 3px 0;
}
/* ── QUESTION CARD: the main content area for each question ── */
.question-card {
flex: 1; padding: 28px 20px 20px;
display: flex; flex-direction: column;
animation: fadeIn 0.3s ease;
}
/* Smooth fade-in animation when moving to the next question */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
/* "Question X of Y" label above the question text */
.question-number {
font-size: 11px; color: #8a9baf; font-weight: 700;
letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 10px;
}
/* The question text itself */
.question-text {
font-size: 22px; font-weight: 800; color: #1a365d;
line-height: 1.3; margin-bottom: 28px;
}
/* ── MULTIPLE CHOICE: list of answer buttons ── */
.options { display: flex; flex-direction: column; gap: 11px; }
.option-btn {
background: white; border: 2px solid #dde5ee; border-radius: 14px;
padding: 15px 18px; font-size: 16px; color: #2d3748;
text-align: left; cursor: pointer;
transition: border-color 0.12s, background 0.12s, transform 0.08s;
-webkit-tap-highlight-color: transparent; /* removes grey flash on iOS tap */
font-family: inherit; line-height: 1.3;
}
.option-btn:active { transform: scale(0.98); }
/* Highlighted state when an option is selected */
.option-btn.selected { border-color: #4A9EFF; background: #ebf4ff; color: #1a365d; font-weight: 600; }
.option-btn:disabled { cursor: default; }
/* ── FREE TEXT: typed answer input ── */
.free-text-container { display: flex; flex-direction: column; gap: 14px; }
.free-text-input {
background: white; border: 2px solid #dde5ee; border-radius: 14px;
padding: 16px 18px; font-size: 18px; color: #2d3748;
outline: none; transition: border-color 0.15s; width: 100%; font-family: inherit;
}
.free-text-input:focus { border-color: #4A9EFF; }
.spacer { flex: 1; }
/* Submit button for free-text questions */
.submit-btn {
background: linear-gradient(135deg, #4A9EFF, #3a7ee0);
color: white; border: none; border-radius: 14px;
padding: 17px 20px; font-size: 17px; font-weight: 700;
cursor: pointer; transition: opacity 0.15s, transform 0.08s;
width: 100%; font-family: inherit; margin-top: 16px; letter-spacing: 0.2px;
}
.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { background: #a0aec0; cursor: not-allowed; }
/* ── THANK YOU SCREEN: shown after all questions are answered ── */
.thankyou {
flex: 1; display: flex; flex-direction: column;
align-items: center; justify-content: center;
text-align: center; padding: 40px 24px;
animation: fadeIn 0.4s ease;
}
.thankyou h2 { font-size: 26px; color: #1a365d; font-weight: 800; margin-bottom: 12px; }
.thankyou p { font-size: 15px; color: #718096; line-height: 1.6; max-width: 280px; }
/* Button to go to the live results page after completing the poll */
.results-btn {
display: inline-block; margin-top: 24px;
background: linear-gradient(135deg, #2563eb, #059669);
color: white; text-decoration: none; border-radius: 14px;
padding: 16px 32px; font-size: 17px; font-weight: 700;
transition: opacity 0.15s, transform 0.08s;
}
.results-btn:active { transform: scale(0.98); opacity: 0.9; }
/* Small event branding at the bottom of the thank-you screen */
.thankyou .brand { margin-top: 32px; font-size: 12px; color: #a0aec0; letter-spacing: 0.5px; }
/* Utility class — hides any element */
.hidden { display: none !important; }
</style>
</head>
<body>
<!-- ── POLL COLUMN: the full page content ── -->
<div class="poll-col" style="flex:1;display:flex;flex-direction:column;min-height:100vh;">
<!-- Top bar: event branding left, tagline centre, live results button right -->
<div class="top-bar">
<div class="top-bar-event">
<div class="top-bar-event-meta">Hi-Acts · 3rd Network Meeting</div>
<div class="top-bar-event-title">Innovation <span>Challenge</span> Arena</div>
<div class="top-bar-event-meta">Data and Software Standardization</div>
</div>
<div class="top-bar-center">
<h1>Every perspective matters.</h1>
<div class="meta">Help us gain insight across the beamline community.</div>
</div>
</div>
<!-- Progress bar — fills from left to right as questions are answered -->
<div class="progress-bar">
<div class="progress-fill" id="progressFill" style="width: 0%"></div>
</div>
<!-- Question card — built and replaced by JavaScript for each question -->
<div id="questionCard" class="question-card"></div>
<!-- Thank-you screen — hidden until all questions are answered -->
<div id="thankYou" class="thankyou hidden">
<h2>Thank you!</h2>
<p>Your answers help us understand real data challenges across the beamline community.</p>
<!-- Takes the attendee to the live results page -->
<a href="/q/1" class="results-btn">See live results &rarr;</a>
<div class="brand">Hi-Acts · 3rd Network Meeting · DESY Hamburg</div>
</div>
</div>
<script>
/* ── QUESTIONS ──
Loaded from the server (defined in app.py).
{{ questions | tojson }} is replaced by real data when the page loads. */
const QUESTIONS = {{ questions | tojson }};
/* Tracks which question the attendee is currently on */
let currentIndex = 0;
/* ── showQuestion ──
Renders the question at the given index.
After all questions shows the comment step, then the thank-you screen. */
function showQuestion(index) {
if (index === QUESTIONS.length) {
showCommentStep();
return;
}
if (index > QUESTIONS.length) {
document.getElementById('questionCard').classList.add('hidden');
document.getElementById('thankYou').classList.remove('hidden');
document.getElementById('progressFill').style.width = '100%';
return;
}
const q = QUESTIONS[index];
const progress = (index / QUESTIONS.length) * 100;
document.getElementById('progressFill').style.width = progress + '%';
/* Build the HTML for this question */
let html = `
<div class="question-number">Question ${index + 1} of ${QUESTIONS.length}</div>
<div class="question-text">${q.text}</div>
`;
if (q.type === 'multiple_choice') {
/* Render a button for each answer option */
html += '<div class="options">';
q.options.forEach(opt => {
const safeOpt = opt.replace(/'/g, "\\'").replace(/"/g, '&quot;');
html += `<button class="option-btn" onclick="selectOption(this, '${safeOpt}', ${q.id})">${opt}</button>`;
});
html += '</div>';
} else {
/* Render a text input field for free-text questions */
html += `
<div class="free-text-container">
<input type="text" class="free-text-input" id="freeTextInput"
placeholder="${q.placeholder || 'Your answer...'}"
maxlength="200"
onkeydown="if(event.key==='Enter') submitFreeText(${q.id})">
</div>
<div class="spacer"></div>
<button class="submit-btn" id="submitBtn" onclick="submitFreeText(${q.id})">Submit &rarr;</button>
`;
}
/* Inject the HTML and replay the fade-in animation */
const card = document.getElementById('questionCard');
card.innerHTML = html;
card.style.animation = 'none';
card.offsetHeight; /* forces browser to reset animation */
card.style.animation = 'fadeIn 0.3s ease';
/* Auto-focus the text input on free-text questions */
if (q.type === 'free_text') {
setTimeout(() => {
const input = document.getElementById('freeTextInput');
if (input) input.focus();
}, 100);
}
}
/* ── selectOption ──
Called when an attendee taps a multiple-choice button.
If "Other" is selected, shows a free-text field instead of submitting immediately. */
function selectOption(btn, answer, qId) {
/* Clear any previously selected button */
document.querySelectorAll('.option-btn').forEach(b => {
b.classList.remove('selected');
b.disabled = false;
});
btn.classList.add('selected');
/* Remove any existing "Other" text field */
const existing = document.getElementById('otherInputWrap');
if (existing) existing.remove();
if (answer === 'Other') {
/* Show a free-text input with a 10-word limit */
const wrap = document.createElement('div');
wrap.id = 'otherInputWrap';
wrap.style.marginTop = '14px';
wrap.innerHTML = `
<input type="text" class="free-text-input" id="otherTextField"
placeholder="Max 10 words..."
onkeydown="if(event.key==='Enter') submitOther(${qId})"
oninput="enforceWordLimit(this, 10)">
<div id="wordCount" style="font-size:11px;color:#8a9baf;text-align:right;margin-top:4px">0 / 10 words</div>
<button class="submit-btn" id="otherSubmitBtn" onclick="submitOther(${qId})" style="margin-top:10px">Submit &rarr;</button>
`;
document.querySelector('.options').appendChild(wrap);
setTimeout(() => document.getElementById('otherTextField').focus(), 50);
return;
}
/* For any other option, disable all buttons and submit immediately */
document.querySelectorAll('.option-btn').forEach(b => b.disabled = true);
submitAnswer(qId, answer);
}
/* ── enforceWordLimit ──
Prevents the "Other" text field from exceeding the word limit.
Updates the live word counter below the input. */
function enforceWordLimit(input, max) {
const words = input.value.trim().split(/\s+/).filter(w => w.length > 0);
const counter = document.getElementById('wordCount');
if (words.length > max) {
input.value = words.slice(0, max).join(' ');
}
const current = input.value.trim() === '' ? 0 : input.value.trim().split(/\s+/).filter(w => w.length > 0).length;
if (counter) {
counter.textContent = `${current} / ${max} words`;
counter.style.color = current >= max ? '#FC8181' : '#8a9baf';
}
}
/* ── submitOther ──
Called when the attendee submits an "Other" free-text answer.
Validates that the field is not empty before submitting. */
function submitOther(qId) {
const input = document.getElementById('otherTextField');
const btn = document.getElementById('otherSubmitBtn');
const answer = input ? input.value.trim() : '';
if (!answer) {
if (input) input.style.borderColor = '#FC8181'; /* flash red if empty */
return;
}
document.querySelectorAll('.option-btn').forEach(b => b.disabled = true);
if (input) input.disabled = true;
if (btn) btn.disabled = true;
submitAnswer(qId, answer);
}
/* ── submitFreeText ──
Called when the attendee submits a free-text question answer.
Validates that the field is not empty before submitting. */
function submitFreeText(qId) {
const input = document.getElementById('freeTextInput');
const btn = document.getElementById('submitBtn');
const answer = input ? input.value.trim() : '';
if (!answer) {
if (input) input.style.borderColor = '#FC8181';
return;
}
if (input) input.disabled = true;
if (btn) btn.disabled = true;
submitAnswer(qId, answer);
}
/* ── submitAnswer ──
Sends the answer to the server, then moves to the next question after a short delay. */
function submitAnswer(qId, answer) {
fetch('/submit', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ question_id: qId, answer: answer })
})
.then(r => r.json())
.then(() => {
setTimeout(() => {
currentIndex++;
showQuestion(currentIndex);
}, 420); /* short pause before showing the next question */
})
.catch(err => console.error(err));
}
/* ── showCommentStep ──
Shown after all questions are answered. Optional 150-char comment box.
Attendee can submit a comment or skip straight to the thank-you screen. */
function showCommentStep() {
const progress = (QUESTIONS.length / QUESTIONS.length) * 100;
document.getElementById('progressFill').style.width = progress + '%';
const card = document.getElementById('questionCard');
card.classList.remove('hidden');
card.innerHTML = `
<div class="question-number">Almost done</div>
<div class="question-text">Any final thoughts?</div>
<div class="free-text-container">
<textarea id="commentInput" class="free-text-input"
placeholder="Optional — max 150 characters..."
maxlength="150" rows="3"
style="resize:none;font-size:16px;"
oninput="updateCharCount(this)"></textarea>
<div id="charCount" style="font-size:11px;color:#8a9baf;text-align:right;margin-top:4px">0 / 150</div>
</div>
<div class="spacer"></div>
<button class="submit-btn" onclick="submitComment()">Submit comment &rarr;</button>
<button onclick="skipComment()" style="background:none;border:none;color:#8a9baf;font-size:14px;margin-top:12px;cursor:pointer;font-family:inherit;text-decoration:underline;">Skip</button>
`;
card.style.animation = 'none';
card.offsetHeight;
card.style.animation = 'fadeIn 0.3s ease';
}
function updateCharCount(el) {
const count = el.value.length;
const counter = document.getElementById('charCount');
if (counter) {
counter.textContent = count + ' / 150';
counter.style.color = count >= 140 ? '#FC8181' : '#8a9baf';
}
}
function submitComment() {
const input = document.getElementById('commentInput');
const text = input ? input.value.trim() : '';
if (text) {
fetch('/submit_comment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ comment: text })
}).catch(err => console.error(err));
}
currentIndex++;
showQuestion(currentIndex);
}
function skipComment() {
currentIndex++;
showQuestion(currentIndex);
}
/* ── START: load the first question when the page opens ── */
showQuestion(0);
</script>
</body>
</html>