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
|
/* colorRules.json
* Author: Benjamin Jones <bjones@galois.com>
*
* Simple rules for checking that the colors of specific elements are in a specific set.
* Test using exampleData/basic/testColorRules.html
*/
{ 'name': "Colors are in a specified set"
, 'description': "All background and foreground colors used on a page should be in a specificed set"
, 'rules': [
{ 'name': "Foregrounds"
, 'description': "Foreground colors should be in the set:"+
"'#0, #FFFFFF, #3D3D3D, #B4B4B4, #4E4E4E, #C2C2C2, #F7F7F7"
, 'rule':
function() { //----------------------------------------------
var allowableColors = { '#0': 1, '#FFFFFF': 1, '#3D3D3D': 1,
'#B4B4B4': 1, '#4E4E4E': 1, '#C2C2C2': 1,
'#F7F7F7': 1 };
fiveui.query(':visible').each(
function(i, elt) {
var color = $(elt).css('color');
if (!(fiveui.color.color.colorToHex(color) in allowableColors)) {
report('Disallowed FOREground color ' +
fiveui.color.colorToHex(color) +
' appears', $(elt));
}
});
} //---------------------------------------------------------
},//==============================================================
{ 'name': "Backgrounds"
, 'description': "Backgrounds colors are in the set:" +
"#000000, #FFFFFF, #3D3D3D, #B4B4B4, #4E4E4E, #C2C2C2"
, 'rule':
function() { //----------------------------------------------
var allowableColors = { '#0': 1, '#FFFFFF': 1,
'#3D3D3D': 1, '#B4B4B4': 1, '#4E4E4E': 1,
'#C2C2C2': 1 };
fiveui.query(':visible').each(
function(i, elt) {
var color = $(elt).css('background-color');
if (!(fiveui.color.colorToHex(color) in allowableColors)) {
report('Disallowed BACKground color ' +
fiveui.color.colorToHex(color) +
' appears', $(elt));
}
});
} //---------------------------------------------------------
},//==============================================================
{ 'name': "Content Area Color"
, 'description': "Content Area Color should be #F7"
, 'rule':
//----------
function() {
var allowableColors = { '#F7F7F7': 1 };
fiveui.query("#content").each(
function(i, elt) {
var color = $(elt).css('color');
if (!(fiveui.color.colorToHex(color) in allowableColors)) {
report('Invalid color '+fiveui.color.colorToHex(color) +
' in content area', $(elt));
}
});
} //---------------------------------------------------------
},//==============================================================
{ 'name': "Left Nav Color"
, 'description': "Left Nav Color should be #C2 (#4E if active)"
, 'rule':
//----------
function() {
var allowableColors = { '#C2C2C2': 1 };
fiveui.query("#nav-left").each(
function(i, elt) {
var color = $(elt).css('color');
// if active then .. 4E
if (!(fiveui.color.colorToHex(color) in allowableColors)) {
report('Invalid color '+fiveui.color.colorToHex(color) +
' in left nav area', $(elt));
}
});
} //---------------------------------------------------------
},//==============================================================
{ 'name': "Header Color"
, 'description': "Header Color should be #3D"
, 'rule':
//----------
function() {
var allowableColors = { '#3D3D3D': 1 };
fiveui.query(":header").each(
function(i, elt) {
var color = $(elt).css('color');
if (!(fiveui.color.colorToHex(color) in allowableColors)) {
report('Invalid color '+fiveui.color.colorToHex(color) +
' in header', $(elt));
}
});
} //---------------------------------------------------------
} //==============================================================
]
}
|