91
91
dialog {
92
92
width : 57vw ;
93
93
height : 40vh ;
94
- margin : 20 vh auto;
94
+ margin : 26 vh auto;
95
95
text-align : center;
96
96
padding : 30px ;
97
97
border : none;
129
129
button : active {
130
130
transform : scale (0.99 );
131
131
}
132
- # main-heading { text-align : center; }
132
+ # main-heading {
133
+ text-align : center;
134
+ margin-bottom : 1px ;
135
+ font-size : 1.7em ;
136
+ }
133
137
.one-fourth-container { font-size : 2.5rem ; }
134
138
# question-count-container {
135
139
margin-left : -20px ;
177
181
background-color : # 888 ;
178
182
position : relative;
179
183
}
180
- .thumb ::before {
184
+ /* .thumb::before {
181
185
content: "🍕";
182
186
font-size: 58px;
183
187
margin-left: -27px;
184
188
margin-top: -22px;
185
189
position: absolute;
186
- }
190
+ }*/
187
191
div .focus .rail {
188
192
background-color : # CCC ;
189
193
}
194
+ # pizza-input {
195
+ background-image : url ("../img/Pizza-4.png" );
196
+ background-repeat : no-repeat;
197
+ background-size : contain;
198
+ width : 419px ;
199
+ height : 406px ;
200
+ margin-top : 35px ;
201
+ margin-left : auto;
202
+ margin-right : auto;
203
+ }
190
204
</ style >
191
205
< script src ="customslider.js "> </ script >
192
206
</ head >
193
207
< body >
194
208
< dialog id ="show-score-modal ">
195
209
< form method ="dialog ">
196
210
< div style ="width: 100% ">
197
- You got all six questions correct. Great work!
211
+ < span id =" dialog-content " > You got all six questions correct. Great work!</ span >
198
212
</ div >
199
213
< div style ="width: 100% ">
200
214
< button type ="submit " autofocus > Close</ button >
201
215
</ div >
202
216
</ form >
203
217
</ dialog >
204
- < h2 id ="main-heading "> Ms. Z's 2nd Grade Pop Quiz</ h2 >
218
+ < h1 id ="main-heading "> Pop Quiz</ h1 >
205
219
< div class ="question-box ">
206
220
< div class ="question-header ">
207
221
< div id ="question-count-container "> </ div >
@@ -218,15 +232,17 @@ <h2 id="main-heading">Ms. Z's 2nd Grade Pop Quiz</h2>
218
232
const pizzaSliderHtml = `
219
233
<div class="question">
220
234
${ pizzaHtml }
221
- Drag the pizza to select your answer !
235
+ Tap the pizza to add and remove slices !
222
236
</div>
223
237
224
- <div class="aria-widget-slider">
225
- <div class="value">0</div>
226
- <div class="rail">
227
- <div role="slider" class="thumb" aria-valuemin="0" aria-valuenow="0" aria-valuetext="0 slices" aria-valuemax="8"></div>
228
- </div>
229
- </div>
238
+ <div id="pizza-input" role="slider" tabindex="0" aria-valuemin="0" aria-valuenow="4" aria-valuetext="4 slices" aria-valuemax="8"></div>
239
+
240
+ <!-- <div class="aria-widget-slider"> -->
241
+ <!-- <div class="value">0</div> -->
242
+ <!-- <div class="rail"> -->
243
+ <!-- <div role="slider" class="thumb" aria-valuemin="0" aria-valuenow="0" aria-valuetext="0 slices" aria-valuemax="8"></div> -->
244
+ <!-- </div> -->
245
+ <!-- </div> -->
230
246
`
231
247
const pizzaRadioHtml = `
232
248
<div class="question">
@@ -293,11 +309,11 @@ <h2 id="main-heading">Ms. Z's 2nd Grade Pop Quiz</h2>
293
309
document . getElementById ( "next-question-button" ) . addEventListener ( 'click' , ( e ) => { switchCurrentScreen ( ) } ) ;
294
310
document . getElementById ( "question-footer" ) . style . justifyContent = "center"
295
311
}
296
- function setupFinalQuestionContent ( ariaLabel ) {
297
- if ( ariaLabel )
298
- document . getElementById ( "show-score-modal" ) . ariaLabel = ariaLabel
312
+ function setupFinalQuestionContent ( labelledById ) {
313
+ if ( labelledById )
314
+ document . getElementById ( "show-score-modal" ) . setAttribute ( "aria-labelledby" , labelledById )
299
315
else
300
- document . getElementById ( "show-score-modal" ) . removeAttribute ( "aria-label " )
316
+ document . getElementById ( "show-score-modal" ) . removeAttribute ( "aria-labelledby " )
301
317
302
318
document . getElementById ( "question-count-container" ) . innerHTML = "6 of 6"
303
319
document . getElementById ( "emoji-container" ) . innerHTML = "🇪🇸"
@@ -308,18 +324,28 @@ <h2 id="main-heading">Ms. Z's 2nd Grade Pop Quiz</h2>
308
324
document . getElementById ( "read-question-button" ) . addEventListener ( 'click' , ( e ) => {
309
325
var ssml = `
310
326
<speak>
311
- How do you say ${ wrapWithSSML ( "the water" , "en-US" ) } in Spanish?
327
+ How do you say ${ wrapWithSSML ( "the water" , "en-US" , false ) } in Spanish?
312
328
${ wrapWithSSML ( "El agua" , "es-ES" ) }
329
+ ${ wrapWithSSML ( "El agua" , "es-MX" ) }
313
330
${ wrapWithSSML ( "La abuela" , "es-ES" ) }
331
+ ${ wrapWithSSML ( "La abuela" , "es-MX" ) }
314
332
${ wrapWithSSML ( "La abeja" , "es-ES" ) }
333
+ ${ wrapWithSSML ( "La abeja" , "es-MX" ) }
315
334
${ wrapWithSSML ( "El árbol" , "es-ES" ) }
335
+ ${ wrapWithSSML ( "El árbol" , "es-MX" ) }
316
336
</speak>
317
337
` ;
318
-
319
338
var utterance = new SpeechSynthesisUtterance ( ssml ) ;
320
339
window . speechSynthesis . speak ( utterance ) ;
321
340
} ) ;
322
341
}
342
+ var currentSliceCount = 4 ;
343
+ function updatePizzaControl ( ) {
344
+ const pizzaInput = document . getElementById ( "pizza-input" ) ;
345
+ pizzaInput . style . backgroundImage = `url(../img/Pizza-${ currentSliceCount } .png)` ;
346
+ pizzaInput . ariaValueNow = `${ currentSliceCount } ` ;
347
+ pizzaInput . ariaValueText = `${ currentSliceCount } ${ currentSliceCount === 1 ? "slice" : "slices" } ` ;
348
+ }
323
349
function switchTo ( screen ) {
324
350
currentScreen = screen
325
351
switch ( currentScreen ) {
@@ -337,30 +363,47 @@ <h2 id="main-heading">Ms. Z's 2nd Grade Pop Quiz</h2>
337
363
s . initSlider ( ) ;
338
364
}
339
365
} ) ;
366
+
367
+ document . getElementById ( "pizza-input" ) . addEventListener ( "click" , ( event ) => {
368
+ console . log (
369
+ "clientX: " + event . clientX +
370
+ " - clientY: " + event . clientY ) ;
371
+ } ) ;
372
+ document . getElementById ( "pizza-input" ) . addEventListener ( "keydown" , ( event ) => {
373
+ console . log ( `Keydown: ${ event . key } , ${ event . code } ` ) ;
374
+ if ( event . key === "ArrowLeft" )
375
+ currentSliceCount = Math . max ( currentSliceCount - 1 , 1 ) ;
376
+ else if ( event . key === "ArrowRight" )
377
+ currentSliceCount = Math . min ( currentSliceCount + 1 , 6 ) ;
378
+ else
379
+ return ;
380
+
381
+ updatePizzaControl ( ) ;
382
+ } ) ;
340
383
break ;
341
384
case Screen . Translation :
342
385
setupFinalQuestionContent ( )
343
386
break ;
344
387
case Screen . TranslationWithAriaLabel :
345
- setupFinalQuestionContent ( "You got all six questions correct. Great work! " )
388
+ setupFinalQuestionContent ( "dialog-content " )
346
389
break ;
347
390
}
348
391
}
349
392
350
- function wrapWithSSML ( phrase , lang ) {
393
+ function wrapWithSSML ( phrase , lang , insertBreak = true ) {
351
394
const ssml = `
352
- <break time="1s"/>
353
- <prosody rate="slow ">
395
+ ${ insertBreak ? " <break time='80ms'/>" : "" }
396
+ <prosody rate="80% ">
354
397
<lang xml:lang="${ lang } ">
355
398
${ phrase }
356
399
</lang>
357
400
</prosody>
358
- <break time="1s"/>
359
401
`
360
402
console . log ( ssml )
361
403
return ssml
362
404
}
363
405
function switchCurrentScreen ( ) {
406
+ console . log ( window . speechSynthesis . getVoices ( ) . map ( ( v ) => v . lang ) ) ;
364
407
switch ( currentScreen ) {
365
408
case Screen . PizzaRadio :
366
409
switchTo ( Screen . PizzaSlider )
0 commit comments