@@ -349,13 +349,36 @@ <h4>Graphics main window</h4>
349349 } , false ) ;
350350
351351 // Loading Animation
352- $ ( 'body' ) . on ( 'DOMNodeInserted' , 'pre' , function ( ) {
353- $ ( '#loader-wrapper' ) . addClass ( "tester" )
354- } ) ;
352+ // Select the body element
353+ var targetNode = document . querySelector ( 'body' ) ;
354+
355+ // Options for the observer (which mutations to observe)
356+ var config = { childList : true , subtree : true } ;
357+
358+ // Callback function to execute when mutations are observed
359+ var callback = function ( mutationsList , observer ) {
360+ mutationsList . forEach ( function ( mutation ) {
361+ // Check if any new nodes are added
362+ mutation . addedNodes . forEach ( function ( node ) {
363+ // If the added node is a <pre> element
364+ if ( node . nodeName === 'SPAN' && node . classList . contains ( "stdout" ) ) {
365+ // Add the class 'tester' to #loader-wrapper
366+ document . querySelector ( '#loader-wrapper' ) . classList . add ( "tester" ) ;
367+ }
368+ } ) ;
369+ } ) ;
370+ } ;
371+
372+ // Create an observer instance linked to the callback function
373+ var observer = new MutationObserver ( callback ) ;
374+
375+ // Start observing the target node for configured mutations
376+ observer . observe ( targetNode , config ) ;
377+
355378 document . getElementById ( "loader-wrapper" ) . addEventListener ( "animationend" , ( ev ) => {
356379 if ( ev . type === "animationend" ) {
357380 document . getElementById ( "loader-wrapper" ) . style . display = "none" ;
358- $ ( 'body' ) . off ( 'DOMNodeInserted' ) ;
381+ observer . disconnect ( ) ;
359382 if ( autosave_number ( ) > 0 ) {
360383 if ( confirm ( "Des documents ont été sauvegardé automatiquement lors de la dernière session, voulez vous les restaurer ?" ) ) {
361384 restore_editors ( ) ;
0 commit comments