Improved null/undefined checks
This commit is contained in:
parent
5c88b367f0
commit
632557800c
@ -75,7 +75,7 @@ loadingBar.show = function(status, errorText) {
|
|||||||
|
|
||||||
loadingBar.hide = function(force) {
|
loadingBar.hide = function(force) {
|
||||||
|
|
||||||
if ((loadingBar.status!=='error' && loadingBar.status!==null) || force) {
|
if ((loadingBar.status!=='error' && loadingBar.status!=null) || force) {
|
||||||
|
|
||||||
// Remove status
|
// Remove status
|
||||||
loadingBar.status = null
|
loadingBar.status = null
|
||||||
|
@ -143,7 +143,7 @@ lychee.loginDialog = function() {
|
|||||||
|
|
||||||
if (localStorage) {
|
if (localStorage) {
|
||||||
let localUsername = localStorage.getItem('lychee_username')
|
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="username"]').val(localUsername)
|
||||||
$('.basicModal input[name="password"]').focus()
|
$('.basicModal input[name="password"]').focus()
|
||||||
}
|
}
|
||||||
@ -181,8 +181,8 @@ lychee.load = function() {
|
|||||||
contextMenu.close()
|
contextMenu.close()
|
||||||
multiselect.close()
|
multiselect.close()
|
||||||
|
|
||||||
if (hash[0]!==undefined) albumID = hash[0]
|
if (hash[0]!=null) albumID = hash[0]
|
||||||
if (hash[1]!==undefined) photoID = hash[1]
|
if (hash[1]!=null) photoID = hash[1]
|
||||||
|
|
||||||
if (albumID && photoID) {
|
if (albumID && photoID) {
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ lychee.load = function() {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Trash albums.json when filled with search results
|
// Trash albums.json when filled with search results
|
||||||
if (search.hash!==null) {
|
if (search.hash!=null) {
|
||||||
albums.json = null
|
albums.json = null
|
||||||
search.hash = null
|
search.hash = null
|
||||||
}
|
}
|
||||||
@ -327,7 +327,7 @@ lychee.retinize = function(path = '') {
|
|||||||
extention = path.split('.').pop(),
|
extention = path.split('.').pop(),
|
||||||
hasRetina = extention!=='svg'
|
hasRetina = extention!=='svg'
|
||||||
|
|
||||||
if ((pixelRatio!==undefined && pixelRatio>1) && hasRetina===true) {
|
if ((pixelRatio!=null && pixelRatio>1) && hasRetina===true) {
|
||||||
|
|
||||||
path = path.replace(/\.[^/.]+$/, '')
|
path = path.replace(/\.[^/.]+$/, '')
|
||||||
path = path + '@2x' + '.' + extention
|
path = path + '@2x' + '.' + extention
|
||||||
|
@ -199,7 +199,7 @@ multiselect.getSelection = function(e) {
|
|||||||
|
|
||||||
let id = $(this).data('id')
|
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)
|
ids.push(id)
|
||||||
$(this).addClass('active')
|
$(this).addClass('active')
|
||||||
|
@ -659,7 +659,7 @@ photo.getSize = function() {
|
|||||||
if (photo.json.width>view.width || photo.json.height>view.height) scaled = true
|
if (photo.json.width>view.width || photo.json.height>view.height) scaled = true
|
||||||
|
|
||||||
// Calculate pixel ratio of screen
|
// Calculate pixel ratio of screen
|
||||||
if (pixelRatio!==undefined && pixelRatio>1) {
|
if (pixelRatio!=null && pixelRatio>1) {
|
||||||
view.width = view.width * pixelRatio
|
view.width = view.width * pixelRatio
|
||||||
view.height = view.height * pixelRatio
|
view.height = view.height * pixelRatio
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ search.reset = function() {
|
|||||||
$('#search').val('')
|
$('#search').val('')
|
||||||
$('.no_content').remove()
|
$('.no_content').remove()
|
||||||
|
|
||||||
if (search.hash!==null) {
|
if (search.hash!=null) {
|
||||||
|
|
||||||
// Trash data
|
// Trash data
|
||||||
albums.json = null
|
albums.json = null
|
||||||
|
@ -88,7 +88,7 @@ upload.start = {
|
|||||||
if (file.supported===false) {
|
if (file.supported===false) {
|
||||||
|
|
||||||
// Skip file
|
// Skip file
|
||||||
if (file.next!==null) process(files, file.next)
|
if (file.next!=null) process(files, file.next)
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// Look for supported files
|
// Look for supported files
|
||||||
@ -217,7 +217,7 @@ upload.start = {
|
|||||||
$('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status').html('Processing')
|
$('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status').html('Processing')
|
||||||
|
|
||||||
// Upload next file
|
// Upload next file
|
||||||
if (file.next!==null) process(files, file.next)
|
if (file.next!=null) process(files, file.next)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ view.albums = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore scroll position
|
// 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)
|
$(document).scrollTop(view.albums.content.scrollPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ const getPhotoSize = function(photo) {
|
|||||||
if (photo.json.width>view.width || photo.json.height>view.height) scaled = true
|
if (photo.json.width>view.width || photo.json.height>view.height) scaled = true
|
||||||
|
|
||||||
// Calculate pixel ratio of screen
|
// Calculate pixel ratio of screen
|
||||||
if (pixelRatio!==undefined && pixelRatio>1) {
|
if (pixelRatio!=null && pixelRatio>1) {
|
||||||
view.width = view.width * pixelRatio
|
view.width = view.width * pixelRatio
|
||||||
view.height = view.height * pixelRatio
|
view.height = view.height * pixelRatio
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ visible.photo = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
visible.search = function() {
|
visible.search = function() {
|
||||||
if (search.hash!==null) return true
|
if (search.hash!=null) return true
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user