updated avatars, version label moved
All checks were successful
Deploy FluentGerman.ai / deploy (push) Successful in 52s
All checks were successful
Deploy FluentGerman.ai / deploy (push) Successful in 52s
This commit is contained in:
@@ -28,8 +28,7 @@ function relativeTime(dateStr) {
|
||||
return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' });
|
||||
}
|
||||
|
||||
// Avatar — DiceBear "avataaars" style for friendly illustrated headshots
|
||||
const AVATAR_SEEDS = ['Felix', 'Lena', 'Hans', 'Sophie', 'Klaus', 'Marta', 'Otto', 'Emma'];
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
if (!requireAuth()) return;
|
||||
@@ -38,10 +37,18 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
const displayName = user?.username || 'User';
|
||||
document.getElementById('user-name').textContent = displayName;
|
||||
|
||||
// Random avatar from DiceBear
|
||||
// Deterministic avatar based on username (tutor1.jpg - tutor5.jpg)
|
||||
const avatarImg = document.getElementById('avatar-img');
|
||||
const seed = AVATAR_SEEDS[Math.floor(Math.random() * AVATAR_SEEDS.length)];
|
||||
avatarImg.src = `https://api.dicebear.com/9.x/avataaars/svg?seed=${seed}&backgroundColor=b6e3f4,c0aede,d1d4f9`;
|
||||
|
||||
// Simple hash function for username
|
||||
let hash = 0;
|
||||
for (let i = 0; i < displayName.length; i++) {
|
||||
hash = displayName.charCodeAt(i) + ((hash << 5) - hash);
|
||||
}
|
||||
|
||||
// Map hash to index 1-5
|
||||
const avatarIndex = (Math.abs(hash) % 5) + 1;
|
||||
avatarImg.src = `/img/tutor${avatarIndex}.jpg`;
|
||||
|
||||
const messagesEl = document.getElementById('chat-messages');
|
||||
const inputEl = document.getElementById('chat-input');
|
||||
|
||||
Reference in New Issue
Block a user