From 187f3000385f136c8766fbfb2d18d24832ecf4b5 Mon Sep 17 00:00:00 2001 From: Juuso Lapinlampi Date: Mon, 28 Sep 2015 19:03:34 +0000 Subject: Fix unexpected use of undefined with Boolean() Airbnb style guide recommends checking booleans this way or using (!!window.FormData). The latter is more confusing for many. While !! is indeed 0.2% faster than Boolean(), it's called micro-optimization. There is no noticeable difference to the user in our use scenario and I prefer more readable code any day. Fixes ESLint no-undefined warning using Airbnb ES5 config. Reference: https://jsperf.com/boolean-conversion-speed --- js/cabinet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/cabinet.js b/js/cabinet.js index 2f3a3a6..a74bb40 100644 --- a/js/cabinet.js +++ b/js/cabinet.js @@ -23,7 +23,7 @@ /* jshint browser:true, jquery:true */ (function($) { $.hasFileAPI = function hasFileAPI() { - return (window.FormData !== undefined); + return Boolean(window.FormData); }; $.fn.cabinet = function(input) { -- cgit v1.2.3 From 11e9d2d0e6d7266ff119fdab9947e879192bd75e Mon Sep 17 00:00:00 2001 From: Juuso Lapinlampi Date: Mon, 28 Sep 2015 19:14:49 +0000 Subject: Add missing var declarations to undefined variables Fixes ESLint no-undef warnings using Airbnb ES5 config. --- js/cheesesteak.js | 2 +- js/pomf.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/cheesesteak.js b/js/cheesesteak.js index ea3dc19..1ee32b8 100644 --- a/js/cheesesteak.js +++ b/js/cheesesteak.js @@ -160,7 +160,7 @@ xhr.upload.addEventListener('progress', function(e) { if (e.lengthComputable) { - size = e.loaded; + var size = e.loaded; /** * We know the size of the files, the order they're in, and how diff --git a/js/pomf.js b/js/pomf.js index 7dd44ef..71972e1 100644 --- a/js/pomf.js +++ b/js/pomf.js @@ -49,7 +49,7 @@ $(function() { }); uploadBtn.on('dragleave', function(e) { - node = e.target; + var node = e.target; do { if (node === this) { $(this).removeClass('drop'); -- cgit v1.2.3 From 4df31fdd704663107cf2e187e6b55483a0edafd3 Mon Sep 17 00:00:00 2001 From: Juuso Lapinlampi Date: Mon, 28 Sep 2015 19:18:49 +0000 Subject: Add missing var declaration to EventEmitter Previous commit 11e9d2d forgot to add the var declaration here. Fixes ESLint no-undef warnings using Airbnb ES5 config. --- js/cheesesteak.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/cheesesteak.js b/js/cheesesteak.js index 1ee32b8..ea3b786 100644 --- a/js/cheesesteak.js +++ b/js/cheesesteak.js @@ -23,7 +23,7 @@ /* jshint browser:true, jquery:true */ (function() { // Lightweight EventEmitter implementation - EventEmitter = function() {}; + var EventEmitter = function() {}; EventEmitter.prototype.on = function(evt, fn) { this._events = this._events || {}; -- cgit v1.2.3