-
Notifications
You must be signed in to change notification settings - Fork 662
/
validator-htmltable.html
1489 lines (1282 loc) · 57.7 KB
/
validator-htmltable.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
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!--[if IE 7]><html lang="en" class="no-js ie7"><![endif]-->
<!--[if IE 8]><html lang="en" class="no-js ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<!-- Web Experience Toolkit (WET) / Boîte à outils de l'expérience Web (BOEW)
wet-boew.github.com/wet-boew/License-eng.txt / wet-boew.github.com/wet-boew/Licence-fra.txt -->
<title>HTML Table Validator - Table Usability - Web Experience Toolkit (WET)</title>
<link rel="shortcut icon" href="../../dist/theme-gcwu-fegc/images/favicon.ico" />
<meta name="description" content="English description/Description en anglais" />
<meta name="dcterms.creator" content="English name of the content author/Nom en anglais de l'auteur du contenu" />
<meta name="dcterms.title" content="English title/Titre en anglais" />
<meta name="dcterms.issued" title="W3CDTF" content="Date published (YYYY-MM-DD)/Date de publication (AAAA-MM-JJ)" />
<meta name="dcterms.modified" title="W3CDTF" content="Date modified (YYYY-MM-DD)/Date de modification (AAAA-MM-JJ)" />
<meta name="dcterms.subject" title="scheme" content="English subject terms/Termes de sujet en anglais" />
<meta name="dcterms.language" title="ISO639-2" content="eng" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="../../dist/js/jquery.min.js"></script>
<!--[if lte IE 8]>
<script src="../../dist/js/polyfills/html5shiv-min.js"></script>
<link rel="stylesheet" href="../../dist/grids/css/util-ie-min.css" />
<link rel="stylesheet" href="../../dist/js/css/pe-ap-ie-min.css" />
<link rel="stylesheet" href="../../dist/theme-gcwu-fegc/css/theme-ie-min.css" />
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="../../dist/grids/css/util-min.css" />
<link rel="stylesheet" href="../../dist/js/css/pe-ap-min.css" />
<link rel="stylesheet" href="../../dist/theme-gcwu-fegc/css/theme-min.css" />
<!--<![endif]-->
<noscript><link rel="stylesheet" href="../../dist/theme-gcwu-fegc/css/theme-ns-min.css" /></noscript>
<!-- CustomScriptsCSSStart -->
<script>
//<![CDATA[
(function ($) {
$(document).ready(function() {
$('#resultTableIdHeaders').empty();
$('#resultTableIdHeaders').append('<pre>Nothing to being displayed</pre>');
$('form').submit(function() {
$('#inputHTMLtable').focus();
return false;
});
var _pe = window.pe || {
fn : {}
},
nbErrorFound = 0,
ErrorMessage = {
"%tblparser1": "Only table can be parsed with this parser",
"%tblparser2": "The table was already parsed.",
"%tblparser3": 'The first colgroup must be spanned to represent the header column group',
"%tblparser3Tech": 6,
"%tblparser4": ' You have an invalid cell inside a row description',
"%tblparser4Tech": 4,
"%tblparser5": 'You need at least one data colgroup, review your table structure',
"%tblparser5Tech": 8,
"%tblparser6": "The Lowest column group level have been found, You may have an error in you column structure",
"%tblparser6Tech": 9,
"%tblparser7": "The initial colgroup should group all the header, there are no place for any data cell",
"%tblparser7Tech": 4,
"%tblparser9": "Error in you header row group, there are cell that are crossing more than one colgroup",
"%tblparser9Tech": 4,
"%tblparser10": "The header group cell used to represent the data at level must encapsulate his group",
"%tblparser10Tech": 7,
"%tblparser12": "Last summary row group already found",
"%tblparser12Tech": 3,
"%tblparser13": "Error, Row group not calculated",
"%tblparser14": 'You can not have a summary at level under 0, add a group header or merge a tbody togheter',
"%tblparser14Tech": 3,
"%tblparser15": 'tr element need to only have th or td element as his child',
"%tblparser16": 'The row do not have a good width',
"%tblparser16Tech": 12,
"%tblparser17": 'The layout cell is not empty',
"%tblparser17Tech": 11,
"%tblparser18": 'Row group header not well structured.',
"%tblparser18Tech": 7,
"%tblparser21": 'Move the row used as the column cell heading in the thead row group',
"%tblparser21Tech": 7,
"%tblparser23": 'Avoid the use of have paralel row headers, it\'s recommended do a cell merge to fix it',
"%tblparser23Tech": 3,
"%tblparser24": 'For a data row, the heading hiearchy need to be the Generic to the specific',
"%tblparser24Tech": 3,
"%tblparser25": 'You have a problematic key cell',
"%tblparser25Tech": 0,
"%tblparser26": 'You can not define any row before the thead group',
"%tblparser26Tech": 12,
"%tblparser27": 'thead element need to only have tr element as his child',
"%tblparser27Tech": 12,
"%tblparser29": 'You cannot span cell in 2 different rowgroup',
"%tblparser29Tech": 12,
"%tblparser30": 'Use the appropriate table markup',
"%tblparser30Tech": 12,
"%tblparser31": 'Internal Error, Number of virtual column must be set [function processColgroup()]',
"%tblparser32": 'Check your row cell headers structure',
"%tblparser32Tech": 3,
"%tblparser34": 'Mark properly your data row group.',
"%tblparser34Tech": 1,
"%tblparser35": 'Column, col element, are not correctly defined',
"%tblparser35Tech": 12},
techniqueURL = [
"keycell-techniques.html", // 1
"rowgrouping-techniques.html", // 2
"summariesrowgroup-techniques.html", // 3
"headerrowgroupstructure-techniques.html", // 4
"rowheader-description-techniques.html", // 5
"rowgroupheader-description-techniques.html", // 6
"colgroupheader-techniques.html", // 7
"headercolgroupstructure-techniques.html", // 8
"datacolgroup-techniques.html", // 9
"colgroupsummary-techniques.html", // 10
"colheader-description-techniques.html", // 11
"layoutcell-techniques.html", // 12
"http://www.w3.org/TR/html5/spec.html"], // 13
techniqueName = [
"Defining a Key Cell", // 1
"Defining a Data Row Group in a Data Table", // 2
"Summaries a Data Row Group in a Data Table", // 3
"Structuring the Header Row in a Data Table", // 4
"Describing a Row Header Cell in a Data Table", // 5
"Describing a Row Group Header Cell in a Data Table", // 6
"Defining Column Group Header in a Data Table", // 7
"Structuring the Header Column Cell in a Data Table", // 8
"Defining a Data Column Group in a Data Table", // 9
"Summaries a Data Column Group in a Data Table", // 10
"Describing a Column Header Cell in a Data Table", // 11
"Defining a Layout Cell in a Data Table", // 12
"HTML5 Specification"], // 13;
tableOpenTag = '<table>',
tableOpenTagNoEncode = '<table>',
tableOpenTagZebra = '<table class="wet-boew-zebra">';
tableOpenTagZebraNoEncode = '<table class="wet-boew-zebra">',
errorHandlerAttached = false,
fnParserLoaded = function () {
_pe.fn.parsertable.onParserError = function(numerr, obj){
var msgListItem = '<li><span class="wb-invisible">' + numerr + '</span> ',
err;
// Retreive the Error message
if (ErrorMessage['%tblparser' + numerr]) {
err = ErrorMessage['%tblparser' + numerr];
// Check if a technique exist related to the error
if (ErrorMessage['%tblparser' + numerr + 'Tech'] !== undefined) {
var techNum = ErrorMessage['%tblparser' + numerr + 'Tech'];
err = '<a href="' + techniqueURL[techNum] + '" title="' + techniqueName[techNum] + '">' + err + '</a>';
}
} else {
err = 'Error found, but not documented. Error Number:' + numerr;
}
if(numerr === 23 || numerr === 18) {
msgListItem += 'Warning: ';
} else {
msgListItem += 'Error: ';
nbErrorFound += 1;
}
$('#errorList').append($(msgListItem + err + '</li>'));
if (obj) {
$(obj).css('background-color', 'red');
}
};
errorHandlerAttached = true;
},
displayTableResult = function (){
// Missing colgroup and col if any
var tblelement = $('#directOutput table:eq(0)');
// Show the result
$('#resultTableIdHeaders').show();
$('#resultTableIdHeaders').empty();
$('#resultTableIdHeaders').html('<pre class="prettyprint"><code>' + ('<table>' + $(tblelement).html() + '</table>').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"') + '</code></pre>');
prettyPrint();
if($('#addzebra').is(':checked')){
_pe.fn.zebra._exec(tblelement);
}
},
optimizeAccessibilitySet = function (){
//var noErrorList = '<li>No Error Found</li>',
var noErrorList = '<li>Table passed, see the resulting source code bellow</li>',
ErrorParsedByForce = '<li>Forced the HTML results, It\'s recommended to fix the errors.</li>',
genericMessage = '<li>Use the above text field to analyse your HTML Complex Table Source Code</li>',
emptyTable = '<li>Empty Table</li>',
qualifiedSimple = '<li>You have a <strong>Simple Table</strong></li>',
qualifiedSimpleGrouping = '<li>You have a <strong>Simple Grouping Table</strong> (Acessibility set with scope attribute)</li>',
qualifiedComplex = '<li>You have a <strong>Complex Table</strong> (Acessibility set with id/headers attribute)</li>',
bypassOnError = false,
ScopeColgroupEligible = true;
nbErrorFound = 0;
if (!errorHandlerAttached){
fnParserLoaded();
}
_pe.fn.parsertable.parse($('#directOutput table:eq(0)'));
if ($('#byPassOnErrorStop').is(':checked')) {
bypassOnError = true;
}
if (nbErrorFound === 0 || bypassOnError) {
var tblparser = $('#directOutput table:eq(0)').data().tblparser;
if (!tblparser.row) {
alert('Your table must have at least one row');
$('#directOutput').empty();
$('#errorList').empty();
$('#errorList').append($(emptyTable));
return;
}
$('#errorList').empty();
if(nbErrorFound === 0){
$('#errorList').append($(noErrorList));
} else {
$('#errorList').append($(ErrorParsedByForce));
}
// Clean the markup if requested
if (!$('#chkCleanMarkup').is(':checked')) {
$('#directOutput table:eq(0) [headers]').each(function () {
$(this).removeAttr('headers');
});
$('#directOutput table:eq(0) [aria-describedby]').each(function () {
$(this).removeAttr('aria-describedby');
});
$('#directOutput table:eq(0) [id]').each(function () {
$(this).removeAttr('id');
});
$('#directOutput table:eq(0) [scope]').each(function () {
$(this).removeAttr('scope');
});
$('#directOutput table:eq(0) [class]').each(function () {
$(this).removeAttr('class');
});
}
// Auto-Detect the best way to make the table accessible WCAG 2.0
// Si le tableau a 2 row pour les colones
// * Toute les cells des 2 ligne doit avoir une hauteur de 1, (Sans tenir compte du column header group)
// * Toute les cell de la 1er ligne doit avoir une largeur egale ou plus grande que 2.
//
// * Les cells de la première ligne doit exatement correspondre au colgroup definie
// *
if (tblparser.theadRowStack.length !== 2) {
ScopeColgroupEligible = false;
} else {
i = 0;
if (tblparser.colgroup[0] && tblparser.colgroup[0].type === 1 && tblparser.theadRowStack[0].cell[0].type === 6) {
i = tblparser.colgroup[0].end;
} else if (tblparser.colgroup[0].type === 2) {
i = 0;
} else {
// This is a complex table.
ScopeColgroupEligible = false;
}
// Test the first row
if (ScopeColgroupEligible) {
for (i; i < tblparser.theadRowStack[0].cell.length; i += 1) {
if (tblparser.theadRowStack[0].cell[i].colgroup.start === tblparser.theadRowStack[0].cell[i].colgroup.end ||
tblparser.theadRowStack[0].cell[i].colgroup.start !== tblparser.theadRowStack[0].cell[i].colpos ||
tblparser.theadRowStack[0].cell[i].colgroup.end !==
(tblparser.theadRowStack[0].cell[i].colpos + tblparser.theadRowStack[0].cell[i].width - 1) ||
tblparser.theadRowStack[0].cell[i].colgroup.type !== 2) {
// This cell DO NOT fit in the colgroup patern
ScopeColgroupEligible = false;
break;
}
}
}
// Test the second row
/*if (ScopeColgroupEligible) {
if (tblparser.colgroup[0].type === 1) {
i = tblparser.colgroup[0].end - 1;
} else {
i = 0;
}
for (i; i < tblparser.theadRowStack[1].cell.length; i += 1) {
}
}*/
}
// Is Simple Table ?
if ((tblparser.theadRowStack.length <= 1 || ScopeColgroupEligible) && // One Row for column headers
!tblparser.desccell && // No Description Cell
!tblparser.keycell // && // No Key Cell
/*((tblparser.colgroup.length === 2 && tblparser.colgroup[0].type === 1 && tblparser.colgroup[0].col.length === 1) || // an header column group build with one column followed by a data column group
tblparser.colgroup.length === 1)*/){ // One data colum group
// Without grouping
if (tblparser.theadRowStack.length <= 1 && (tblparser.lstrowgroup.length === 1 || (tblparser.lstrowgroup[0].type === 2 && tblparser.lstrowgroup[1].type === 3 && tblparser.lstrowgroup[1].level === 0))) { // Only one row group or one data group with a summary group at level 0 (tfoot)
// This table is qualified to be an simple table
$('#errorList').append($(qualifiedSimple));
displayTableResult();
return;
}
var qualifySimpleGrouping = true;
// Simple Row grouping (Need to be at only at level 0, 1 or 2 and no summary)
for (i = 0; i < tblparser.lstrowgroup.length; i += 1) {
if (!((tblparser.lstrowgroup[i].type === 2 && tblparser.lstrowgroup[i].level <= 2) || (tblparser.lstrowgroup[i].type === 3 && tblparser.lstrowgroup[i].level === 0))) {
// Sorry, but this table are not qualify for simple row grouping
qualifySimpleGrouping = false;
break;
}
}
if (qualifySimpleGrouping) {
// Do the simple row grouping
$('#errorList').append($(qualifiedSimpleGrouping));
for (i = 0; i < tblparser.lstrowgroup.length; i += 1) {
if (tblparser.lstrowgroup[i].headerlevel && tblparser.lstrowgroup[i].headerlevel[0]) {
$(tblparser.lstrowgroup[i].headerlevel[0].elem).attr('scope', 'rowgroup');
}
for (j = 0; j < tblparser.lstrowgroup[i].row.length; j += 1) {
if (tblparser.lstrowgroup[i].row[j].cell[0].type === 1) {
$(tblparser.lstrowgroup[i].row[j].cell[0].elem).attr('scope', 'row');
}
}
}
if (tblparser.theadRowStack.length === 2) {
if (tblparser.colgroup[0].type === 1) {
i = tblparser.colgroup[0].end;
} else {
i = 0;
}
for (i; i < tblparser.theadRowStack[0].cell.length; i += 1) {
if (i === 0 || (tblparser.theadRowStack[0].cell[i - 1].uid !== tblparser.theadRowStack[0].cell[i].uid)){
$(tblparser.theadRowStack[0].cell[i].elem).attr('scope', 'colgroup');
}
}
}
if (tblparser.theadRowStack.length === 1 || tblparser.theadRowStack.length === 2) {
for (i = 0; i < tblparser.theadRowStack[(tblparser.theadRowStack.length === 1 ? 0 : 1)].cell.length; i += 1) {
if (tblparser.theadRowStack[(tblparser.theadRowStack.length === 1 ? 0 : 1)].cell[i].type === 1){
$(tblparser.theadRowStack[(tblparser.theadRowStack.length === 1 ? 0 : 1)].cell[i].elem).attr('scope', 'col');
}
}
}
displayTableResult();
return;
}
}
// All Others Cases
$('#errorList').append($(qualifiedComplex));
generateIdHeaders();
}
},
generateIdHeaders = function(){
//var noErrorList = '<li>No Error Found</li>',
var noErrorList = '<li>Table passed, see the resulting source code bellow</li>',
ErrorParsedByForce = '<li>Forced the HTML results, It\'s recommended to fix the errors.</li>',
genericMessage = '<li>Use the above text field to analyse your HTML Complex Table Source Code</li>',
emptyTable = '<li>Empty Table</li>',
bypassOnError = false;
/*
nbErrorFound = 0;
if (!errorHandlerAttached){
fnParserLoaded();
}
_pe.fn.parsertable.parse($('#directOutput table:eq(0)'));
if ($('#byPassOnErrorStop').is(':checked')) {
bypassOnError = true;
}
*/
// if(nbErrorFound === 0 || bypassOnError){
// Add id, headers attribute to each cell
var tblparser = $('#directOutput table:eq(0)').data().tblparser,
tblelement = $('#directOutput table:eq(0)'),
i,
j,
currRow,
currCell,
idPrefix = $('#idprefix').val() || 'usabletblparsed',
resetIds = false;
/*
// Remove any headers and aria-describedby attribute
$('#directOutput table:eq(0) [headers]').each(function () {
$(this).removeAttr('headers');
});
$('#directOutput table:eq(0) [aria-describedby]').each(function () {
$(this).removeAttr('aria-describedby');
});
if ($('#idreset:checked').length > 0) {
$('#directOutput table:eq(0) [id]').each(function () {
$(this).removeAttr('id');
});
}
if($('#removeScope:checked').length > 0) {
$('#directOutput table:eq(0) [scope]').each(function () {
$(this).removeAttr('scope');
});
}
*/
// Set ID and Header for the table head
for (i = 0; i < tblparser.theadRowStack.length; i += 1) {
currRow = tblparser.theadRowStack[i];
for (j = 0; j < currRow.cell.length; j += 1) {
currCell = currRow.cell[j];
if ((currCell.type === 1 || currCell.type === 7) && (
!(j > 0 && currCell.uid === currRow.cell[j - 1].uid) &&
!(i > 0 && currCell.uid === tblparser.theadRowStack[i - 1].cell[j].uid)
) ) {
// If there no id, add an uid
var currCellId = $(currCell.elem).attr('id');
if (currCellId === undefined || currCellId === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId = idPrefix + currCell.uid; // Generate a new ID
$(currCell.elem).attr('id', currCellId);
}
// Set the header of the current cell if required
if (i > 0) {
var headersCurrCell = $(tblparser.theadRowStack[i - 1].cell[j].elem).attr('id');
if ($(tblparser.theadRowStack[i-1].cell[j].elem).attr('headers') !== undefined) {
headersCurrCell = $(tblparser.theadRowStack[i - 1].cell[j].elem).attr('headers') + ' ' + headersCurrCell;
}
$(currCell.elem).attr('headers', headersCurrCell);
if ($(currCell.elem).attr('headers') === undefined || $(currCell.elem).attr('headers') === '') {
$(currCell.elem).removeAttr('headers');
}
}
// Set the header on his descriptive cell is any (May be better aria-describedby
if (currCell.descCell) {
$(currCell.descCell.elem).attr('headers', currCellId);
if ($(currCell.descCell.elem).attr('headers') === undefined || $(currCell.descCell.elem).attr('headers') === '') {
$(currCell.descCell.elem).removeAttr('headers');
}
var currCellDescId = $(currCell.descCell.elem).attr('id');
if (currCellDescId === undefined || currCellDescId === '' || resetIds) {
// currCellDescId = idPrefix + new Date().getTime() + currCell.descCell.uid; // Generate a new ID
$(currCell.descCell.elem).attr('id', currCellDescId);
}
$(currCell.elem).attr('aria-describedby', currCellDescId);
}
}
}
}
// Set Id/headers for header cell and data cell in the table.
for (i = 0; i < tblparser.row.length; i += 1) {
currRow = tblparser.row[i];
var rowheadersgroup = "",
rowheaders = "",
currrowheader = "";
ongoingRowHeader = "";
// Get or Generate a unique ID for each header in this row
if (currRow.headerset && !currRow.idsheaderset) {
for (j = 0; j < currRow.headerset.length; j += 1) {
var currCellId = $(currRow.headerset[j].elem).attr('id');
if (currCellId === undefined || currCellId === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId = idPrefix + currRow.headerset[j].uid; // Generate a new ID
$(currRow.headerset[j].elem).attr('id', currCellId);
}
rowheadersgroup= (rowheadersgroup ? rowheadersgroup + ' ' + currCellId : currCellId);
}
currRow.idsheaderset = rowheadersgroup;
}
if (currRow.header) {
for (j = 0; j < currRow.header.length; j += 1) {
var currCellId2 = $(currRow.header[j].elem).attr('id');
if (currCellId2 === undefined || currCellId2 === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId2 = idPrefix + currRow.header[j].uid; // Generate a new ID
$(currRow.header[j].elem).attr('id', currCellId2);
}
rowheaders = (rowheaders ? rowheaders + ' ' + currCellId2 : currCellId2);
}
}
rowheaders = (currRow.idsheaderset ? currRow.idsheaderset + ' ' + rowheaders : rowheaders);
for (j = 0; j < currRow.cell.length; j += 1) {
if ((j === 0) || (j > 0 && currRow.cell[j].uid !== currRow.cell[(j - 1)].uid)){
var currCell = currRow.cell[j],
coldataheader = "";
if (currCell.col && !currCell.col.dataheader) {
var currCol = currCell.col;
var colheaders = "",
colheadersgroup = "";
if (currCol.headerLevel) {
for (m = 0; m < currCol.headerLevel.length; m += 1) {
var currCellId = $(currCol.headerLevel[m].elem).attr('id');
if (currCellId === undefined || currCellId === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId = idPrefix + currCol.headerLevel[m].uid; // Generate a new ID
$(currCol.headerLevel[m].elem).attr('id', currCellId);
}
colheadersgroup = (colheadersgroup ? colheadersgroup + ' ' + currCellId : currCellId);
}
}
if (currCol.header) {
for (m = 0; m < currCol.header.length; m += 1) {
var currCellId = $(currCol.header[m].elem).attr('id');
if (currCellId === undefined || currCellId === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId = idPrefix + currCol.header[m].uid; // Generate a new ID
$(currCol.header[m].elem).attr('id', currCellId);
}
colheaders = (colheaders ? colheaders + ' ' + currCellId : currCellId);
}
}
currCol.dataheader = (colheadersgroup ? colheadersgroup + ' ' + colheaders : colheaders);
}
if (currCell.col && currCell.col.dataheader) {
coldataheader = currCell.col.dataheader;
}
if (currCell.type === 1) {
$(currCell.elem).attr('headers', (coldataheader ? coldataheader : '') +
(currRow.idsheaderset && coldataheader ? ' ' : '') +
(currRow.idsheaderset ? currRow.idsheaderset : '') +
((currRow.idsheaderset && ongoingRowHeader) || (coldataheader && ongoingRowHeader && !currRow.idsheaderset) ? ' ' : '') +
(ongoingRowHeader ? ongoingRowHeader : ''));
if ($(currCell.elem).attr('headers') === undefined || $(currCell.elem).attr('headers') === '') {
$(currCell.elem).removeAttr('headers');
}
var currCellId5 = $(currCell.elem).attr('id');
if (currCellId5 === undefined || currCellId5 === '' || resetIds) {
// currCellId5 = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId5 = idPrefix + currCell.uid; // Generate a new ID
$(currCell.elem).attr('id', currCellId5);
}
ongoingRowHeader = (ongoingRowHeader !== '' ? ongoingRowHeader + ' ' : '') + currCellId5;
}
if (currCell.type === 2 || currCell.type === 3) {
// Get Current Column Headers
currrowheader = rowheaders;
if (currCell.addcolheaders) {
for (m = 0; m < currCell.addcolheaders.length; m += 1) {
var currCellId = $(currCell.addcolheaders[m].elem).attr('id');
if (currCellId === undefined || currCellId === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId = idPrefix + currCell.addcolheaders[m].uid; // Generate a new ID
$(currCell.addcolheaders[m].elem).attr('id', currCellId);
}
coldataheader = (coldataheader ? coldataheader + ' ' + currCellId : currCellId);
}
}
if (currCell.addrowheaders) {
for (m = 0; m < currCell.addrowheaders.length; m += 1) {
var currCellId = $(currCell.addrowheaders[m].elem).attr('id');
if (currCellId === undefined || currCellId === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId = idPrefix + currCell.addrowheaders[m].uid; // Generate a new ID
$(currCell.addrowheaders[m].elem).attr('id', currCellId);
}
currrowheader = (currrowheader ? currrowheader + ' ' + currCellId : currCellId);
}
}
$(currCell.elem).attr('headers', (coldataheader ? coldataheader : '') + (currrowheader && coldataheader ? ' ' : '') + (currrowheader ? currrowheader : ''));
if ($(currCell.elem).attr('headers') === undefined || $(currCell.elem).attr('headers') === '') {
$(currCell.elem).removeAttr('headers');
}
}
if (currCell.type === 4 || currCell.type === 5) {
var descHeaders = "";
if (currCell.describe) {
for (m = 0; m < currCell.describe.length; m += 1) {
var currCellId = $(currCell.describe[m].elem).attr('id');
if (currCellId === undefined || currCellId === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId = idPrefix + currCell.describe[m].uid; // Generate a new ID
$(currCell.describe[m].elem).attr('id', currCellId);
}
descHeaders = (descHeaders ? descHeaders + ' ' + currCellId : currCellId);
if (currCell.type === 5 && !$(currCell.describe[m].elem).attr('aria-describedby')) {
var currCellId = $(currCell.elem).attr('id');
if (currCellId === undefined || currCellId === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId = idPrefix + currCell.uid; // Generate a new ID
$(currCell.elem).attr('id', currCellId);
}
$(currCell.describe[m].elem).attr('aria-describedby', currCellId);
}
}
}
if (currCell.type !== 4) {
$(currCell.elem).attr('headers', (coldataheader ? coldataheader : '') + (coldataheader && descHeaders ? ' ' : '') + (descHeaders || ''));
if ($(currCell.elem).attr('headers') === undefined || $(currCell.elem).attr('headers') === '') {
$(currCell.elem).removeAttr('headers');
}
} else if (!$(currCell.elem).attr('aria-describedby')) {
$(currCell.elem).attr('aria-describedby', descHeaders || '');
$(currCell.elem).attr('headers', coldataheader || '');
if ($(currCell.elem).attr('headers') === undefined || $(currCell.elem).attr('headers') === '') {
$(currCell.elem).removeAttr('headers');
}
}
}
}
}
}
// Check for any description that are related to the an group header cell
for (i = 0; i < tblparser.lstrowgroup.length; i += 1) {
if (tblparser.lstrowgroup[i].headerlevel.length > 0) {
for (j = 0; j < tblparser.lstrowgroup[i].headerlevel.length; j += 1){
if (tblparser.lstrowgroup[i].headerlevel[j].descCell) {
// Set the aria-describedby
var currDescCellId = $(tblparser.lstrowgroup[i].headerlevel[j].descCell.elem).attr('id');
if (currDescCellId === undefined || currDescCellId === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currDescCellId = idPrefix + tblparser.lstrowgroup[i].headerlevel[j].descCell.uid; // Generate a new ID
$(tblparser.lstrowgroup[i].headerlevel[j].descCell.elem).attr('id', currDescCellId);
}
$(tblparser.lstrowgroup[i].headerlevel[j].elem).attr('aria-describedby', currDescCellId);
// Set the headers
currCellId = $(tblparser.lstrowgroup[i].headerlevel[j].elem).attr('id');
if (currCellId === undefined || currCellId === '' || resetIds) {
// currCellId = idPrefix + new Date().getTime() + currCell.uid; // Generate a new ID
currCellId = idPrefix + tblparser.lstrowgroup[i].headerlevel[j].uid; // Generate a new ID
$(tblparser.lstrowgroup[i].headerlevel[j].elem).attr('id', currCellId);
}
$(tblparser.lstrowgroup[i].headerlevel[j].descCell.elem).attr('headers', currCellId);
}
}
}
}
// Horay, now all the table cell have theirs id/headers set as the table was parsed,
// Suggestion: Add some aria-label to annonce the data summary, I will ask the WAI Interrest Mailing List to get some liable solution
// tfoot question: do I force it as exclusive column summaries as the HTML5 spec define it if it used as table footnote ??
// Add the missing tag if they are missing, "colgroup, col, thead, tbody", remove tfoot ????
var previousColgroup = false;
for (i = 0; i < tblparser.colgroup.length; i += 1) {
if (tblparser.colgroup[i].elem === undefined) {
// Create a colgroup element
colgroupelem = $('<colgroup></colgroup>');
// Create the column
for (j = 0; j < tblparser.colgroup[i].col.length; j += 1) {
var column = $('<col />');
$(colgroupelem).append(column);
tblparser.colgroup[i].col[j].elem = $(column).get(0);
$(column).data().tblparser = tblparser.colgroup[i].col[j];
}
if (previousColgroup) {
$(previousColgroup).after(colgroupelem);
} else {
if ($(tblelement).has('caption')) {
$('caption:eq(0)', tblelement).after(colgroupelem);
} else {
$(tblelement).prepend(colgroupelem);
}
}
previousColgroup = colgroupelem;
tblparser.colgroup[i].elem = $(colgroupelem).get(0);
$(colgroupelem).data().tblparser = tblparser.colgroup[i];
} else {
// Remove the span attribute if exist
colgroupelem = tblparser.colgroup[i].elem;
$(colgroupelem).removeAttr('span');
// Create the column
for (j = 0; j < tblparser.colgroup[i].col.length; j += 1) {
if (tblparser.colgroup[i].col[j].elem === undefined) {
var column = $('<col />');
$(colgroupelem).append(column);
tblparser.colgroup[i].col[j].elem = $(column).get(0);
$(column).data().tblparser = tblparser.colgroup[i].col[j];
}
}
}
}
// TODO: Rebuild the thead, tbody section
displayTableResult();
// }
};
// setTimeout(function(){
// _pe.wb_load({'dep': ['parserTable']}, "depsTableParserLoaded")
// }, 2000);
$('#analysetable').click(function(){
//var noErrorList = '<li>No Error Found</li>',
var noErrorList = '<li>Table passed, see the resulting source code bellow</li>',
genericMessage = '<li>Use the above text field to analyse your HTML Complex Table Source Code</li>',
emptyTable = '<li>Empty Table</li>',
parsingInProgress = '<li>Please wait, you will see the result in a moment.</li>';
nbErrorFound = 0;
$('#resultTableIdHeaders').val('');
$('#resultTableIdHeaders').empty();
$('#resultTableIdHeaders').append('<pre>Nothing to being displayed</pre>');
$('#errorList').empty();
$('#directOutput').empty();
if($('#addzebra').is(':checked')){
$('#directOutput').append(tableOpenTagZebraNoEncode + $('#inputHTMLtable').val() + '</table>');
} else {
$('#directOutput').append(tableOpenTagNoEncode + $('#inputHTMLtable').val() + '</table>');
}
if($('#chkHassum').is(':checked')){
$('#directOutput table:eq(0)').addClass('hassum');
}
if ($('#directOutput table:eq(0)').length === 0) {
alert('Please add HTML Table code');
// $('#directOutput').empty();
$('#errorList').append($(genericMessage));
return;
}
$('#errorList').append($(parsingInProgress));
if (_pe.fn.parsertable) {
optimizeAccessibilitySet();
} else {
$(document).on('depsTableParserLoaded', optimizeAccessibilitySet);
_pe.wb_load({'dep': ['parserTable']}, "depsTableParserLoaded");
}
});
$('#addzebra').click(function () {
if($('#addzebra').is(':checked')){
$('#tableopentag').html(tableOpenTagZebra);
} else {
$('#tableopentag').html(tableOpenTag);
}
});
if($('#addzebra').is(':checked')){
$('#tableopentag').html(tableOpenTagZebra);
} else {
$('#tableopentag').html(tableOpenTag);
}
$('#chkHassum').click(function () {
if($('#chkHassum').is(':checked')){
$('#hassumoption').show();
} else {
$('#hassumoption').hide();
}
});
if($('#chkHassum').is(':checked')){
$('#hassumoption').show();
} else {
$('#hassumoption').hide();
}
});
}(jQuery));
//]]>
</script>
<!-- CustomScriptsCSSEnd -->
</head>
<body><div id="wb-body">
<div id="wb-skip">
<ul id="wb-tphp">
<li id="wb-skip1"><a href="#wb-cont">Skip to main content</a></li>
<li id="wb-skip2"><a href="#wb-nav">Skip to footer</a></li>
</ul>
</div>
<div id="wb-head"><div id="wb-head-in"><header>
<!-- HeaderStart -->
<nav role="navigation"><div id="gcwu-gcnb"><h2>Government of Canada navigation bar</h2><div id="gcwu-gcnb-in"><div id="gcwu-gcnb-fip">
<div id="gcwu-sig"><div id="gcwu-sig-in"><div id="gcwu-sig-eng" title="Government of Canada"><img src="../../dist/theme-gcwu-fegc/images/sig-eng.gif" width="214" height="20" alt="Government of Canada" /></div></div></div>
<ul>
<li id="gcwu-gcnb1"><a rel="external" href="http://www.canada.gc.ca/home.html">Canada.gc.ca</a></li>
<li id="gcwu-gcnb2"><a rel="external" href="http://www.servicecanada.gc.ca/eng/home.shtml">Services</a></li>
<li id="gcwu-gcnb3"><a rel="external" href="http://www.canada.gc.ca/depts/major/depind-eng.html">Departments</a></li>
<li id="gcwu-gcnb-lang"><a href="#" lang="fr">Français</a></li>
</ul>
</div></div></div></nav>
<div id="gcwu-bnr" role="banner"><div id="gcwu-bnr-in">
<div id="gcwu-wmms"><div id="gcwu-wmms-in"><div id="gcwu-wmms-fip" title="Symbol of the Government of Canada"><img src="../../dist/theme-gcwu-fegc/images/wmms.gif" width="126" height="30" alt="Symbol of the Government of Canada" /></div></div></div>
<div id="gcwu-title"><p id="gcwu-title-in"><a href="../../index-eng.html">Web Experience Toolkit (WET)</a></p></div>
<section role="search"><div id="gcwu-srchbx"><h2>Search</h2>
<form action="#" method="post"><div id="gcwu-srchbx-in">
<label for="gcwu-srch">Search website</label><input id="gcwu-srch" name="gcwu-srch" type="text" value="" size="27" maxlength="150" />
<input id="gcwu-srch-submit" name="gcwu-srch-submit" type="submit" value="Search" data-icon="search" />
</div></form>
</div></section>
</div></div>
<nav role="navigation">
<div id="gcwu-psnb"><h2><span>Site </span>menu</h2><div id="gcwu-psnb-in"><div class="wet-boew-menubar mb-mega"><div>
<ul class="mb-menu" data-ajax-replace="../includes/menu-eng.txt">
<li><div><a href="http://wet-boew.github.com/wet-boew/index-eng.html">WET project</a></div></li>
<li><div><a href="section2/index-eng.html">Section 2</a></div></li>
<li><div><a href="#">Section 3</a></div></li>
<li><div><a href="#">Section 4</a></div></li>
<li><div><a href="#">Section 5</a></div></li>
<li><div><a href="#">Section 6</a></div></li>
<li><div><a href="#">Section 7</a></div></li>
</ul>
</div></div></div></div>
<div id="gcwu-bc"><h2>Breadcrumb trail</h2><div id="gcwu-bc-in">
<ol>
<li><a href="../../index-eng.html">Home</a></li>
<li><a href="../index-eng.html">Working examples</a></li>
<li>Table Usability - Web Experience Toolkit (WET)</li>
</ol>
</div></div>
</nav>
<!-- HeaderEnd -->
</header></div></div>
<div id="wb-core"><div id="wb-core-in" class="equalize">
<div id="wb-main" role="main"><div id="wb-main-in">
<!-- MainContentStart -->
<h1 id="wb-cont">HTML Table Validator - Table Usability - Web Experience Toolkit (WET)</h1>
<h2>Instruction</h2>
<p>This validator would help you find any relationship error defined in your complex table. The validation process can be accomplished by <strong>pasting your HTML table source code without the table element</strong> in the text field below and clicking the button "<strong>Analyse</strong>".</p>
<p>Once the validator has detected that your complex and simple table is well structured, under the Result heading you will get access to a version with the best accessibility method that can be used on your complex and simple table markup. By default, all the ids, headers, scope and class are removed. If you want to keep your table ids, please check the option "Do not clean the HTML Tabular Markup". Please note that you would have different HTML markup result of the same complex table depending of the browser used, but both are valid as per the HTML5 specification. For example, with Firefox and chrome the HTML tag are in lowercase and in Internet Explorer you get HTML tag in uppercase.<p>
<div class="module-alert span-8">
<p>The table structure analysis is based on the WCAG 2.0 Level AA, HTML5 specification, the <a href="#wethtmltabletechnique">12 techniques</a> listed below under "Resources" and with the concept of having summary group (activated with the option "hassum").<p>
</div>
<div class="clear"></div>
<h2>Analysing your Complex HTML Table</h2>
<form class="form-inline span-8 background-light">
<frameset>
<legend>Options</legend>
<label class="form-checkbox" for="chkHassum"><input type="checkbox" value="chkHassum" id="chkHassum"/> Has Summary Group (<em>"hassum" option</em>)<sup id="fnb1-ref"><a class="footnote-link" href="#fnb1"><span class="wb-invisible">Footnote </span>1</a></sup></label>
<label class="form-checkbox" for="byPassOnErrorStop"><input type="checkbox" value="byPassOnErrorStop" id="byPassOnErrorStop"/> Force the HTML Results<sup id="fnb2-ref"><a class="footnote-link" href="#fnb2"><span class="wb-invisible">Footnote </span>2</a></sup></label><br />
<label class="form-checkbox" for="chkCleanMarkup"><input type="checkbox" value="chkCleanMarkup" id="chkCleanMarkup"/> Do not clean the HTML Tabular Markup<sup id="fnb3-ref"><a class="footnote-link" href="#fnb3"><span class="wb-invisible">Footnote </span>3</a></sup></label>
<label class="form-checkbox" for="addzebra"><input type="checkbox" value="addzebra" id="addzebra"/> Zebra Stripping Enhancement</label><br />
<label for="idprefix">Ids Prefix:</label>
<input id="idprefix" value="tbl" /><br />
</frameset>
<div class="clear"></div>
<frameset>
<legend>Please add content bellow</legend>
<div>
<p id="hassumoption" class="background-highlight">Will be analysed with <strong>Has Summary Group</strong> (<em>"hassum"</em>) option</p>
<p class="background-highlight"><code id="tableopentag"><table></code></p>
<textarea id="inputHTMLtable" class="width-90" rows="20" cols="50" placeholder="Paste your HTML Table Source Code"></textarea>
<p class="background-highlight"><code></table></code></p>
</div>
</frameset>
<div class="clear"></div>
<button id="analysetable" class="button button-accent">Analyse</button>
</form>
<div class="clear"></div>
<div id="directOutput"></div>
<h3>Message</h3>
<ul id="errorList">
<li>Use the above text field to analyse your HTML Complex Table Source Code</li>
</ul>
<h3>Result</h3>
<div id="resultTableIdHeaders" class="wet-boew-prettify">
<pre>
Nothing to being displayed
</pre>
</div>
<hr />
<h2>Resources</h2>
<p><a href="index-eng.html">View all resource</a></p>
<h3>Simple Table</h3>
<ul>
<li>Zero or one row used to define column headers. That row is located at the top of the table.</li>
<li>Zero or one column used to define row headers. That is the first cell for each row, excluding the first table row if it used for columns headers.</li>
<li>If there is no table footers (<code>tfoot</code>) row group, the row grouping element <code>thead, tbody</code> can be omited.</li>
</ul>
<details>
<summary>Simple Example</summary>
<pre><code>
<table>