This commit is contained in:
2026-03-05 22:38:31 +02:00
parent e520ff8bc5
commit e879703041
9 changed files with 106 additions and 112 deletions

41
static/js/cards.js Normal file
View File

@@ -0,0 +1,41 @@
(() => {
const CARD_ICONS = ['★', '◆', '✦', '☀', '☘', '⚙', '♣', '♠', '♥', '♦', '✚', '⚡', '☾', '✿'];
function iconForValue(value) {
const normalized = String(value || '');
if (normalized === '?') return '❓';
if (normalized === '☕') return '☕';
if (normalized === '∞') return '∞';
let hash = 0;
for (let i = 0; i < normalized.length; i += 1) {
hash = (hash * 31 + normalized.charCodeAt(i)) >>> 0;
}
return CARD_ICONS[hash % CARD_ICONS.length];
}
function appendFace(el, value) {
const normalized = String(value || '');
const topLeft = document.createElement('span');
topLeft.className = 'card-corner top-left';
topLeft.textContent = normalized;
const center = document.createElement('span');
center.className = 'card-center-icon';
center.textContent = iconForValue(normalized);
const bottomRight = document.createElement('span');
bottomRight.className = 'card-corner bottom-right';
bottomRight.textContent = normalized;
el.appendChild(topLeft);
el.appendChild(center);
el.appendChild(bottomRight);
}
window.CardUI = {
iconForValue,
appendFace,
};
})();