@@ -167,6 +167,7 @@ class TypingAnimation {
167167 this . selectElement = null ;
168168 this . namesKey = namesKey ;
169169 this . timeoutId = null ;
170+ this . initTimeoutId = null ;
170171 this . changeHandler = null ;
171172 this . focusHandler = null ;
172173 this . blurHandler = null ;
@@ -189,7 +190,7 @@ class TypingAnimation {
189190 this . setupHandlers ( ) ;
190191 this . checkSelection ( ) ;
191192
192- setTimeout ( ( ) => {
193+ this . initTimeoutId = setTimeout ( ( ) => {
193194 if ( ! this . selectElement . value && document . activeElement !== this . selectElement && ! this . selectElement . disabled ) {
194195 this . typingElement . style . display = 'block' ;
195196 this . typingElement . textContent = '|' ;
@@ -203,6 +204,11 @@ class TypingAnimation {
203204 clearTimeout ( this . timeoutId ) ;
204205 this . timeoutId = null ;
205206 }
207+
208+ if ( this . initTimeoutId ) {
209+ clearTimeout ( this . initTimeoutId ) ;
210+ this . initTimeoutId = null ;
211+ }
206212
207213 if ( this . selectElement ) {
208214 if ( this . changeHandler ) {
@@ -1102,6 +1108,33 @@ async function loadAvailableGeographies(pathogen = '') {
11021108 const data = await response . json ( ) ;
11031109 geographySelect . innerHTML = '<option value=""></option>' ;
11041110
1111+ if ( data && data . available_geos ) {
1112+ const geos = data . available_geos ;
1113+ let allGeoNames = [ ] ;
1114+
1115+ geos . forEach ( group => {
1116+ const optgroup = document . createElement ( 'optgroup' ) ;
1117+ optgroup . label = group . text ;
1118+
1119+ if ( group . children && Array . isArray ( group . children ) ) {
1120+ group . children . forEach ( child => {
1121+ const option = document . createElement ( 'option' ) ;
1122+ option . value = child . id ;
1123+ option . textContent = child . text ;
1124+ optgroup . appendChild ( option ) ;
1125+
1126+ allGeoNames . push ( child . text ) ;
1127+ } ) ;
1128+ }
1129+
1130+ geographySelect . appendChild ( optgroup ) ;
1131+ } ) ;
1132+
1133+ if ( allGeoNames . length > 0 ) {
1134+ // Randomize names for typing animation
1135+ window . geographyNames = allGeoNames . sort ( ( ) => Math . random ( ) - 0.5 ) ;
1136+ }
1137+ }
11051138
11061139 setTimeout ( ( ) => {
11071140 initGeographyTypingAnimation ( ) ;
0 commit comments