This guide explains how to use the interactive poll demo and understand the poll feature implementation for NodeBB posts.
The poll feature includes an interactive demo that showcases the complete polling experience without requiring a full NodeBB installation.
Demo Location: poll-demo.html
You can access the demo in several ways:
- Navigate to your project directory
- Open
poll-demo.htmlin any modern web browser - The demo will load with sample polls
# Using Python (if available)
python3 -m http.server 8080
# Using Node.js (if available)
npx http-server
# Using VS Code Live Server extension
# Right-click poll-demo.html → "Open with Live Server"If you have NodeBB running:
- Place
poll-demo.htmlin thepublic/directory - Access via
http://your-nodebb-url/poll-demo.html
The demo page contains two main sections:
- Voting Demo - Shows the poll before a user has voted
- Results Demo - Shows the poll after voting is complete
What You'll See:
- Poll question with a chart icon
- Multiple radio button options (JavaScript, Python, Java)
- A "Vote" button
- Poll expiration information
How to Test:
- Select an Option: Click on any radio button to choose your preference
- Submit Vote: Click the blue "Vote" button
- Watch the Animation: The interface will show a loading spinner
- See Results: After ~800ms, the poll transforms to show results
Expected Behavior:
- Selecting no option and clicking "Vote" shows a warning message
- After voting, the interface changes to results view
- Your selection is highlighted in blue with a checkmark
- Vote counts and percentages are updated
- The vote button disappears (single-vote enforcement)
What You'll See:
- Same poll question with chart icon
- Results display with progress bars
- Vote counts and percentages for each option
- User's selection highlighted in blue
- Total vote count at the bottom
Features Demonstrated:
- Visual Hierarchy: Selected option stands out with primary color
- Progress Bars: Visual representation of vote distribution
- Vote Counts: Exact numbers and percentages
- Responsive Design: Adapts to different screen sizes
┌─────────────────────────────────────┐
│ 📊 Poll Question │
├─────────────────────────────────────┤
│ ○ Option A │
│ ○ Option B │
│ ○ Option C │
│ │
│ [Vote] Poll closes in X days │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│ 📊 Poll Question │
├─────────────────────────────────────┤
│ ✓ Option A 15 votes (60%) │
│ ████████████░░░░░░░░ │
│ │
│ Option B 8 votes (32%) │
│ ████████░░░░░░░░░░░░ │
│ │
│ Option C 2 votes (8%) │
│ ██░░░░░░░░░░░░░░░░░░ │
│ │
│ 👥 25 votes total • Ends in 3 days │
└─────────────────────────────────────┘
- Once you vote, you cannot vote again
- The voting interface is permanently replaced with results
- No way to change your vote (simulates real poll behavior)
- No page refresh required
- Smooth animations between states
- Immediate visual feedback
- Works on desktop and mobile devices
- Progress bars scale appropriately
- Text remains readable at all sizes
- Clear warning if no option is selected
- User-friendly error messages
- Visual feedback for all actions
- Proper ARIA labels for screen readers
- Keyboard navigation support
- High contrast colors for visibility
- Semantic HTML structure
The demo uses hardcoded data to simulate backend responses:
- Vote counts are predetermined
- Percentages are calculated dynamically
- User's vote increments the selected option
The demo code demonstrates how the real implementation will work:
- Same HTML structure as NodeBB templates
- Same CSS classes and styling
- Same JavaScript event handling
- Same component architecture
Supported Browsers:
- Chrome 80+
- Firefox 75+
- Safari 13+
- Edge 80+
Required Features:
- ES6 JavaScript support
- CSS Grid and Flexbox
- Modern event handling
- Check File Path: Ensure
poll-demo.htmlis in the correct directory - Browser Console: Open DevTools and check for JavaScript errors
- File Permissions: Make sure the file is readable
- Internet Connection: Demo uses CDN resources (Bootstrap, jQuery)
- JavaScript Enabled: Ensure JavaScript is enabled in your browser
- Console Errors: Check browser console for error messages
- Click Target: Make sure you're clicking on the radio buttons, not labels
- CDN Access: Demo requires internet for Bootstrap and Font Awesome
- CSS Loading: Check if external stylesheets are blocked
- Browser Zoom: Try resetting browser zoom to 100%
Demo URL: Open poll-demo.html in your browser
Documentation: See README-polls.md for technical details
Implementation: See IMPLEMENTATION-SUMMARY.md for complete overview