File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -457,7 +457,17 @@ function scrollTop() {
457457 document . getElementById ( "right-side" ) . scrollIntoView ( { behavior : "smooth" , block : "start" , inline : "nearest" } )
458458}
459459
460- function navigateTo ( step ) {
460+ window . addEventListener ( "popstate" , ( event ) => {
461+ let step = ( event . state && event . state . step ) || 1
462+ navigateTo ( step , true )
463+ } ) ;
464+
465+
466+ function navigateTo ( step , nohistory ) {
467+ if ( ! nohistory ) {
468+ history . pushState ( { step : step } , "step " + step , "?step=" + step ) ;
469+ }
470+
461471 const tab = new bootstrap . Tab ( document . querySelector ( `#step-${ step } -tab` ) ) ;
462472 tab . show ( ) ;
463473 scrollTop ( ) ;
@@ -496,15 +506,23 @@ function navigateTo(step) {
496506 }
497507}
498508
499- function secondpage ( ) {
509+ function getPostcodeValues ( ) {
500510 const zipValue = elements . searchInput . value . split ( " " ) [ 0 ] . trim ( ) ;
501511 const cityValue = elements . searchInput . value . split ( " " ) [ 1 ]
502512 ? elements . searchInput . value . substr (
503513 elements . searchInput . value . indexOf ( " " ) + 1
504514 )
505515 : "" ;
516+ return {
517+ zip : zipValue ,
518+ city : cityValue
519+ }
520+ }
521+
522+ function secondpage ( ) {
523+ const data = getPostcodeValues ( )
506524
507- if ( zipValue . length >= 5 && is_valid_datalist_value ( zipValue , cityValue ) ) {
525+ if ( data . zip . length >= 5 && is_valid_datalist_value ( data . zip , data . city ) ) {
508526 navigateTo ( 2 ) ;
509527 }
510528}
You can’t perform that action at this time.
0 commit comments