diff options
author | Benjamin Jones <bjones@galois.com> | 2013-06-17 00:22:49 -0700 |
---|---|---|
committer | Benjamin Jones <bjones@galois.com> | 2013-06-17 00:22:49 -0700 |
commit | 27e7d5dbd6d6510df67b72f193fbdaaf7e837e59 (patch) | |
tree | 2d9a4d5ae23cc4208844d5306f39ed5a84ace6a3 /exampleData/ruleSets/basic | |
parent | 465269594485f4bf61c7475ac0f46c95b7357014 (diff) |
big cleanup and reorganization of exampleData directory; bugfixes to the basic/ rules; added test_basic.html for testing basic UI rules
Diffstat (limited to 'exampleData/ruleSets/basic')
-rw-r--r-- | exampleData/ruleSets/basic/basicUIRules.json | 3 | ||||
-rw-r--r-- | exampleData/ruleSets/basic/capitalHeadings.js | 18 | ||||
-rw-r--r-- | exampleData/ruleSets/basic/emptyHrefs.js | 5 | ||||
-rw-r--r-- | exampleData/ruleSets/basic/labelFields.js | 11 | ||||
-rw-r--r-- | exampleData/ruleSets/basic/test_basic.html | 42 |
5 files changed, 69 insertions, 10 deletions
diff --git a/exampleData/ruleSets/basic/basicUIRules.json b/exampleData/ruleSets/basic/basicUIRules.json index bfa755d..0a6346c 100644 --- a/exampleData/ruleSets/basic/basicUIRules.json +++ b/exampleData/ruleSets/basic/basicUIRules.json @@ -2,5 +2,6 @@ , "description": "A selection of simple HTML guidelines for improved usability and consistency" , "rules": [ "labelFields.js", "emptyHeadings.js", - "emptyHrefs.js" ] + "emptyHrefs.js", + "capitalHeadings.js" ] } diff --git a/exampleData/ruleSets/basic/capitalHeadings.js b/exampleData/ruleSets/basic/capitalHeadings.js new file mode 100644 index 0000000..ec44fd7 --- /dev/null +++ b/exampleData/ruleSets/basic/capitalHeadings.js @@ -0,0 +1,18 @@ +exports.name = 'Capitalized headings'; +exports.description = 'All headings should lead with a capital letter'; + +exports.rule = function(report) { + var badHeadings = $5(':header').filter( + function(idx) { + var ch = $(this).text()[0]; + if (ch) { + return (ch == ch.toLowerCase()); + } + else { + return false; + } + }); + $(badHeadings).each(function(i, elt) { + report.error('Heading does not start with a capital letter', elt); + }); +}; diff --git a/exampleData/ruleSets/basic/emptyHrefs.js b/exampleData/ruleSets/basic/emptyHrefs.js index 2be60f2..ad6290d 100644 --- a/exampleData/ruleSets/basic/emptyHrefs.js +++ b/exampleData/ruleSets/basic/emptyHrefs.js @@ -1,12 +1,11 @@ exports.name = "Don't use empty hrefs"; exports.description = "Links with no text can't generally be used"; exports.rule = - function() { - var that = this; + function(report) { fiveui.query('a').each( function(i, elt) { if ($(elt).text() == '' && elt.title == '') { - that.report('Link has no text', elt); + report.error('Link has no text', elt); } }); }; diff --git a/exampleData/ruleSets/basic/labelFields.js b/exampleData/ruleSets/basic/labelFields.js index e93c370..cb0068a 100644 --- a/exampleData/ruleSets/basic/labelFields.js +++ b/exampleData/ruleSets/basic/labelFields.js @@ -4,19 +4,18 @@ exports.description = '<p>Screen readers rely on HTML attributes to identify the + 'attributes that specify the id of the form element they pertain to. ' + 'Some of the components of this web page do not have those labels.</p>'; -exports.rule = function() { - var that = this; - fiveui.query(':input').each( +exports.rule = function(report) { + $5(':input').each( function(i, elt) { if (elt.id) { - var $label = fiveui.query("label[for='" + elt.id + "']"); + var $label = $5("label[for='" + elt.id + "']"); if (1 < $label.size()) { - that.report('Form element has too many labels', elt); + report.error('Form element has too many labels', elt); } if (0 == $label.size()) { - that.report('Form element has no label', elt); + report.error('Form element has no label', elt); } } }); diff --git a/exampleData/ruleSets/basic/test_basic.html b/exampleData/ruleSets/basic/test_basic.html new file mode 100644 index 0000000..defcbac --- /dev/null +++ b/exampleData/ruleSets/basic/test_basic.html @@ -0,0 +1,42 @@ +<html> +<head> + <title> + Testing Basic UI Rules + </title> +</head> + +<body> +<h1>Welcome to my webpage!</h1> + +<h2>this is an H2</h2> + +<h3></h3> + +Oops, that was an empty H3 header above. Oh well.. + +Here is a <a href="http://google.com">link</a>, but here is an +<u>empty</u> one: <a href="http://twitter.com"></a>. + +<hr> + +<div id="form-div"> + <h2>Just look at this form!</h2> + + Here's an input field: + + <form> + <label for="b">Favorite number</label> + <input type="number" id="b" value="50"> + </form> + + I'm going to leave out the semantic tags this time! + + <form> + Airspeed velocity of an unladen swallow: + <input type="number" id="s" value="121"> + </form> +</div> + + +</body> +</html> |