211
211
< span id ="dialog-content "> You got all six questions correct. Great work!</ span >
212
212
</ div >
213
213
< 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 >
215
216
</ div >
216
217
</ form >
217
218
</ dialog >
@@ -225,6 +226,37 @@ <h1 id="main-heading">Pop Quiz</h1>
225
226
< div id ="question-footer "> </ div >
226
227
</ div >
227
228
< 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
+ } ) ;
228
260
const nextQuestionHtml = `
229
261
<button id="next-question-button">Next question <span aria-hidden="true">➡️ </span></button>
230
262
`
0 commit comments