Browse Source

Improved getID

Tobias Reich 10 years ago
parent
commit
7314245e60
2 changed files with 10 additions and 11 deletions
  1. 5 6
      src/scripts/album.js
  2. 5 5
      src/scripts/photo.js

+ 5 - 6
src/scripts/album.js

@@ -11,18 +11,17 @@ album = {
 
 album.getID = function() {
 
-	var id;
+	var id = null;
 
 	if (photo.json)			id = photo.json.album;
 	else if (album.json)	id = album.json.id;
-	else					id = $('.album:hover, .album.active').attr('data-id');
 
 	// Search
-	if (!id) id = $('.album:hover, .album.active').attr('data-id');
-	if (!id) id = $('.photo:hover, .photo.active').attr('data-album-id');
+	if ($.isNumeric(id)===false) id = $('.album:hover, .album.active').attr('data-id');
+	if ($.isNumeric(id)===false) id = $('.photo:hover, .photo.active').attr('data-album-id');
 
-	if (id)	return id;
-	else	return false;
+	if ($.isNumeric(id)===true)	return id;
+	else						return false;
 
 }
 

+ 5 - 5
src/scripts/photo.js

@@ -12,13 +12,13 @@ photo = {
 
 photo.getID = function() {
 
-	var id;
+	var id = null;
 
-	if (photo.json) id = photo.json.id;
-	else id = $('.photo:hover, .photo.active').attr('data-id');
+	if (photo.json)	id = photo.json.id;
+	else			id = $('.photo:hover, .photo.active').attr('data-id');
 
-	if (id) return id;
-	else return false;
+	if ($.isNumeric(id)===false)	return id;
+	else							return false;
 
 }