From 632557800c79ba4aa137bbf968c2f73f38b3894f Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Mon, 13 Jul 2015 14:29:02 +0200 Subject: [PATCH] Improved null/undefined checks --- src/scripts/loadingBar.js | 2 +- src/scripts/lychee.js | 10 +++++----- src/scripts/multiselect.js | 2 +- src/scripts/photo.js | 2 +- src/scripts/search.js | 2 +- src/scripts/upload.js | 4 ++-- src/scripts/view.js | 2 +- src/scripts/view/main.js | 2 +- src/scripts/visible.js | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/scripts/loadingBar.js b/src/scripts/loadingBar.js index 83d42d5..f613555 100755 --- a/src/scripts/loadingBar.js +++ b/src/scripts/loadingBar.js @@ -75,7 +75,7 @@ loadingBar.show = function(status, errorText) { loadingBar.hide = function(force) { - if ((loadingBar.status!=='error' && loadingBar.status!==null) || force) { + if ((loadingBar.status!=='error' && loadingBar.status!=null) || force) { // Remove status loadingBar.status = null diff --git a/src/scripts/lychee.js b/src/scripts/lychee.js index 9851a33..315ec7b 100644 --- a/src/scripts/lychee.js +++ b/src/scripts/lychee.js @@ -143,7 +143,7 @@ lychee.loginDialog = function() { if (localStorage) { let localUsername = localStorage.getItem('lychee_username') - if (localUsername!==null && localUsername.length>0) { + if (localUsername!=null && localUsername.length>0) { $('.basicModal input[name="username"]').val(localUsername) $('.basicModal input[name="password"]').focus() } @@ -181,8 +181,8 @@ lychee.load = function() { contextMenu.close() multiselect.close() - if (hash[0]!==undefined) albumID = hash[0] - if (hash[1]!==undefined) photoID = hash[1] + if (hash[0]!=null) albumID = hash[0] + if (hash[1]!=null) photoID = hash[1] if (albumID && photoID) { @@ -212,7 +212,7 @@ lychee.load = function() { } else { // Trash albums.json when filled with search results - if (search.hash!==null) { + if (search.hash!=null) { albums.json = null search.hash = null } @@ -327,7 +327,7 @@ lychee.retinize = function(path = '') { extention = path.split('.').pop(), hasRetina = extention!=='svg' - if ((pixelRatio!==undefined && pixelRatio>1) && hasRetina===true) { + if ((pixelRatio!=null && pixelRatio>1) && hasRetina===true) { path = path.replace(/\.[^/.]+$/, '') path = path + '@2x' + '.' + extention diff --git a/src/scripts/multiselect.js b/src/scripts/multiselect.js index 0b84d21..37bc2cb 100644 --- a/src/scripts/multiselect.js +++ b/src/scripts/multiselect.js @@ -199,7 +199,7 @@ multiselect.getSelection = function(e) { let id = $(this).data('id') - if (id!=='0' && id!==0 && id!=='f' && id!=='s' && id!=='r' && id!==null) { + if (id!=='0' && id!==0 && id!=='f' && id!=='s' && id!=='r' && id!=null) { ids.push(id) $(this).addClass('active') diff --git a/src/scripts/photo.js b/src/scripts/photo.js index 46d1d43..46c4fc6 100644 --- a/src/scripts/photo.js +++ b/src/scripts/photo.js @@ -659,7 +659,7 @@ photo.getSize = function() { if (photo.json.width>view.width || photo.json.height>view.height) scaled = true // Calculate pixel ratio of screen - if (pixelRatio!==undefined && pixelRatio>1) { + if (pixelRatio!=null && pixelRatio>1) { view.width = view.width * pixelRatio view.height = view.height * pixelRatio } diff --git a/src/scripts/search.js b/src/scripts/search.js index 0aec1aa..b168380 100755 --- a/src/scripts/search.js +++ b/src/scripts/search.js @@ -85,7 +85,7 @@ search.reset = function() { $('#search').val('') $('.no_content').remove() - if (search.hash!==null) { + if (search.hash!=null) { // Trash data albums.json = null diff --git a/src/scripts/upload.js b/src/scripts/upload.js index 75c7fc0..e536a75 100755 --- a/src/scripts/upload.js +++ b/src/scripts/upload.js @@ -88,7 +88,7 @@ upload.start = { if (file.supported===false) { // Skip file - if (file.next!==null) process(files, file.next) + if (file.next!=null) process(files, file.next) else { // Look for supported files @@ -217,7 +217,7 @@ upload.start = { $('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status').html('Processing') // Upload next file - if (file.next!==null) process(files, file.next) + if (file.next!=null) process(files, file.next) } diff --git a/src/scripts/view.js b/src/scripts/view.js index 01d83bd..537f4ad 100644 --- a/src/scripts/view.js +++ b/src/scripts/view.js @@ -62,7 +62,7 @@ view.albums = { } // Restore scroll position - if (view.albums.content.scrollPosition!==null && view.albums.content.scrollPosition!==0) { + if (view.albums.content.scrollPosition!=null && view.albums.content.scrollPosition!==0) { $(document).scrollTop(view.albums.content.scrollPosition) } diff --git a/src/scripts/view/main.js b/src/scripts/view/main.js index fd09264..c6e8c3e 100644 --- a/src/scripts/view/main.js +++ b/src/scripts/view/main.js @@ -50,7 +50,7 @@ const getPhotoSize = function(photo) { if (photo.json.width>view.width || photo.json.height>view.height) scaled = true // Calculate pixel ratio of screen - if (pixelRatio!==undefined && pixelRatio>1) { + if (pixelRatio!=null && pixelRatio>1) { view.width = view.width * pixelRatio view.height = view.height * pixelRatio } diff --git a/src/scripts/visible.js b/src/scripts/visible.js index 25eed62..3d51d4e 100755 --- a/src/scripts/visible.js +++ b/src/scripts/visible.js @@ -21,7 +21,7 @@ visible.photo = function() { } visible.search = function() { - if (search.hash!==null) return true + if (search.hash!=null) return true return false }