Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Follow some recommendations of jslint.

  • Loading branch information...
commit c9c6baaba85e1e3b5964bfb6dc3e0c9e5dce225e 1 parent db480b6
Winston Teo authored

Showing 1 changed file with 22 additions and 14 deletions. Show diff stats Hide diff stats

  1. +22 14 vendor/assets/javascripts/cactus.js
36 vendor/assets/javascripts/cactus.js
... ... @@ -1,13 +1,17 @@
1   -var Cactus = (function() {
  1 +var Cactus, CactusReport;
2 2
3   - // Public Accessor
4   - var _cactus = {};
  3 +Cactus = (function() {
  4 + // http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
  5 + "use strict";
5 6
6 7 // Private Variables
  8 + var _cactus = {};
7 9 var tag_name = null;
8 10 var property = null;
9 11 var styles = null;
10 12
  13 + // Public Methods
  14 +
11 15 // Debug
12 16 _cactus.debug = function() {
13 17 return {
@@ -20,7 +24,7 @@ var Cactus = (function() {
20 24 // Expectations
21 25 _cactus.expect = function(elem, attr) {
22 26 tag_name = elem;
23   - property = attr
  27 + property = attr;
24 28 styles = [ $(tag_name).css(property) ];
25 29
26 30 return this;
@@ -28,7 +32,7 @@ var Cactus = (function() {
28 32
29 33 _cactus.expectEvery = function(elem, attr) {
30 34 tag_name = elem;
31   - property = attr
  35 + property = attr;
32 36 styles = $.map( $(tag_name), function(elem, i) { return $(elem).css(property); } );
33 37
34 38 return this;
@@ -46,7 +50,7 @@ var Cactus = (function() {
46 50 _cactus.toHaveColor = function(expected_style) {
47 51 // Source: http://stackoverflow.com/questions/1740700/get-hex-value-rather-than-rgb-value-using-jquery
48 52 function rgb2hex(rgb) {
49   - function hex(x) { return ("0" + parseInt(x).toString(16)).slice(-2); }
  53 + function hex(x) { return ("0" + parseInt(x, 10).toString(16)).slice(-2); }
50 54
51 55 rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
52 56 return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
@@ -77,17 +81,21 @@ var Cactus = (function() {
77 81 // Return Accessor
78 82 return _cactus;
79 83
80   -})();
  84 +}());
81 85
82   -var CactusReport = (function() {
  86 +CactusReport = (function() {
  87 + // http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
  88 + "use strict";
83 89
84   - // Public Accessor
  90 + // Private Variables
85 91 var _cactus_report = {};
86 92
87 93 _cactus_report.render = function(status, message) {
88   - var $html = init_or_retrieve_report_container();
  94 + var $html, $row;
  95 +
  96 + $html = init_container();
89 97
90   - var $row = $(
  98 + $row = $(
91 99 "<div />",
92 100 {
93 101 html: message,
@@ -111,10 +119,10 @@ var CactusReport = (function() {
111 119
112 120 // Private Methods
113 121
114   - function init_or_retrieve_report_container() {
  122 + function init_container() {
115 123 var $html = $("#cactus");
116 124
117   - if ($html.length == 0) {
  125 + if ($html.length === 0) {
118 126 // Create a new div#cactus
119 127 $html = $("<div id='cactus'><div class='cactus_header'><div class='cactus_banner'>Cactus</div><div class='cactus_option'><a href='#' class='cactus_toggle_pass' style='display: none;'>Show Passes</a> | <a href='#' class='cactus_toggle_fail' style='display: none;'>Hide Failures</a></div></div></div>");
120 128
@@ -164,4 +172,4 @@ var CactusReport = (function() {
164 172 // Return Accessor
165 173 return _cactus_report;
166 174
167   -})();
  175 +}());

0 comments on commit c9c6baa

Please sign in to comment.
Something went wrong with that request. Please try again.