@@ -199,27 +199,36 @@ TABS.calibration.initialize = function (callback) {
199199
200200 $ ( button ) . addClass ( 'disabled' ) ;
201201
202- modalProcessing = new jBox ( 'Modal' , {
202+ let modalProcessing = new jBox ( 'Modal' , {
203203 width : 400 ,
204204 height : 100 ,
205205 animation : false ,
206206 closeOnClick : false ,
207207 closeOnEsc : false ,
208- content : $ ( '#modal-compass-processing' )
208+ content : $ ( '#modal-compass-processing' ) . clone ( )
209209 } ) . open ( ) ;
210210
211211 var countdown = 30 ;
212212 helper . interval . add ( 'compass_calibration_interval' , function ( ) {
213213 countdown -- ;
214- $ ( '#modal-compass-countdown' ) . text ( countdown ) ;
215214 if ( countdown === 0 ) {
216- $ ( button ) . removeClass ( 'disabled' ) ;
217-
218- modalProcessing . close ( ) ;
219- GUI . log ( chrome . i18n . getMessage ( 'initialSetupMagCalibEnded' ) ) ;
220- MSP . send_message ( MSPCodes . MSP_CALIBRATION_DATA , false , false , updateSensorData ) ;
221- helper . interval . remove ( 'compass_calibration_interval' ) ;
215+ setTimeout ( function ( ) {
216+ $ ( button ) . removeClass ( 'disabled' ) ;
217+
218+ modalProcessing . close ( ) ;
219+ GUI . log ( chrome . i18n . getMessage ( 'initialSetupMagCalibEnded' ) ) ;
220+
221+ MSP . send_message ( MSPCodes . MSP_CALIBRATION_DATA , false , false , updateSensorData ) ;
222+ helper . interval . remove ( 'compass_calibration_interval' ) ;
223+
224+ //Cleanup
225+ delete modalProcessing ;
226+ $ ( '.jBox-wrapper' ) . remove ( ) ;
227+ } , 1000 ) ;
228+ } else {
229+ modalProcessing . content . find ( '.modal-compass-countdown' ) . text ( countdown ) ;
222230 }
231+
223232 } , 1000 ) ;
224233 } ) ;
225234
0 commit comments