@@ -141,8 +141,23 @@ function startTerminal() {
141141 var status = document . getElementById ( 'terminal-status' ) ;
142142 if ( status ) status . textContent = 'Loading...' ;
143143
144+ // Replace placeholder with loading animation
145+ var tbody = document . getElementById ( 'terminal-body' ) ;
146+ if ( tbody ) tbody . classList . add ( 'loading' ) ;
144147 var ph = document . getElementById ( 'terminal-placeholder' ) ;
145- if ( ph ) ph . remove ( ) ;
148+ if ( ph ) {
149+ ph . innerHTML =
150+ '<pre id="terminal-ascii">' +
151+ '<span id="terminal-spinner"></span>\n\n' +
152+ '<span class="tp-info">Loading Alpine Linux terminal...</span>\n' +
153+ '</pre>' ;
154+ var frames = [ '|' , '/' , '-' , '\\' ] ;
155+ var fi = 0 ;
156+ var spinner = document . getElementById ( 'terminal-spinner' ) ;
157+ var spinInterval = setInterval ( function ( ) {
158+ if ( spinner ) spinner . textContent = ' ' + frames [ fi ++ % 4 ] ;
159+ } , 150 ) ;
160+ }
146161
147162 var script = document . createElement ( 'script' ) ;
148163 script . src = '/v86/libv86.js' ;
@@ -169,18 +184,8 @@ function startTerminal() {
169184 disable_mouse : true ,
170185 } ;
171186
172- fetch ( '/v86/vm_state.bin' , { method : 'HEAD' } ) . then ( function ( r ) {
173- if ( r . ok ) {
174- if ( status ) status . textContent = 'Restoring...' ;
175- config . initial_state = { url : '/v86/vm_state.bin' } ;
176- } else {
177- if ( status ) status . textContent = 'Booting...' ;
178- }
179- bootEmulator ( config , status ) ;
180- } ) . catch ( function ( ) {
181- if ( status ) status . textContent = 'Booting...' ;
182- bootEmulator ( config , status ) ;
183- } ) ;
187+ if ( status ) status . textContent = 'Booting...' ;
188+ bootEmulator ( config , status ) ;
184189 } ;
185190 script . onerror = function ( ) {
186191 if ( status ) status . textContent = 'Failed to load' ;
@@ -190,18 +195,19 @@ function startTerminal() {
190195}
191196
192197function bootEmulator ( config , status ) {
193- var useSnapshot = ! ! config . initial_state ;
194-
195198 emulator = new V86 ( config ) ;
196199
197200 emulator . add_listener ( 'emulator-ready' , function ( ) {
198201 if ( status ) status . textContent = '' ;
202+ var ph = document . getElementById ( 'terminal-placeholder' ) ;
203+ if ( ph ) ph . remove ( ) ;
204+ var tbody = document . getElementById ( 'terminal-body' ) ;
205+ if ( tbody ) tbody . classList . remove ( 'loading' ) ;
199206 v86Loading = false ;
200207 updateTerminalSpacing ( ) ;
201208
202209 if ( pendingCommand ) {
203- var delay = useSnapshot ? 500 : 30000 ;
204- setTimeout ( typePendingCommand , delay ) ;
210+ setTimeout ( typePendingCommand , 30000 ) ;
205211 }
206212 } ) ;
207213}
0 commit comments