File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -260,9 +260,25 @@ <h2>Ask Defang</h2>
260260 // Display user query
261261 chatBox . innerHTML += `<p><strong>You:</strong> ${ query } </p>` ;
262262
263+ let processingMsg = `Processing<span class="loading-dots"><span>.</span><span>.</span><span>.</span></span>` ;
264+ // Animate the loading dots
265+ setTimeout ( ( ) => {
266+ const dots = responseContainer ?. querySelectorAll ( '.loading-dots span' ) ;
267+ if ( ! dots ) return ;
268+ let visible = 1 ;
269+ const interval = setInterval ( ( ) => {
270+ dots . forEach ( ( dot , idx ) => {
271+ dot . style . visibility = idx < visible ? 'visible' : 'hidden' ;
272+ } ) ;
273+ visible = visible < 3 ? visible + 1 : 1 ;
274+ // Stop animation when spinner is hidden (response received)
275+ if ( loadingSpinner . style . display === 'none' ) clearInterval ( interval ) ;
276+ } , 400 ) ;
277+ } , 0 ) ;
278+
263279 // Create a new response container for this query
264280 const responseContainer = document . createElement ( 'p' ) ;
265- responseContainer . innerHTML = `<strong>Assistant:</strong> <span class="assistant-response"></span>` ;
281+ responseContainer . innerHTML = `<strong>Assistant:</strong> <span class="assistant-response">${ processingMsg } </span>` ;
266282 chatBox . appendChild ( responseContainer ) ;
267283
268284 chatBox . scrollTop = chatBox . scrollHeight ;
You can’t perform that action at this time.
0 commit comments