From ce1705aead18472ea0b088c1a745aa0994d639e3 Mon Sep 17 00:00:00 2001 From: Dmytro Trotsko Date: Thu, 11 Dec 2025 00:50:17 +0200 Subject: [PATCH] Fixed available geo auto type --- src/assets/js/alter_dashboard.js | 35 +++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/assets/js/alter_dashboard.js b/src/assets/js/alter_dashboard.js index a0a0099..aa92f63 100644 --- a/src/assets/js/alter_dashboard.js +++ b/src/assets/js/alter_dashboard.js @@ -167,6 +167,7 @@ class TypingAnimation { this.selectElement = null; this.namesKey = namesKey; this.timeoutId = null; + this.initTimeoutId = null; this.changeHandler = null; this.focusHandler = null; this.blurHandler = null; @@ -189,7 +190,7 @@ class TypingAnimation { this.setupHandlers(); this.checkSelection(); - setTimeout(() => { + this.initTimeoutId = setTimeout(() => { if (!this.selectElement.value && document.activeElement !== this.selectElement && !this.selectElement.disabled) { this.typingElement.style.display = 'block'; this.typingElement.textContent = '|'; @@ -203,6 +204,11 @@ class TypingAnimation { clearTimeout(this.timeoutId); this.timeoutId = null; } + + if (this.initTimeoutId) { + clearTimeout(this.initTimeoutId); + this.initTimeoutId = null; + } if (this.selectElement) { if (this.changeHandler) { @@ -1102,6 +1108,33 @@ async function loadAvailableGeographies(pathogen = '') { const data = await response.json(); geographySelect.innerHTML = ''; + if (data && data.available_geos) { + const geos = data.available_geos; + let allGeoNames = []; + + geos.forEach(group => { + const optgroup = document.createElement('optgroup'); + optgroup.label = group.text; + + if (group.children && Array.isArray(group.children)) { + group.children.forEach(child => { + const option = document.createElement('option'); + option.value = child.id; + option.textContent = child.text; + optgroup.appendChild(option); + + allGeoNames.push(child.text); + }); + } + + geographySelect.appendChild(optgroup); + }); + + if (allGeoNames.length > 0) { + // Randomize names for typing animation + window.geographyNames = allGeoNames.sort(() => Math.random() - 0.5); + } + } setTimeout(() => { initGeographyTypingAnimation();