-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtables.js
127 lines (125 loc) · 11.2 KB
/
tables.js
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
javascript: (function() {
function callback() {
function l() {
$("span").remove(".openSpan, .closeSpan, .inputSpan");
$("table, [role=grid]").attr('style','outline:2px solid olive;');
$("caption").each(function() {
$(this).attr('style','outline:green 2px solid;padding:2px;');
$(this).prepend("<span class=\"openSpan\" style=\"padding:1px;color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;z-index:2147483647;speak:literal-punctuation;\"><caption>🎓</span>");
$(this).append("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;speak:literal-punctuation;\"></caption></span>");
});
$("th").each(function() {
$(this).attr('style','outline:green 2px solid;padding:2px;');
if ($(this).attr('scope')) {
if ($(this).attr('id')) {
if ($(this).attr('scope') == 'row') {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th♿scope=\"row\"🚣 id=\""+$(this).attr('id')+"\"></span>");
}
if ($(this).attr('scope') == 'col') {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th♿scope=\"col\"👇 id=\""+$(this).attr('id')+"\"></span>");
}
} else if ($(this).attr('role')) {
if ($(this).attr('scope') == 'row') {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th♿scope=\"row\"🚣 ♿role=\""+$(this).attr('role')+"\"></span>");
}
if ($(this).attr('scope') == 'col') {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th♿scope=\"col\"👇 ♿role=\""+$(this).attr('role')+"\"></span>");
}
} else {
if ($(this).attr('scope') == 'row') {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th♿scope=\"row\"🚣></span>");
}
if ($(this).attr('scope') == 'col') {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th♿scope=\"col\"👇></span>");
}
}
} else if ($(this).attr('headers')) {
if ($(this).attr('id')) {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th♿headers=\""+$(this).attr('headers')+"\" id=\""+$(this).attr('id')+"\"></span>");
} else {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th♿headers=\""+$(this).attr('headers')+"\"></span>");
}
} else if ($(this).attr('id')) {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th id=\""+$(this).attr('id')+"\">♿</span>");
} else if ($(this).attr('role')) {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th♿role=\""+$(this).attr('role')+"\"></span>");
} else {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><th>♿</span>");
}
});
$("td").each(function() {
$(this).attr('style','outline:orange 2px dashed;padding:2px;');
if ($(this).attr('headers')) {
if ($(this).attr('role')) {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><td♿headers=\""+$(this).attr('headers')+"\"♿role=\""+$(this).attr('role')+"\"></span>");
} else {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><td♿headers=\""+$(this).attr('headers')+"\"></span>");
}
} else if ($(this).attr('role')) {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><td♿role=\""+$(this).attr('role')+"\"></span>");
} else {
$(this).prepend("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><td></span>");
}
});
$("table").each(function() {
if ($(this).attr('summary')) {
$(this).before("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><table♿summary=\""+$(this).attr('summary')+"\"></span>");
} else if ($(this).attr('aria-label')) {
$(this).before("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><table♿aria-label=\""+$(this).attr('aria-label')+"\"></span>");
} else if($(this).attr('aria-labelledby')) {
$(this).before("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;outline:orange 2px dashed;margin:0 2px; padding:2px;speak:literal-punctuation;\"><table♿aria-labelledby=\""+$(this).attr('aria-labelledby')+"\"></span>");
var labelledbyValue = $(this).attr('aria-labelledby');
var labelledbyArray = labelledbyValue.split(' ');
for (i = 0; i < labelledbyArray.length; i++) {
$('[id="'+labelledbyArray[i]+'"]').attr('style','outline:orange 2px dashed;');
$('[id="'+labelledbyArray[i]+'"]').prepend("<span class=\"inputSpan\" style=\"padding:1px;color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;outline:orange 2px dashed;z-index:2147483647;speak:literal-punctuation;\">id=\""+labelledbyArray[i]+"\"</span>");
}
}
else if ($(this).attr('role') == 'presentation') {
$(this).before("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><table♿role=\""+$(this).attr('role')+"\"></span>");
} else {
$(this).before("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><table></span>");
}
});
$("[role=grid]").each(function() {
if ($(this).attr('aria-readonly')){
$(this).before("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\">♿role=\""+$(this).attr('role')+"\"♿aria-readonly=\""+$(this).attr('aria-readonly')+"\"</span>");
} else if ($(this).attr('aria-labelledby') && $(this).attr('aria-readonly')){
$(this).before("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\">♿role=\""+$(this).attr('role')+"\"♿aria-labelledby=\""+$(this).attr('aria-labelledby')+"\"♿aria-readonly=\""+$(this).attr('aria-readonly')+"\"</span>");
} else if ($(this).attr('aria-label') && $(this).attr('aria-readonly')){
$(this).before("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\">♿role=\""+$(this).attr('role')+"\"♿aria-label=\""+$(this).attr('aria-label')+"\"♿aria-readonly=\""+$(this).attr('aria-readonly')+"\"</span>");
} else {
$(this).before("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\">♿role=\""+$(this).attr('role')+"\"</span>");
}
});
$("tr[role]").each(function() {
$(this).before("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;speak:literal-punctuation;\"><tr♿role=\""+$(this).attr('role')+"\"></span>");
});
$('td[headers], th[headers]').each(function(index) {
var describedbyValue = $(this).attr('headers');
var describedbyArray = describedbyValue.split(' ');
for (i = 0; i < describedbyArray.length; i++) {
var idString = "#";
idString += describedbyArray[i];
if ($(idString).length <=0 && $('[id="'+describedbyArray[i]+'"]')) {
$(this).attr('style','outline:red 2px dotted;padding:2px;');
$(this).append("<span class=\"closeSpan\" style=\"color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;speak:literal-punctuation;\">❌NO ID MATCH</span>");
}
}
});
if (!$("table").length) {
$('body').prepend('<strong style="color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;" id="failure" role="status"></strong>');
$('#failure').html('No Tables Found on Page: ' + document.title);
setTimeout(function(){ $('#failure').remove(); }, 6000);
} else {
$('body').append('<div id="success" role="alert" style="position:absolute; width:0; height:0; clip: rect(0,0,0,0);"></div>');
$('#success').html('Success! Tables Found on Page: ' + document.title);
setTimeout(function(){ $('#success').remove(); }, 3000);
}
$("script[src$='tables.js']").remove();s.remove();
}
l()
}
var s = document.createElement("script");
s.addEventListener ? s.addEventListener("load", callback, !1) : s.readyState && (s.onreadystatechange = callback), s.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js", document.body.appendChild(s);
})()