-
Notifications
You must be signed in to change notification settings - Fork 3
/
1_3_1_InfoAndRelationships(A).js
executable file
·325 lines (317 loc) · 17 KB
/
1_3_1_InfoAndRelationships(A).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
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
setTimeout(() => {
InfoAndRelationships()
}, 2000);
function InfoAndRelationships() {
$.fn.log = function () {
console.log.apply(console, this);
return this;
};
var inputTags = document.querySelectorAll('input')
for (var d = 0; d < inputTags.length; d++) {
if (!inputTags[d].disabled) {
var testCasePass = false
if (inputTags[d].type == "text") {
var labelTags = document.querySelectorAll("label")
for (var x = 0; x < labelTags.length; x++) {
if (labelTags[x].htmlFor == inputTags[d].id) {
if (labelTags[x].innerText != null && labelTags[x].innerText != "") {
testCasePass = true
break
}
}
}
if (testCasePass == false) {
console.log("%cRule:%cWCAG 1.3.1 (2.0,A)",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #809FFF;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%cError:%cInput element (of type text) is missing text in the label",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #EB5177;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%cCode Snippet:",
`color: #FFF;
background-color: #333;
border-radius: 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
$(inputTags[d]).log()
console.log("%cFix:%cA text to the label corresponding to this input element has to be added in order to describe the function or purpose of the control",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #007075;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%c-----------------------------------------------------------------------------",
`color: #FFF;
background-color: #293543;
font-weight: bolder;
border-radius: 5px;
padding: 5px 10px;
font-size: 1rem;
display: inline;`)
}
if (inputTags[d].title == null || inputTags[d].title == "") {
console.log("%cRule:%cWCAG 1.3.1 (2.0,A)",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #809FFF;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%cError:%cInput element (of type text) is missing a title",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #EB5177;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%cCode Snippet:",
`color: #FFF;
background-color: #333;
border-radius: 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
$(inputTags[d]).log()
console.log("%cFix:%cA title has to be added to this input element in order to describe the function or purpose of the control",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #007075;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%c-----------------------------------------------------------------------------",
`color: #FFF;
background-color: #293543;
font-weight: bolder;
border-radius: 5px;
padding: 5px 10px;
font-size: 1rem;
display: inline;`)
}
var etestCasePass = false
var e1labelTags = document.querySelectorAll("label")
for (var x = 0; x < e1labelTags.length; x++) {
if (inputTags[d].contains(e1labelTags[x])) {
if (e1labelTags[x].innerText != null && e1labelTags[x].innerHTML != "") {
etestCasePass = true
break
}
}
}
if (etestCasePass == false) {
console.log("%cRule:%cWCAG 1.3.1 (2.0,A)",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #809FFF;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%cError:%cInput element (of type text) is missing a label",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #EB5177;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%cCode Snippet:",
`color: #FFF;
background-color: #333;
border-radius: 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
$(inputTags[d]).log()
console.log("%cFix:%cA label corresponding to this input element has to be added in order to describe the function or purpose of the control",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #007075;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%c-----------------------------------------------------------------------------",
`color: #FFF;
background-color: #293543;
font-weight: bolder;
border-radius: 5px;
padding: 5px 10px;
font-size: 1rem;
display: inline;`)
}
}
}
}
$(document).ready(function () {
$('*').each(function () {
if ($(this).prop("nodeName") == "P") {
var textRoot = ""
$(this).contents().filter(function () {
return this.nodeType == Node.TEXT_NODE && this.nodeValue.trim() != '';
}).each(function () {
textRoot += $(this).text();
});
if (!$.trim(textRoot)) {
var pTags = $(this).children()
for (var d = 0; d < pTags.length; d++) {
if ([d].nodeName == "FONT" ||
pTags[d].nodeName == "I" ||
pTags[d].nodeName == "B" ||
pTags[d].nodeName == "BOLD" ||
pTags[d].nodeName == "EM" ||
pTags[d].nodeName == "U" ||
pTags[d].nodeName == "STRONG") {
console.log("%cRule:%cWCAG 1.3.1 (2.0,A)",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #809FFF;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%cWarning:%c<p> might be misused as a header, its content should not be marked by any of font, i, b, u, em, strong tags",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #F6976E;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%cCode Snippet:",
`color: #FFF;
background-color: #333;
border-radius: 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
$(this).log()
console.log("%cFix:%cUse a header tag instead",
`color: #FFF;
background-color: #333;
border-radius: 5px 0px 0px 5px;
padding: 5px 10px;
font-size: 0.8rem;
display: inline;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`,
`color: #FFF;
display: inline;
font-size: 0.8rem;
background-color: #007075;
border-radius: 0px 5px 5px 0px;
padding: 5px 10px;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);`)
console.log("%c-----------------------------------------------------------------------------",
`color: #FFF;
background-color: #293543;
font-weight: bolder;
border-radius: 5px;
padding: 5px 10px;
font-size: 1rem;
display: inline;`)
break
}
}
}
}
}
)
})
}