Our new polling reveals what Britons want for Christmas this year, how this varies by demographics and our Seven Segments, and settles common debates about acceptable gifts!
${percent}%
${hasSubcategories ? ‘Click to see specific items
‘ : ”}
`;
container.appendChild(giftCard);
});
}
function displayGifts(containerId, gifts) {
const container = document.getElementById(containerId);
container.innerHTML = ”;
gifts.forEach(gift => {
const percent = (gift.probability * 100).toFixed(1);
let probClass = ‘low-prob’;
if (gift.probability > 0.6) probClass = ‘high-prob’;
else if (gift.probability > 0.4) probClass = ‘medium-prob’;
const giftCard = document.createElement(‘div’);
giftCard.className = ‘gift-item’;
giftCard.innerHTML = `
${gift.name}
${percent}%
`;
container.appendChild(giftCard);
});
}
function showSubcategories(categoryKey) {
// Get the subcategory keys for this upper category
const subcategoryKeys = CATEGORY_MAPPING[categoryKey];
if (!subcategoryKeys || subcategoryKeys.length === 0) {
alert(‘No specific items available for this category’);
return;
}
// Get all results for these subcategories
const subcategoryResults = subcategoryKeys
.map(key => window.allResults[key])
.filter(result => result !== undefined);
// Sort by probability (highest first) and take top 4
subcategoryResults.sort((a, b) => b.probability – a.probability);
const top4 = subcategoryResults.slice(0, 4);
// Display in the container
displayGifts(‘all-lower-gifts’, top4);
document.getElementById(‘all-lower-container’).classList.remove(‘collapsed’);
// Scroll to subcategories
document.getElementById(‘all-lower-container’).scrollIntoView({ behavior: ‘smooth’, block: ‘nearest’ });
}
function resetForm() {
document.getElementById(‘age’).value = 35;
document.getElementById(‘gender’).value = 0;
document.getElementById(‘party’).value = ‘conservative’;
document.getElementById(‘results’).classList.remove(‘active’);
}