File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change 3535 // Load theme before the preloader is shown
3636 document . querySelector ( ":root" ) . className = JSON . parse ( localStorage . getItem ( "options" ) ) . theme ;
3737
38- // Cycle loading messages
38+ // Define loading messages
3939 const loadingMsgs = [
4040 "Proving P = NP..." ,
4141 "Computing 6 x 9..." ,
4949 "Navigating neural network..." ,
5050 "Importing machine learning..."
5151 ] ;
52+
53+ // Shuffle array using Durstenfeld algorithm
54+ for ( let i = loadingMsgs . length - 1 ; i > 0 ; -- i ) {
55+ const j = Math . floor ( Math . random ( ) * ( i + 1 ) ) ;
56+ const temp = loadingMsgs [ i ] ;
57+ loadingMsgs [ i ] = loadingMsgs [ j ] ;
58+ loadingMsgs [ j ] = temp ;
59+ }
60+
61+ // Show next loading message then move it to the end of the array
5262 function changeLoadingMsg ( ) {
63+ const msg = loadingMsgs . shift ( ) ;
5364 try {
5465 const el = document . getElementById ( "preloader-msg" ) ;
5566 el . className = "loading" ; // Causes CSS transition on first message
56- el . innerHTML = loadingMsgs [ Math . floor ( Math . random ( ) * loadingMsgs . length ) ] ;
57- } catch ( err ) { }
67+ el . innerHTML = msg ;
68+ } catch ( err ) { } // Ignore errors if DOM not yet ready
69+ loadingMsgs . push ( msg ) ;
5870 }
71+
5972 changeLoadingMsg ( ) ;
60- window . loadingMsgsInt = setInterval ( changeLoadingMsg , ( Math . random ( ) * 500 ) + 500 ) ;
73+ window . loadingMsgsInt = setInterval ( changeLoadingMsg , ( Math . random ( ) * 1000 ) + 1000 ) ;
6174 </ script >
6275 </ head >
6376 < body >
You can’t perform that action at this time.
0 commit comments