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
|
{ 'name': 'Text capitalization guidelines'
, 'description': 'Guidelines regarding capitalization of text withing the page'
, 'rules': [
//---------------------------------------------------------------
{ 'id': 19042301
, 'name': 'Sentence case'
, 'description': 'Titles should be written in sentence case'
, 'rule':
function() {
var posLength = function(ar) {
return 1 <= ar.length;
};
/**
* Test str to see if it is in sentence case.
*/
var assertSentenceCase = function(inStr, elt) {
var str = fiveui.string.trim(inStr);
if (!fiveui.word.capitalized(str[0])) {
report('The heading: [' + str + '] is not in sentence case.', elt);
return;
}
var tokens = str.split(' ').filter(posLength);
for (var i = 1; i < tokens.length; ++i) {
if (fiveui.word.capitalized(tokens[i])) {
report('The heading: [' + str + '] is not in sentence case.', elt);
return;
}
}
};
fiveui.query(':header').each(function(idx, elt) {
assertSentenceCase($(elt).text(), elt);
});
}
},
//---------------------------------------------------------------
{ 'id': 19042302
, 'name': 'Capitalization check'
, 'description': 'Capitalize \"Galois\" and \"Galwegian\" when referring to the company'
, 'rule':
function() {
fiveui.query('*').hasText('galois').each(function(i, elt) {
report('\"Galois\" should be capitalized', elt);
});
fiveui.query('*').hasText('galwegian').each(function(i, elt) {
report('\"Galwegian\" should be capitalized', elt);
});
}
}//,
//---------------------------------------------------------------
]
}
|