-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
707 lines (643 loc) · 26.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="TalkingCharts.io - Accessible Data Visualizations">
<meta name="author" content="Eric Wamugu">
<title>TalkingCharts.io - Accessible Data Visualizations</title>
<link rel="apple-touch-icon" sizes="180x180" href="assets/images/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon/favicon-16x16.png">
<link rel="icon" type="image/png" href="assets/images/favicon/favicon.ico">
<link rel="manifest" href="assets/images/favicon/site.webmanifest">
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="vendor/fontawesome/css/fontawesome.css" rel="stylesheet">
<link href="vendor/fontawesome/css/solid.css" rel="stylesheet">
<style>
.center-content {
margin: 0 auto;
}
.card-body .progress {
display: none;
}
.box {
background-color: #dfebf9;
position: relative;
padding: 30px 20px;
}
.box .box__input{
text-align: center;
}
.box.has-advanced-upload {
outline: 2px dashed #92b0b3;
outline-offset: -10px;
-webkit-transition: outline-offset .15s ease-in-out, background-color .15s linear;
transition: outline-offset .15s ease-in-out, background-color .15s linear;
}
.box.is-dragover {
outline-offset: -20px;
outline-color: #c8dadf;
background-color: #fff;
}
.box__dragndrop,
.box__icon {
display: none;
}
.box.has-advanced-upload .box__dragndrop {
display: inline;
}
.box.is-uploading .box__input,
.box.is-success .box__input,
.box.is-error .box__input {
visibility: hidden;
}
.box__uploading,
.box__success,
.box__error {
display: none;
}
.box.is-uploading .box__uploading,
.box.is-success .box__success,
.box.is-error .box__error {
display: block;
position: absolute;
top: 50%;
right: 0;
left: 0;
text-align: center;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
.box__uploading {
font-style: italic;
}
.box__success {
-webkit-animation: appear-from-inside .25s ease-in-out;
animation: appear-from-inside .25s ease-in-out;
}
@-webkit-keyframes appear-from-inside {
from {
-webkit-transform: translateY(-50%) scale(0);
}
75% {
-webkit-transform: translateY(-50%) scale(1.1);
}
to {
-webkit-transform: translateY(-50%) scale(1);
}
}
@keyframes appear-from-inside {
from {
transform: translateY(-50%) scale(0);
}
75% {
transform: translateY(-50%) scale(1.1);
}
to {
transform: translateY(-50%) scale(1);
}
}
.box__restart {
font-weight: 700;
}
.box__restart:focus,
.box__restart:hover {
color: #39bfd3;
}
.js .box__file {
width: 0.1px;
height: 0.1px;
opacity: 0;
overflow: hidden;
position: absolute;
z-index: -1;
}
.js .box__file+label {
max-width: 95%;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
display: inline-block;
overflow: hidden;
}
.js .box__file+label:hover strong,
.box__file:focus+label strong,
.box__file.has-focus+label strong {
color: #39bfd3;
}
.js .box__file:focus+label,
.js .box__file.has-focus+label {
outline: 1px dotted #000;
outline: -webkit-focus-ring-color auto 5px;
}
.js .box__file+label * {
/* pointer-events: none; */
/* in case of FastClick lib use */
}
.no-js .box__file+label {
display: none;
}
.no-js .box__button {
display: block;
}
.box__button {
font-weight: 700;
color: #e5edf1;
background-color: #39bfd3;
display: none;
padding: 8px 16px;
margin: 40px auto 0;
}
.box__button:hover,
.box__button:focus {
background-color: #0f3c4b;
}
.gallery {
width: 100%;
float: left;
}
.gallery-image {
width: 45%;
float: left;
}
.gallery-image img {
width: 100%;
border: 1px solid #ddd;
border-radius: 4px;
padding: 5px;
}
.gallery-image img:hover {
box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
cursor: pointer;
/* width: 200%; */
}
.gallery-image img.selected {
box-shadow: 0 0 5px 5px rgba(0, 140, 186, 0.5);
/* width: 40%; */
}
.dataVizCaptions {
width: 100%;
float: left;
}
.audios audio {
display: none;
width: 100%;
}
.audios audio.active {
display: inline-block;
}
</style>
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">
<div class="container">
<a class="navbar-brand" href="#">TalkingCharts.io - Accessible Data Visualizations</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">
<i class="fas fa-home"> Home</i>
<!-- <span class="sr-only">Home</span> -->
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About</a>
</li>
<li class="nav-item">
<a class="nav-link" target="_blank" href="https://docs.google.com/forms/d/e/1FAIpQLSfPfhTYzHSRPZmMH6Qaj2i0HzgW5MqM9hcnm5I8REKKN4VYuw/viewform">Feedback</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-md-5 col-sm-4 center-content">
<div class="card">
<div class="card-header">
<i class="fas fa-chart-bar"></i>
<span><b>Step 1:</b> Upload a graph or chart for auto-captioning</span>
</div>
<div class="card-body js">
<form method="post" action="" enctype="multipart/form-data" novalidate class="box">
<div class="box__input">
<input type="file" name="files[]" id="file" class="box__file" data-multiple-caption="{count} files selected" multiple accept='image/*' />
<label for="file"><strong>Choose a file</strong><span class="box__dragndrop"> or drag it here (EXPERIMENTAL!)</span></label>
<button type="submit" class="box__button">Upload</button>
</div>
<div class="box__uploading">
<span>Processing</span>…
<i class="fas fa-spinner"></i>
</div>
<div class="box__success">
Done!
<a href="https://elric-wamugu.github.io/GC-Prototype/" class="box__restart" role="button">Upload more?</a>
</div>
<div class="box__error">
<span>Error!</span>
<a href="https://elric-wamugu.github.io/GC-Prototype/" class="box__restart" role="button">Try again!</a>
</div>
</form>
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
</div>
<p><span>OR, try out by selecting one of these examples below</span></p>
<div class="gallery ">
<div class="gallery-image">
<a href="#"><img class="" id="viz1" src="assets/images/Bar-Chart-Example.jpg" alt="image of a bar chart" /></a>
</div>
<div class="gallery-image">
<a href="#"><img class="" id="viz2" src="assets/images/Pie-Chart-Example.jpg" alt="image of a pie chart" /></a>
</div>
</div>
<div class="dataVizCaptions font-italic">
<div id="dataVizCaption1" class="dataVizCaption" style="display: none;">
<p class="text-justify">
Exam question. <br> The bar chart below shows the number of men and women studying engineering at Australian universities. Summarise the information in the chart by selecting and reporting the main features. Make comparisons where relevant.
</p>
<p>
The Y axis represents the number of students studying engineering, while the X axis representing the years by decade from 1992, 2002, to 2012.
</p>
<p>
In 1992, there were 14,000 men studying engineering at Australian universities compared to 2000 women. In 2002, the number of male students reduced by 2000 to 12,000 while female students had increased by 2,000 to 4,000 in total. A decade later in 2012, there was no change in the total number of men studying engineering with the figure remaining at 12,000 while there was an increase in the number of women by 2,000 to 6,000 women in total.
</p>
</div>
<div id="dataVizCaption2" class="dataVizCaption" style="display: none;">
<p class="text-justify">
The graph illustrates trends in music buying habits between 2011 and 2018. It presents three different methods: streaming, downloading and buying CDs.
Overall, both downloads and physical sales of music have steadily declined. The latter has slumped since 2011, while the downturn for the former began in 2014. However, there has been a sharp rise in people streaming music since 2013.
</p>
<p>
Downloads peaked in 2014 at about 43% of sales but fell to 30% by 2018. This was slightly higher than physical sales, which shrank to 25%. Streaming, on the other hand, overtook both of them and accounted for just over 40% of sales in 2018.
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-5 col-sm-4 center-content">
<div class="card">
<div class="card-header">
<i class="fas fa-info-circle"></i>
<span><b>Step 2:</b> Press play to listen to the content</span>
</div>
<div class="card-body">
<form class="needs-validation" novalidate>
<div class="input-group mb-4">
<div class="input-group-prepend" style="width: 100%;">
<button id="audio-play" aria-label="Play audio" class="btn btn-primary btn-lg col-md-8 col-sm-8" type="button">
<i class="fas fa-play"></i>
</button>
<button id="audio-stop" aria-label="Stop audio" class="btn btn-outline-secondary btn-lg col-md-4 col-sm-4" type="button">
<i class="fas fa-stop"></i>
</button>
</div>
</div>
<div class="input-group mb-4">
<div class="input-group-prepend" style="width: 100%;">
<button class="btn btn-outline-secondary btn-lg col-md-6 col-sm-6" type="button" aria-label="Previous visualization" disabled>
<i class="fas fa-step-backward"></i>
<span>Previous visualization</span>
</button>
<button class="btn btn-outline-secondary btn-lg col-md-6 col-sm-6" type="button" aria-label="Next visualization" disabled>
<i class="fas fa-step-forward"></i>
<span>Next visualization</span>
</button>
</div>
</div>
<div class="input-group mb-4">
<div class="input-group-prepend audios" style="width: 100%;">
<audio id="audio-en" class="audio-en audio" src="assets/audio/graph-text-en.mp3" controls>
Your browser does not support the <code>audio</code> element.
</audio>
<audio id="audio-es" class="audio-es audio" src="assets/audio/graph-text-es.mp3" controls>
Your browser does not support the <code>audio</code> element.
</audio>
<audio id="audio-fr" class="audio-fr audio" src="assets/audio/graph-text-fr.mp3" controls>
Your browser does not support the <code>audio</code> element.
</audio>
<audio id="audio-sw" class="audio-sw audio" src="assets/audio/graph-text-sw.mp3" controls>
Your browser does not support the <code>audio</code> element.
</audio>
<audio id="viz1-en" class="audio audio" src="assets/audio/viz1-en.mp3" controls>
Your browser does not support the <code>audio</code> element.
</audio>
<audio id="viz1-es" class="audio audio" src="assets/audio/viz1-es.mp3" controls>
Your browser does not support the <code>audio</code> element.
</audio>
<audio id="viz1-fr" class="audio audio" src="assets/audio/viz1-fr.mp3" controls>
Your browser does not support the <code>audio</code> element.
</audio>
<audio id="viz2-en" class="audio" src="assets/audio/viz2-en.mp3" controls>
Your browser does not support the <code>audio</code> element.
</audio>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-5 col-sm-4 center-content">
<div class="card">
<div class="card-header" id="headingOne">
<a href="#" class="navbar-brand" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<i class="fas fa-headphones"></i>
<span>Voice Settings</span>
</a>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<form class="needs-validation" novalidate>
<div class="mb-3">
<label for="country">Voice Accent & Language</label>
<select class="custom-select d-block w-100" id="country" required>
<option value="">Choose...</option>
<option value="en" selected="selected">English</option>
<option value="fr">Français</option>
<option value="es">Español</option>
<option value="sw">Kiswahili</option>
</select>
</div>
<!-- <div class="mb-3">
<label for="volume">Volume</label>
<div class="input-group">
<input id="volume" class="border-0" type="range" min="0" max="100" />
<span class="font-weight-bold text-primary ml-2 mt-1 volumeSpan"></span>
</div>
</div> -->
<div class="mb-3">
<label for="speed">Speed</label>
<div class="input-group">
<input id="speed" class="border-0" type="range" value="100" min="100" max="200" />
<span class="font-weight-bold text-primary ml-2 mt-1 speedSpan"></span>
</div>
</div>
<div class="mb-3">
<label for="pitch">Pitch</label>
<div class="input-group">
<input id="pitch" class="border-0" type="range" min="0" max="100" />
<span class="font-weight-bold text-primary ml-2 mt-1 pitchSpan"></span>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" crossorigin="anonymous"></script>
<script src="https://getbootstrap.com/docs/4.0/dist/js/bootstrap.min.js"></script>
<script>
'use strict';
;( function ( document, window, index )
{
// feature detection for drag&drop upload
var isAdvancedUpload = function()
{
var div = document.createElement( 'div' );
return ( ( 'draggable' in div ) || ( 'ondragstart' in div && 'ondrop' in div ) ) && 'FormData' in window && 'FileReader' in window;
}();
function showVizCaption(){
var showCaption = document.querySelector("#dataVizCaption2");
var selectedCountry = document.querySelector("#country").value;
var defaultAudio = document.querySelector(".audios .audio-" + selectedCountry);
showCaption.style.display = "block";
defaultAudio.classList.add( 'active' );
}
var viz1 = document.querySelector( '#viz1' );
var viz2 = document.querySelector( '#viz2' );
/* selectedViz.addEventListener( 'click', function( e )
{
showVizCaption();
console.log('called');
});
*/
var showProgressBar = function()
{
var progress = document.querySelector(".progress");
var progressBar = document.querySelector('.progress-bar');
progress.style.display = "flex";
for (let step = 0; step <= 100; step++) {
setTimeout(function(){
progressBar.setAttribute( 'aria-valuenow', step );
progressBar.style.width = step + "%";
progressBar.textContent = step + "%";
}, 500);
}
setTimeout(showVizCaption, 1500);
};
// applying the effect for every form
var forms = document.querySelectorAll( '.box' );
Array.prototype.forEach.call( forms, function( form )
{
var input = form.querySelector( 'input[type="file"]' ),
label = form.querySelector( 'label' ),
errorMsg = form.querySelector( '.box__error span' ),
restart = form.querySelectorAll( '.box__restart' ),
droppedFiles = false,
showFiles = function( files )
{
label.textContent = files.length > 1 ? ( input.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', files.length ) : files[ 0 ].name;
},
triggerFormSubmit = function()
{
var event = document.createEvent( 'HTMLEvents' );
event.initEvent( 'submit', true, false );
form.dispatchEvent( event );
};
// letting the server side to know we are going to make an Ajax request
var ajaxFlag = document.createElement( 'input' );
ajaxFlag.setAttribute( 'type', 'hidden' );
ajaxFlag.setAttribute( 'name', 'ajax' );
ajaxFlag.setAttribute( 'value', 1 );
form.appendChild( ajaxFlag );
// automatically submit the form on file select
input.addEventListener( 'change', function( e )
{
showFiles( e.target.files );
showProgressBar();
// console.log(e.target.files);
// triggerFormSubmit();
});
// drag&drop files if the feature is available
if( isAdvancedUpload )
{
form.classList.add( 'has-advanced-upload' ); // letting the CSS part to know drag&drop is supported by the browser
[ 'drag', 'dragstart', 'dragend', 'dragover', 'dragenter', 'dragleave', 'drop' ].forEach( function( event )
{
form.addEventListener( event, function( e )
{
// preventing the unwanted behaviours
e.preventDefault();
e.stopPropagation();
});
});
[ 'dragover', 'dragenter' ].forEach( function( event )
{
form.addEventListener( event, function()
{
form.classList.add( 'is-dragover' );
});
});
[ 'dragleave', 'dragend', 'drop' ].forEach( function( event )
{
form.addEventListener( event, function()
{
form.classList.remove( 'is-dragover' );
});
});
form.addEventListener( 'drop', function( e )
{
droppedFiles = e.dataTransfer.files; // the files that were dropped
showFiles( droppedFiles );
showProgressBar();
// console.log(droppedFiles);
// triggerFormSubmit();
});
}
// if the form was submitted
form.addEventListener( 'submit', function( e )
{
e.preventDefault();
// preventing the duplicate submissions if the current one is in progress
if( form.classList.contains( 'is-uploading' ) ) return false;
form.classList.add( 'is-uploading' );
form.classList.remove( 'is-error' );
if( isAdvancedUpload ) // ajax file upload for modern browsers
{
e.preventDefault();
}
else // fallback Ajax solution upload for older browsers
{
}
});
// Firefox focus bug fix for file input
input.addEventListener( 'focus', function(){ input.classList.add( 'has-focus' ); });
input.addEventListener( 'blur', function(){ input.classList.remove( 'has-focus' ); });
});
}( document, window, 0 ));
</script>
<script>
$(document).ready(function() {
$( ".gallery-image img" ).click(function() {
play_audio('stop');
$( ".gallery-image img" ).removeClass( "selected" );
$( ".audios audio" ).removeClass("active");
$( this ).toggleClass( "selected" );
showVizCaption($( this ).attr('id'));
});
function showVizCaption(selectedDataViz){
$(".dataVizCaption").hide();
var selectedDataVizId = selectedDataViz.replace("viz", "");
$('#dataVizCaption' + selectedDataVizId).show();
$( ".audios audio" ).each(function() {
$( this ).removeClass("active");
});
var country = $('#country').val();
if(selectedDataVizId == '2'){
var graphAudio = $('.audios .audio-' + country);
} else {
var graphAudio = $('.audios #viz' + selectedDataVizId + '-' + country);
}
graphAudio.addClass('active');
}
//language change
$('#country').on('change', () => {
var selectedDataVizId = $('.gallery-image img.selected').attr('id');
play_audio('stop');
showVizCaption(selectedDataVizId);
change_audio();
});
function check_upload(){
if($('.dataVizCaption ').is(':visible')){
return true;
}
$(".audios audio").removeClass("active");
$('#file').trigger('click');
}
function change_audio(){
$(".audios audio").removeClass("active");
var country = $('#country').val();
var graphAudio = $('.audios .audio-' + country);
graphAudio.addClass('active');
}
//playing and stoping current audio
function play_audio(task, playbackRate) {
if(task == 'play'){
const audio = document.querySelector("audio.active");
try {
audio.playbackRate = playbackRate;
} catch(error) {
console.log('> Error: ' + error.message);
}
$(".audios audio.active").trigger('play');
}
if(task == 'stop'){
$(".audios audio.active").trigger('pause');
$(".audios audio.active").prop("currentTime",0);
}
}
//change the speed of speech
function getPlaybackRate(speed) {
switch (true) {
case (speed >= 100 && speed <= 133):
return 1;
break;
case (speed >= 134 && speed <= 166):
return 1.5;
break;
case (speed >= 167 && speed <= 200):
return 2;
break;
default:
return 1;
}
}
$( "#audio-play" ).click(function() {
// change_audio();
var playbackRate = getPlaybackRate($('#speed').val());
play_audio('play', playbackRate);
});
$( "#audio-stop" ).click(function() {
play_audio('stop');
});
//volume
const $volumeSpan = $('.volumeSpan');
const $volumeValue = $('#volume');
$volumeSpan.html($volumeValue.val());
$volumeValue.on('input change', () => {
$volumeSpan.html($volumeValue.val());
});
//pitch
const $pitchSpan = $('.pitchSpan');
const $pitchValue = $('#pitch');
$pitchSpan.html($pitchValue.val());
$pitchValue.on('input change', () => {
$pitchSpan.html($pitchValue.val());
});
//speed
const $speedSpan = $('.speedSpan');
const $speedValue = $('#speed');
$speedSpan.html($speedValue.val() + '%');
$speedValue.on('input change', () => {
$speedSpan.html($speedValue.val() + '%');
var playbackRate = getPlaybackRate($speedValue.val());
play_audio('play', playbackRate);
});
});
</script>
</body>
</html>