211211 < span id ="dialog-content "> You got all six questions correct. Great work!</ span >
212212 </ div >
213213 < div style ="width: 100% ">
214- < button type ="submit " autofocus > Close</ button >
214+ <!-- <button id="modal-close-button" autofocus tabindex="0">Close</button> -->
215+ < button id ="modal-close-button " type ="submit " autofocus > Close</ button >
215216 </ div >
216217 </ form >
217218 </ dialog >
@@ -225,6 +226,37 @@ <h1 id="main-heading">Pop Quiz</h1>
225226 < div id ="question-footer "> </ div >
226227 </ div >
227228 < script >
229+ function setVoiceOverFocus ( element ) {
230+ var focusInterval = 1 ; // ms, time between function calls
231+ var focusTotalRepetitions = 100 ; // number of repetitions
232+
233+ element . setAttribute ( 'tabindex' , '0' ) ;
234+ element . blur ( ) ;
235+
236+ var focusRepetitions = 0 ;
237+ var interval = window . setInterval ( function ( ) {
238+ element . focus ( ) ;
239+ focusRepetitions ++ ;
240+ if ( focusRepetitions >= focusTotalRepetitions ) {
241+ window . clearInterval ( interval ) ;
242+ }
243+ } , focusInterval ) ;
244+ }
245+
246+ document . getElementById ( "modal-close-button" ) . addEventListener ( "click" , ( ) => {
247+ document . getElementById ( "show-score-modal" ) . close ( ) ;
248+ // setVoiceOverFocus(document.getElementById("show-score-button"))
249+ // let iterations = 0;
250+ // const showScoreButton = document.getElementById("show-score-button");
251+ // console.log(showScoreButton);
252+ // while (true) {
253+ // console.log(document.activeElement)
254+ // showScoreButton.focus();
255+ // if (iterations >= 500)
256+ // break;
257+ // iterations += 1;
258+ // }
259+ } ) ;
228260 const nextQuestionHtml = `
229261 <button id="next-question-button">Next question <span aria-hidden="true">➡️ </span></button>
230262 `
@@ -325,13 +357,9 @@ <h1 id="main-heading">Pop Quiz</h1>
325357 var ssml = `
326358 <speak>
327359 How do you say ${ wrapWithSSML ( "the water" , "en-US" , false ) } in Spanish?
328- ${ wrapWithSSML ( "El agua" , "es-ES" ) }
329360 ${ wrapWithSSML ( "El agua" , "es-MX" ) }
330- ${ wrapWithSSML ( "La abuela" , "es-ES" ) }
331361 ${ wrapWithSSML ( "La abuela" , "es-MX" ) }
332- ${ wrapWithSSML ( "La abeja" , "es-ES" ) }
333362 ${ wrapWithSSML ( "La abeja" , "es-MX" ) }
334- ${ wrapWithSSML ( "El árbol" , "es-ES" ) }
335363 ${ wrapWithSSML ( "El árbol" , "es-MX" ) }
336364 </speak>
337365 ` ;
0 commit comments