@@ -487,7 +487,6 @@ const IWSY = (playerElement, scriptObject) => {
487
487
doTransitionStep ( block , target , ratio ) ;
488
488
} catch ( err ) {
489
489
clearInterval ( interval ) ;
490
- throw Error ( err ) ;
491
490
}
492
491
animStep ++ ;
493
492
} else {
@@ -828,75 +827,80 @@ const IWSY = (playerElement, scriptObject) => {
828
827
829
828
// Process a single step
830
829
const doStep = step => {
831
- if ( ! step ) {
832
- return ;
833
- }
834
- if ( step . title ) {
835
- console . log ( `Step ${ step . index } : ${ step . title } ` ) ;
836
- } else {
837
- console . log ( `Step ${ step . index } : ${ step . action } ` ) ;
838
- }
839
- if ( script . speed === `scan` && step . index === script . scanTarget ) {
840
- script . speed = `normal` ;
841
- for ( const block of script . blocks ) {
842
- if ( block . element ) {
843
- block . element . style . display = `block` ;
830
+ try {
831
+ if ( ! step ) {
832
+ return ;
833
+ }
834
+ if ( step . title ) {
835
+ console . log ( `Step ${ step . index } : ${ step . title } ` ) ;
836
+ } else {
837
+ console . log ( `Step ${ step . index } : ${ step . action } ` ) ;
838
+ }
839
+ if ( script . speed === `scan` && step . index === script . scanTarget ) {
840
+ script . speed = `normal` ;
841
+ for ( const block of script . blocks ) {
842
+ if ( block . element ) {
843
+ block . element . style . display = `block` ;
844
+ }
844
845
}
845
846
}
846
- }
847
847
848
- const onStepCB = script . onStepCB ;
849
- if ( step . action === `chain` ) {
850
- const runMode = script . runMode ;
851
- fetch ( `${ path } ${ step . script } ` )
852
- . then ( response => {
853
- if ( response . status >= 400 ) {
854
- throw Error ( `Unable to load ${ step . script } : ${ response . status } ` )
855
- }
856
- response . json ( ) . then ( data => {
857
- script = data ;
858
- if ( onStepCB ) {
859
- onStepCB ( - 1 ) ;
848
+ const onStepCB = script . onStepCB ;
849
+ if ( step . action === `chain` ) {
850
+ const runMode = script . runMode ;
851
+ fetch ( `${ path } ${ step . script } ?v=${ Date . now ( ) } ` )
852
+ . then ( response => {
853
+ if ( response . status >= 400 ) {
854
+ throw Error ( `Unable to load ${ step . script } : ${ response . status } ` )
860
855
}
861
- initScript ( ) ;
862
- script . runMode = runMode ;
863
- doStep ( script . steps [ 1 ] ) ;
856
+ response . json ( ) . then ( data => {
857
+ script = data ;
858
+ if ( onStepCB ) {
859
+ onStepCB ( - 1 ) ;
860
+ }
861
+ initScript ( ) ;
862
+ script . runMode = runMode ;
863
+ doStep ( script . steps [ 1 ] ) ;
864
+ } ) ;
865
+ } )
866
+ . catch ( err => {
867
+ throw Error ( `Fetch Error :${ err } ` ) ;
864
868
} ) ;
865
- } )
866
- . catch ( err => {
867
- throw Error ( `Fetch Error :${ err } ` ) ;
868
- } ) ;
869
- return ;
870
- }
871
-
872
- const actionName = step . action . split ( ` ` ) . join ( `` ) ;
873
- let handler = actions [ actionName ] ;
874
- if ( script . runMode === `auto` ) {
875
- if ( typeof handler === `undefined` ) {
876
- handler = IWSY . plugins [ actionName ] ;
869
+ return ;
870
+ }
871
+
872
+ const actionName = step . action . split ( ` ` ) . join ( `` ) ;
873
+ let handler = actions [ actionName ] ;
874
+ if ( script . runMode === `auto` ) {
877
875
if ( typeof handler === `undefined` ) {
878
- throw Error ( `Unknown action: '${ step . action } '` ) ;
876
+ handler = IWSY . plugins [ actionName ] ;
877
+ if ( typeof handler === `undefined` ) {
878
+ throw Error ( `Unknown action: '${ step . action } '` ) ;
879
+ }
880
+ }
881
+ if ( onStepCB ) {
882
+ onStepCB ( step . index ) ;
883
+ }
884
+ try {
885
+ handler ( step ) ;
886
+ } catch ( err ) {
887
+ console . log ( `Step ${ step . index } (${ step . action } ): ${ err } ` ) ;
888
+ alert ( `Step ${ step . index } (${ step . action } ): ${ err } ` ) ;
889
+ }
890
+ } else {
891
+ try {
892
+ handler ( step ) ;
893
+ } catch ( err ) {
894
+ console . log ( JSON . stringify ( step , 0 , 2 ) + `\n` + JSON . stringify ( handler , 0 , 2 ) ) ;
895
+ console . log ( `Step ${ step . index } (${ step . action } ): ${ err } ` ) ;
896
+ alert ( `Step ${ step . index } (${ step . action } ): ${ err } ` ) ;
879
897
}
880
- }
881
- if ( onStepCB ) {
882
- onStepCB ( step . index ) ;
883
- }
884
- try {
885
- handler ( step ) ;
886
- } catch ( err ) {
887
- console . log ( `Step ${ step . index } (${ step . action } ): ${ err } ` ) ;
888
- alert ( `Step ${ step . index } (${ step . action } ): ${ err } ` ) ;
889
- }
890
- } else {
891
- try {
892
- handler ( step ) ;
893
- } catch ( err ) {
894
- console . log ( JSON . stringify ( step , 0 , 2 ) + `\n` + JSON . stringify ( handler , 0 , 2 ) ) ;
895
- console . log ( `Step ${ step . index } (${ step . action } ): ${ err } ` ) ;
896
- alert ( `Step ${ step . index } (${ step . action } ): ${ err } ` ) ;
897
898
}
898
899
}
899
-
900
+ catch ( err ) {
901
+ console . log ( `Step error: ${ err } ` ) ;
902
+ throw Error ( err ) ;
903
+ }
900
904
} ;
901
905
902
906
///////////////////////////////////////////////////////////////////////////////
@@ -983,41 +987,46 @@ const IWSY = (playerElement, scriptObject) => {
983
987
984
988
// Run the presentation
985
989
const run = ( mode , startMode , then ) => {
986
- homeScript = JSON . parse ( JSON . stringify ( script ) ) ;
987
- afterRun = then ;
988
- initScript ( ) ;
989
- if ( mode === `fullscreen` ) {
990
- if ( document . fullscreenElement ) {
991
- document . exitFullscreen ( ) ;
992
- } else {
993
- player . requestFullscreen ( ) ;
994
- document . onfullscreenchange = ( ) => {
995
- if ( document . fullscreenElement ) {
996
- player = document . fullscreenElement ;
997
- script . nextStep = script . steps [ 0 ] ;
998
- switch ( startMode ) {
999
- case `auto` :
1000
- script . runMode = `auto` ;
1001
- release ( ) ;
1002
- break ;
1003
- case `manual` :
1004
- script . runMode = `manual` ;
1005
- release ( ) ;
1006
- break ;
1007
- case `wait` :
1008
- script . runMode = `manual` ;
1009
- enterManualMode ( null ) ;
1010
- break ;
990
+ try {
991
+ homeScript = JSON . parse ( JSON . stringify ( script ) ) ;
992
+ afterRun = then ;
993
+ initScript ( ) ;
994
+ if ( mode === `fullscreen` ) {
995
+ if ( document . fullscreenElement ) {
996
+ document . exitFullscreen ( ) ;
997
+ } else {
998
+ player . requestFullscreen ( ) ;
999
+ document . onfullscreenchange = ( ) => {
1000
+ if ( document . fullscreenElement ) {
1001
+ player = document . fullscreenElement ;
1002
+ script . nextStep = script . steps [ 0 ] ;
1003
+ switch ( startMode ) {
1004
+ case `auto` :
1005
+ script . runMode = `auto` ;
1006
+ release ( ) ;
1007
+ break ;
1008
+ case `manual` :
1009
+ script . runMode = `manual` ;
1010
+ release ( ) ;
1011
+ break ;
1012
+ case `wait` :
1013
+ script . runMode = `manual` ;
1014
+ enterManualMode ( null ) ;
1015
+ break ;
1016
+ }
1017
+ } else {
1018
+ player = playerElement ;
1019
+ script . stop = true ;
1011
1020
}
1012
- } else {
1013
- player = playerElement ;
1014
- script . stop = true ;
1015
- }
1016
- } ;
1021
+ } ;
1022
+ }
1023
+ } else {
1024
+ script . runMode = `auto` ;
1025
+ doStep ( script . steps [ 0 ] ) ;
1017
1026
}
1018
- } else {
1019
- script . runMode = `auto` ;
1020
- doStep ( script . steps [ 0 ] ) ;
1027
+ } catch ( err ) {
1028
+ console . log ( `Run error: ${ err } ` ) ;
1029
+ throw Error ( err ) ;
1021
1030
}
1022
1031
}
1023
1032
0 commit comments