2222</ script >
2323
2424< noscript >
25- < style > # maincontent { display : none !important ; }</ style >
25+ < style >
26+ .nhsuk-header { display : block !important ; }
27+ .with-script-maincontent { display : none !important ; }
28+ </ style >
2629</ noscript >
2730
2831< div id ="app-root " class ="appLayout ">
2932 < a class ="nhsuk-skip-link " href ="#maincontent " data-testid ="skip-link "> Skip to main content</ a >
3033
31- < header class ="nhsuk-header " role ="banner " data-module ="nhsuk-header ">
34+ < header class ="nhsuk-header " style =" display: none " role ="banner " data-module ="nhsuk-header ">
3235 < div class ="nhsuk-header__container nhsuk-width-container ">
3336 < div class ="nhsuk-header__service ">
3437 < a class ="nhsuk-header__service-logo " href ="/check-and-book-vaccinations " aria-label ="Check and book vaccinations homepage ">
4548 </ header >
4649
4750 < div class ="nhsuk-width-container ">
48- < a class ="nhsuk-back-link " href ="# "> Back</ a >
51+ < a class ="nhsuk-back-link " style =" display: none " href ="# "> Back</ a >
4952
5053 < noscript >
51- < main class ="nhsuk-main-wrapper nhsuk-main-wrapper--s " id ="maincontent-noscript ">
54+ < main class ="nhsuk-main-wrapper nhsuk-main-wrapper--s " id ="maincontent ">
5255 < div class ="nhsuk-grid-row ">
5356 < div class ="nhsuk-grid-column-full ">
5457 < h1 class ="nhsuk-heading-xl nhsuk-u-margin-bottom-5 "> Cannot show page</ h1 >
@@ -67,14 +70,12 @@ <h1 class="nhsuk-heading-xl nhsuk-u-margin-bottom-5">Cannot show page</h1>
6770 </ main >
6871 </ noscript >
6972
70- < main class ="nhsuk-main-wrapper nhsuk-main-wrapper--s " id ="maincontent ">
73+ < main class ="nhsuk-main-wrapper nhsuk-main-wrapper--s with-script-maincontent " id ="maincontent ">
7174 < div class ="nhsuk-grid-row ">
7275 < div class ="nhsuk-grid-column-full ">
7376 < h1 class ="nhsuk-heading-xl nhsuk-u-margin-bottom-5 "> There is a problem with the service</ h1 >
7477 < p > This may be a temporary problem.</ p >
75- < p >
76- Go back and try logging in again. If you cannot log in, try again later.
77- </ p >
78+ < p id ="guidance "> </ p >
7879 < p >
7980 For urgent medical advice, go to < a href ="https://111.nhs.uk/ " target ="_blank " rel ="noopener "> 111.nhs.uk</ a > or call 111.
8081 </ p >
@@ -111,32 +112,44 @@ <h2 class="nhsuk-u-visually-hidden">Support links</h2>
111112 </ div >
112113 </ footer >
113114 < script >
114- function showHeaderIfOutsideNHSApp ( ) {
115- if ( ! window . nhsapp ) {
116- setTimeout ( showHeaderIfOutsideNHSApp , 100 ) ;
117- return ;
118- }
115+ function showComponentsBasedOnDevice ( ) {
116+ window . onload = ( ) => {
117+ const handleClick = ( event ) => {
118+ event . preventDefault ( ) ;
119+ window . nhsapp . navigation . goToPage ( window . nhsapp . navigation . AppPage . SERVICES ) ;
120+ }
121+
122+ const handleSkipLink = ( event ) => {
123+ event . preventDefault ( ) ;
124+ const contentTitle = document . getElementsByTagName ( "h1" ) . item ( 0 ) ;
125+ contentTitle ?. setAttribute ( "tabindex" , "-1" ) ;
126+ contentTitle ?. focus ( ) ;
127+ }
128+
129+ const skipLink = document . querySelector ( '.nhsuk-skip-link' ) ;
130+ skipLink . addEventListener ( 'click' , handleSkipLink ) ;
131+
132+ const guidance = document . getElementById ( 'guidance' ) ;
133+ if ( window . nhsapp . tools . isOpenInNHSApp ( ) ) {
134+ // mobile
135+ const backLink = document . querySelector ( '.nhsuk-back-link' ) ;
136+ backLink . style . display = 'block' ;
137+
138+ window . nhsapp . navigation . setBackAction ( handleClick ) ;
139+ backLink . addEventListener ( 'click' , handleClick ) ;
140+
141+ guidance . innerHTML = 'Go back and try logging in again. If you cannot log in, try again later.' ;
142+ } else {
143+ // desktop
144+ const header = document . querySelector ( '.nhsuk-header' ) ;
145+ header . style . display = 'block' ;
119146
120- if ( ! window . nhsapp . tools . isOpenInNHSApp ( ) ) {
121- const waitForHeader = ( ) => {
122- const header = document . querySelector ( '#app-root .nhsuk-header' ) ;
123- if ( header ) {
124- setTimeout ( ( ) => {
125- header . style . display = 'block' ;
126- } , 50 ) ;
127- } else {
128- setTimeout ( waitForHeader , 50 ) ;
129- }
130- } ;
131-
132- waitForHeader ( ) ;
133- } else {
134- const header = document . querySelector ( '#app-root .nhsuk-header' ) ;
135- if ( header ) header . style . display = 'none' ;
147+ guidance . innerHTML = 'Close this tab and try logging in again. If you cannot log in, try again later.' ;
148+ }
136149 }
137150 }
138151
139- showHeaderIfOutsideNHSApp ( ) ;
152+ showComponentsBasedOnDevice ( ) ;
140153 </ script >
141154</ div >
142155</ body >
0 commit comments