Permalink
Browse files

fix a whole bunch of jslint errors

  • Loading branch information...
1 parent de1aabd commit 736666ab890595be5d0f1429a8a98a5797d98e46 @bluesmoon committed Feb 22, 2013
Showing with 139 additions and 123 deletions.
  1. +81 −70 boomerang.js
  2. +5 −6 plugins/bw.js
  3. +2 −2 plugins/dns.js
  4. +4 −5 plugins/ipv6.js
  5. +3 −3 plugins/memory.js
  6. +1 −1 plugins/mobile.js
  7. +39 −36 plugins/rt.js
  8. +4 −0 plugins/zzz_last_plugin.js
View
@@ -28,16 +28,16 @@ BOOMR_start = new Date().getTime();
(function(w) {
// This is the only block where we use document without the w. qualifier
-if(w.parent != w
+if(w.parent !== w
&& document.getElementById('boomr-if-as')
- && document.getElementById('boomr-if-as').nodeName.toLowerCase() == 'script') {
+ && document.getElementById('boomr-if-as').nodeName.toLowerCase() === 'script') {
w = w.parent;
}
var impl, boomr, k, d=w.document;
// Short namespace because I don't want to keep typing BOOMERANG
-if(typeof w.BOOMR === "undefined") {
+if(w.BOOMR === undefined) {
w.BOOMR = {};
}
BOOMR = w.BOOMR;
@@ -83,11 +83,12 @@ impl = {
onclick_handler: function(ev) {
var target;
- if (!ev) ev = w.event;
- if (ev.target) target = ev.target;
- else if (ev.srcElement) target = ev.srcElement;
- if (target.nodeType == 3) // defeat Safari bug
+ if (!ev) { ev = w.event; }
+ if (ev.target) { target = ev.target; }
+ else if (ev.srcElement) { target = ev.srcElement; }
+ if (target.nodeType === 3) {// defeat Safari bug
target = target.parentNode;
+ }
// don't capture clicks on flash objects
// because of context slowdowns in PepperFlash
@@ -136,10 +137,12 @@ boomr = {
objectToString: function(o, separator) {
var value = [], k;
- if(!o || typeof o != "object")
+ if(!o || typeof o !== "object") {
return o;
- if(typeof separator === "undefined")
+ }
+ if(separator === undefined) {
separator="\n\t";
+ }
for(k in o) {
if(Object.prototype.hasOwnProperty.call(o, k)) {
@@ -231,7 +234,7 @@ boomr = {
}
for(i=0; i<properties.length; i++) {
- if(typeof config[plugin_name][properties[i]] !== "undefined") {
+ if(config[plugin_name][properties[i]] !== undefined) {
o[properties[i]] = config[plugin_name][properties[i]];
props++;
}
@@ -250,49 +253,50 @@ boomr = {
}
for(i=0; i<properties.length; i++) {
- if(typeof config[properties[i]] !== "undefined") {
+ if(config[properties[i]] !== undefined) {
impl[properties[i]] = config[properties[i]];
}
}
- if(typeof config.log !== "undefined") {
+ if(config.log !== undefined) {
this.log = config.log;
}
if(!this.log) {
- this.log = function(m,l,s) { };
+ this.log = function(/* m,l,s */) { };
}
for(k in this.plugins) {
- // config[pugin].enabled has been set to false
- if( config[k]
- && ("enabled" in config[k])
- && config[k].enabled === false
- ) {
- impl.disabled_plugins[k] = 1;
- continue;
- }
- else if(impl.disabled_plugins[k]) {
- delete impl.disabled_plugins[k];
- }
+ if(this.plugins.hasOwnProperty(k)) {
+ // config[pugin].enabled has been set to false
+ if( config[k]
+ && config[k].hasOwnProperty("enabled")
+ && config[k].enabled === false
+ ) {
+ impl.disabled_plugins[k] = 1;
+ continue;
+ }
+ else if(impl.disabled_plugins[k]) {
+ delete impl.disabled_plugins[k];
+ }
- // plugin exists and has an init method
- if(this.plugins.hasOwnProperty(k)
- && typeof this.plugins[k].init === "function"
- ) {
- this.plugins[k].init(config);
+ // plugin exists and has an init method
+ if(typeof this.plugins[k].init === "function") {
+ this.plugins[k].init(config);
+ }
}
}
- if(impl.handlers_attached)
+ if(impl.handlers_attached) {
return this;
+ }
// The developer can override onload by setting autorun to false
- if(!impl.onloadfired && (!("autorun" in config) || config.autorun !== false)) {
+ if(!impl.onloadfired && (config.autorun === undefined || config.autorun !== false)) {
if(d.readyState && d.readyState === "complete") {
this.setImmediate(BOOMR.page_ready, null, null, BOOMR);
}
else {
- if("onpagehide" in w) {
+ if(w.onpagehide || w.onpagehide === null) {
impl.addListener(w, "pageshow", BOOMR.page_ready);
}
else {
@@ -303,27 +307,32 @@ boomr = {
impl.addListener(w, "DOMContentLoaded", function() { impl.fireEvent("dom_loaded"); });
- // visibilitychange is useful to detect if the page loaded through prerender
- // or if the page never became visible
- // http://www.w3.org/TR/2011/WD-page-visibility-20110602/
- // http://www.nczonline.net/blog/2011/08/09/introduction-to-the-page-visibility-api/
- var fire_visible = function() { impl.fireEvent("visibility_changed"); }
- if(d.webkitVisibilityState)
- impl.addListener(d, "webkitvisibilitychange", fire_visible);
- else if(d.msVisibilityState)
- impl.addListener(d, "msvisibilitychange", fire_visible);
- else if(d.visibilityState)
- impl.addListener(d, "visibilitychange", fire_visible);
+ (function() {
+ // visibilitychange is useful to detect if the page loaded through prerender
+ // or if the page never became visible
+ // http://www.w3.org/TR/2011/WD-page-visibility-20110602/
+ // http://www.nczonline.net/blog/2011/08/09/introduction-to-the-page-visibility-api/
+ var fire_visible = function() { impl.fireEvent("visibility_changed"); };
+ if(d.webkitVisibilityState) {
+ impl.addListener(d, "webkitvisibilitychange", fire_visible);
+ }
+ else if(d.msVisibilityState) {
+ impl.addListener(d, "msvisibilitychange", fire_visible);
+ }
+ else if(d.visibilityState) {
+ impl.addListener(d, "visibilitychange", fire_visible);
+ }
- impl.addListener(d, "mouseup", impl.onclick_handler);
+ impl.addListener(d, "mouseup", impl.onclick_handler);
- if(!("onpagehide" in w)) {
- // This must be the last one to fire
- // We only clear w on browsers that don't support onpagehide because
- // those that do are new enough to not have memory leak problems of
- // some older browsers
- impl.addListener(w, "unload", function() { BOOMR.window=w=null; });
- }
+ if(!w.onpagehide && w.onpagehide !== null) {
+ // This must be the last one to fire
+ // We only clear w on browsers that don't support onpagehide because
+ // those that do are new enough to not have memory leak problems of
+ // some older browsers
+ impl.addListener(w, "unload", function() { BOOMR.window=w=null; });
+ }
+ }());
impl.handlers_attached = true;
return this;
@@ -364,7 +373,7 @@ boomr = {
},
subscribe: function(e_name, fn, cb_data, cb_scope) {
- var i, h, e;
+ var i, h, e, unload_handler;
if(!impl.events.hasOwnProperty(e_name)) {
return this;
@@ -382,7 +391,7 @@ boomr = {
e.push([ fn, cb_data || {}, cb_scope || null ]);
// attaching to page_ready after onload fires, so call soon
- if(e_name == 'page_ready' && impl.onloadfired) {
+ if(e_name === 'page_ready' && impl.onloadfired) {
this.setImmediate(fn, null, cb_data, cb_scope);
}
@@ -393,14 +402,14 @@ boomr = {
// support it. This allows us to fall back to onunload when onbeforeunload
// isn't implemented
if(e_name === 'page_unload') {
- var unload_handler = function(ev) {
+ unload_handler = function(ev) {
if(fn) {
fn.call(cb_scope, ev || w.event, cb_data);
}
};
// pagehide is for iOS devices
// see http://www.webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/
- if("onpagehide" in w) {
+ if(w.onpagehide || w.onpagehide === null) {
impl.addListener(w, "pagehide", unload_handler);
}
else {
@@ -427,15 +436,15 @@ boomr = {
return this;
},
- removeVar: function() {
+ removeVar: function(arg0) {
var i, params;
if(!arguments.length) {
return this;
}
if(arguments.length === 1
- && Object.prototype.toString.apply(arguments[0]) === "[object Array]") {
- params = arguments[0];
+ && Object.prototype.toString.apply(arg0) === "[object Array]") {
+ params = arg0;
}
else {
params = arguments;
@@ -470,7 +479,7 @@ boomr = {
impl.vars.v = BOOMR.version;
impl.vars.u = d.URL.replace(/#.*/, '');
// use d.URL instead of location.href because of a safari bug
- if(w != window) {
+ if(w !== window) {
impl.vars["if"] = "";
}
@@ -520,24 +529,27 @@ boomr = {
delete BOOMR_start;
-var make_logger = function(l) {
- return function(m, s) {
- this.log(m, l, "boomerang" + (s?"."+s:"")); return this;
+(function() {
+ var make_logger = function(l) {
+ return function(m, s) {
+ this.log(m, l, "boomerang" + (s?"."+s:""));
+ return this;
+ };
};
-};
-boomr.debug = make_logger("debug");
-boomr.info = make_logger("info");
-boomr.warn = make_logger("warn");
-boomr.error = make_logger("error");
+ boomr.debug = make_logger("debug");
+ boomr.info = make_logger("info");
+ boomr.warn = make_logger("warn");
+ boomr.error = make_logger("error");
+}());
if(w.YAHOO && w.YAHOO.widget && w.YAHOO.widget.Logger) {
boomr.log = w.YAHOO.log;
}
-else if(typeof w.Y !== "undefined" && typeof w.Y.log !== "undefined") {
+else if(w.Y && w.Y.log) {
boomr.log = w.Y.log;
}
-else if(typeof console !== "undefined" && typeof console.log !== "undefined") {
+else if(typeof console === "object" && console.log !== undefined) {
boomr.log = function(m,l,s) { console.log(s + ": [" + l + "] " + m); };
}
@@ -557,4 +569,3 @@ BOOMR.plugins = BOOMR.plugins || {};
-/*jslint white: false, devel: true, onevar: true, browser: true, undef: true, nomen: true, regexp: false, continue: true, plusplus: false, bitwise: false, newcap: true, maxerr: 50, indent: 4 */
View
@@ -6,6 +6,7 @@
// This is the Bandwidth & Latency plugin abbreviated to BW
(function() {
+var impl, images;
BOOMR = BOOMR || {};
BOOMR.plugins = BOOMR.plugins || {};
@@ -20,7 +21,7 @@ BOOMR.plugins = BOOMR.plugins || {};
// bytes respectively
// See https://spreadsheets.google.com/ccc?key=0AplxPyCzmQi6dDRBN2JEd190N1hhV1N5cHQtUVdBMUE&hl=en_GB
// for a spreadsheet with the details
-var images=[
+images=[
{ name: "image-0.png", size: 11483, timeout: 1400 },
{ name: "image-1.png", size: 40658, timeout: 1200 },
{ name: "image-2.png", size: 164897, timeout: 1300 },
@@ -39,7 +40,7 @@ images.start = 0;
images.l = { name: "image-l.gif", size: 35, timeout: 1000 };
// private object
-var impl = {
+impl = {
// properties
base_url: '',
timeout: 15000,
@@ -171,7 +172,7 @@ var impl = {
bandwidths_corrected.push(bw_c);
if(r[j].t < this.latency.mean) {
- debug_info.push("" + j + "_" + r[j].t);
+ debug_info.push(j + "_" + r[j].t);
}
}
}
@@ -350,9 +351,7 @@ var impl = {
// we terminate if an image timed out because that means the connection is
// too slow to go to the next image
- if(i >= images.end-1
- || typeof this.results[this.nruns-run].r[i+1] !== "undefined"
- ) {
+ if(i >= images.end-1 || this.results[this.nruns-run].r[i+1] !== undefined) {
BOOMR.debug(this.results[this.nruns-run], "bw");
// First run is a pilot test to decide what the largest image
// that we can download is. All following runs only try to
View
@@ -31,7 +31,7 @@ var impl = {
}
var random = Math.random().toString(36),
- cache_bust = "" + (new Date().getTime()) + (Math.random());
+ cache_bust = (new Date().getTime()) + "." + (Math.random());
impl.gen_url = impl.base_url.replace(/\*/, random);
@@ -46,7 +46,7 @@ var impl = {
var cache_bust;
impl.t_dns = new Date().getTime() - impl.t_start;
- cache_bust = "" + (new Date().getTime()) + (Math.random());
+ cache_bust = (new Date().getTime()) + "." + (Math.random());
impl.img = new Image();
impl.img.onload = impl.B_loaded;
View
@@ -68,7 +68,7 @@ var impl = {
a = arguments;
// Terminate if we've reached end of test list
- if(!which || !(which in this.timers)) {
+ if(!which || !this.timers.hasOwnProperty(which)) {
this.done();
return false;
}
@@ -166,10 +166,9 @@ BOOMR.plugins.IPv6 = {
impl.complete = true;
return this;
}
- else {
- impl.ipv6_url = impl.ipv6_url.replace(/^https:/, 'http:');
- impl.host_url = impl.host_url.replace(/^https:/, 'http:');
- }
+
+ impl.ipv6_url = impl.ipv6_url.replace(/^https:/, 'http:');
+ impl.host_url = impl.host_url.replace(/^https:/, 'http:');
BOOMR.subscribe("page_ready", impl.start, null, impl);
BOOMR.subscribe("page_unload", impl.skip, null, impl);
View
@@ -23,12 +23,12 @@ var impl = {
p = w.performance,
c = w.console,
d = w.document,
- _f = (({}).toString.call(w.opera) == '[object Opera]' ? d.querySelectorAll : d.getElementsByTagName),
- m;
+ fn = (({}).toString.call(w.opera) === '[object Opera]' ? d.querySelectorAll : d.getElementsByTagName),
+ m, f;
// handle IE6/7 weirdness regarding host objects
// See: http://stackoverflow.com/questions/7125288/what-is-document-getelementbyid
- var f = (typeof _f.call === 'undefined' ? function(tag) { return _f(tag) } : _f);
+ f = (fn.call === undefined ? function(tag) { return fn(tag); } : fn);
m = (p && p.memory ? p.memory : (c && c.memory ? c.memory : null));
Oops, something went wrong.

0 comments on commit 736666a

Please sign in to comment.