@@ -722,104 +722,42 @@ const IWSY = (container, script) => {
722
722
handler ( step ) ;
723
723
} ;
724
724
725
- // Initialization
726
- const setup = ( ) => {
727
- container . innerHTML = `` ;
728
- document . removeEventListener ( `click` , init ) ;
729
- if ( mode === `auto` ) {
730
- document . addEventListener ( `click` , onClick ) ;
731
- }
732
- document . onkeydown = null ;
733
- script . container = container ;
734
- container . style . position = `relative` ;
735
- container . style . overflow = `hidden` ;
736
- container . style . cursor = 'none' ;
737
- container . style [ `background-size` ] = `cover` ;
738
- script . speed = `normal` ;
739
- script . labels = { } ;
740
- for ( const [ index , step ] of script . steps . entries ( ) ) {
741
- step . index = index ;
742
- step . script = script ;
743
- if ( typeof step . label !== `undefined` ) {
744
- script . labels [ step . label ] = index ;
745
- }
746
- if ( index < script . steps . length - 1 ) {
747
- step . next = ( ) => {
748
- const next = step . index + 1 ;
749
- setTimeout ( ( ) => {
750
- doStep ( script . steps [ next ] ) ;
751
- } , 0 ) ;
752
- }
725
+ container . innerHTML = `` ;
726
+ document . removeEventListener ( `click` , init ) ;
727
+ if ( mode === `auto` ) {
728
+ document . addEventListener ( `click` , onClick ) ;
729
+ }
730
+ document . onkeydown = null ;
731
+ script . container = container ;
732
+ container . style . position = `relative` ;
733
+ container . style . overflow = `hidden` ;
734
+ container . style . cursor = 'none' ;
735
+ container . style [ `background-size` ] = `cover` ;
736
+ script . speed = `normal` ;
737
+ script . labels = { } ;
738
+ for ( const [ index , step ] of script . steps . entries ( ) ) {
739
+ step . index = index ;
740
+ step . script = script ;
741
+ if ( typeof step . label !== `undefined` ) {
742
+ script . labels [ step . label ] = index ;
743
+ }
744
+ if ( index < script . steps . length - 1 ) {
745
+ step . next = ( ) => {
746
+ const next = step . index + 1 ;
747
+ setTimeout ( ( ) => {
748
+ doStep ( script . steps [ next ] ) ;
749
+ } , 0 ) ;
753
750
}
754
- else {
755
- step . next = ( ) => {
756
- console . log ( `Step ${ index + 1 } : Finished` ) ;
757
- container . style . cursor = 'pointer' ;
758
- }
759
- } ;
760
- }
761
- IWSY . plugins = { } ;
762
- initBlocks ( ) ;
763
- preloadImages ( ) ;
764
- doStep ( script . steps [ 0 ] ) ;
765
- } ;
766
-
767
- // Wait for a click/tap or a keypress to start
768
- document . addEventListener ( `click` , init ) ;
769
- document . onkeydown = function ( event ) {
770
- if ( event . code === `Enter` ) {
771
- mode = `auto` ;
772
751
}
773
- setup ( ) ;
774
- return true ;
775
- } ;
776
- } ;
777
-
778
- window . onload = ( ) => {
779
- const createCORSRequest = ( url ) => {
780
- let xhr = new XMLHttpRequest ( ) ;
781
- if ( `withCredentials` in xhr ) {
782
-
783
- // Check if the XMLHttpRequest object has a "withCredentials" property.
784
- // "withCredentials" only exists on XMLHTTPRequest2 objects.
785
- xhr . open ( `GET` , url , true ) ;
786
-
787
- } else if ( typeof XDomainRequest != `undefined` ) {
788
-
789
- // Otherwise, check if XDomainRequest.
790
- // XDomainRequest only exists in IE, and is IE's way of making CORS requests.
791
- xhr = new XDomainRequest ( ) ;
792
- xhr . open ( `GET` , url ) ;
793
-
794
- } else {
795
-
796
- // Otherwise, CORS is not supported by the browser.
797
- xhr = null ;
798
-
799
- }
800
- return xhr ;
801
- } ;
802
-
803
- const scriptElement = document . getElementById ( `iwsy-script` ) ;
804
- if ( scriptElement ) {
805
- const request = createCORSRequest ( `${ scriptElement . innerText } ?v=${ Math . floor ( Date . now ( ) ) } ` ) ;
806
- if ( ! request ) {
807
- throw Error ( `Unable to access the JSON script` ) ;
808
- }
809
-
810
- request . onload = ( ) => {
811
- if ( 200 <= request . status && request . status < 400 ) {
812
- const script = JSON . parse ( request . responseText ) ;
813
- IWSY ( document . getElementById ( `iwsy-container` ) , script ) ;
814
- } else {
815
- throw Error ( `Unable to access the JSON script` ) ;
752
+ else {
753
+ step . next = ( ) => {
754
+ console . log ( `Step ${ index + 1 } : Finished` ) ;
755
+ container . style . cursor = 'pointer' ;
816
756
}
817
757
} ;
818
-
819
- request . onerror = ( ) => {
820
- throw Error ( `Unable to access the JSON script` ) ;
821
- } ;
822
-
823
- request . send ( ) ;
824
758
}
759
+ IWSY . plugins = { } ;
760
+ initBlocks ( ) ;
761
+ preloadImages ( ) ;
762
+ doStep ( script . steps [ 0 ] ) ;
825
763
} ;
0 commit comments