feat: language switch reloads page (fixes chat), fun loading phrases

- Language switch now does full page reload so chat reinitializes
- Replaced boring "Initializing AI model..." with 14 fun random phrases
- Phrases are bilingual (ES/EN), CV-themed, with emojis
This commit is contained in:
juanatsap
2026-05-04 15:00:46 +01:00
parent 075a58efe4
commit ef958dffe5
2 changed files with 39 additions and 11 deletions
@@ -22,21 +22,13 @@
<div class="language-selector" id="language-selector">
<button class="selector-btn {{if eq .Lang "en"}}active{{end}}"
data-short="EN"
hx-get="/switch-language?lang=en"
hx-target="#language-selector"
hx-swap="outerHTML swap:250ms settle:250ms"
hx-indicator="#lang-indicator-en"
hx-push-url="/?lang=en"
onclick="window.location.href='/?lang=en'"
aria-label="English">
<span>English</span>
</button>
<button class="selector-btn {{if eq .Lang "es"}}active{{end}}"
data-short="ES"
hx-get="/switch-language?lang=es"
hx-target="#language-selector"
hx-swap="outerHTML swap:250ms settle:250ms"
hx-indicator="#lang-indicator-es"
hx-push-url="/?lang=es"
onclick="window.location.href='/?lang=es'"
aria-label="Español">
<span>Español</span>
</button>
+37 -1
View File
@@ -118,6 +118,42 @@
var chatModelReady = false;
var chatWarmedUp = false;
// Fun loading phrases — random per request
var chatLoadingPhrases = {{if eq .Lang "es"}}[
'Repasando mi currículum… 📄',
'Recordando mis proyectos… 🧠',
'Calentando neuronas… ⚡',
'Preparando mi mejor versión… 💪',
'Buscando en mis recuerdos… 🔍',
'Consultando mi experiencia… 💼',
'Un momento, que me concentro… 🎯',
'Revisando 21 años de código… ⏳',
'Encendiendo el cerebro digital… 🤖',
'Organizando ideas… 💡',
'Dame un segundo… ☕',
'Casi listo, paciencia… 🏗️',
'Activando modo profesional… 👨‍💻',
'Conectando con mi yo digital… 🔌'
]{{else}}[
'Reviewing my CV… 📄',
'Remembering my projects… 🧠',
'Warming up neurons… ⚡',
'Preparing my best self… 💪',
'Searching my memories… 🔍',
'Consulting my experience… 💼',
'One moment, focusing… 🎯',
'Scanning 21 years of code… ⏳',
'Booting up the digital brain… 🤖',
'Organizing thoughts… 💡',
'Give me a second… ☕',
'Almost there, hang tight… 🏗️',
'Activating professional mode… 👨‍💻',
'Connecting to my digital self… 🔌'
]{{end}};
function chatLoadingPhrase() {
return chatLoadingPhrases[Math.floor(Math.random() * chatLoadingPhrases.length)];
}
// Poll model status until ready
function pollChatStatus() {
fetch('/api/chat/status').then(function(r) { return r.json(); }).then(function(data) {
@@ -217,7 +253,7 @@ document.addEventListener('htmx:beforeRequest', function(event) {
var statusEl = document.getElementById('chat-status-text');
var dotsEl = document.querySelector('.chat-typing-dots');
if (!chatModelReady && statusEl && dotsEl) {
statusEl.textContent = '{{if eq .Lang "es"}}Inicializando modelo IA…{{else}}Initializing AI model…{{end}}';
statusEl.textContent = chatLoadingPhrase();
statusEl.style.display = 'inline';
dotsEl.style.display = 'none';
} else if (statusEl && dotsEl) {