Browse Source

Updated albums.js (ES2015)

Tobias Reich 8 years ago
parent
commit
a0ea271bd6
3 changed files with 76 additions and 77 deletions
  1. 0 0
      dist/main.js
  2. 4 3
      src/scripts/album.js
  3. 72 74
      src/scripts/albums.js

File diff suppressed because it is too large
+ 0 - 0
dist/main.js


+ 4 - 3
src/scripts/album.js

@@ -36,8 +36,7 @@ album.load = function(albumID, refresh) {
 
 		if (!refresh) lychee.animate('#content', 'contentZoomOut')
 
-		let startTime = new Date().getTime(),
-		    waitTime  = 0
+		let startTime = new Date().getTime()
 
 		let params = {
 			albumID,
@@ -46,6 +45,8 @@ album.load = function(albumID, refresh) {
 
 		api.post('Album::get', params, function(data) {
 
+			let waitTime = 0
+
 			if (data==='Warning: Album private!') {
 
 				if (document.location.hash.replace('#', '').split('/')[1]!=undefined) {
@@ -76,7 +77,7 @@ album.load = function(albumID, refresh) {
 			if (refresh===true)                                            waitTime = 0
 			if (!visible.albums() && !visible.photo() && !visible.album()) waitTime = 0
 
-			setTimeout(function() {
+			setTimeout(() => {
 
 				view.album.init()
 

+ 72 - 74
src/scripts/albums.js

@@ -11,61 +11,59 @@ albums = {
 
 albums.load = function() {
 
-	var startTime,
-		durationTime,
-		waitTime;
+	let startTime = new Date().getTime()
 
-	lychee.animate('#content', 'contentZoomOut');
-
-	startTime = new Date().getTime();
+	lychee.animate('#content', 'contentZoomOut')
 
 	if (albums.json===null) {
 
 		api.post('Album::getAll', {}, function(data) {
 
-			/* Smart Albums */
-			if (lychee.publicMode===false) albums._createSmartAlbums(data.smartalbums);
+			let waitTime = 0
+
+			// Smart Albums
+			if (lychee.publicMode===false) albums._createSmartAlbums(data.smartalbums)
 
-			albums.json = data;
+			albums.json = data
 
 			// Calculate delay
-			durationTime = (new Date().getTime() - startTime);
-			if (durationTime>300)	waitTime = 0;
-			else					waitTime = 300 - durationTime;
+			let durationTime = (new Date().getTime() - startTime)
+			if (durationTime>300) waitTime = 0
+			else                  waitTime = 300 - durationTime
 
 			// Skip delay when opening a blank Lychee
-			if (!visible.albums()&&!visible.photo()&&!visible.album())	waitTime = 0;
-			if (visible.album()&&lychee.content.html()==='')			waitTime = 0;
+			if (!visible.albums() && !visible.photo() && !visible.album()) waitTime = 0
+			if (visible.album() && lychee.content.html()==='')             waitTime = 0
 
-			setTimeout(function() {
-				header.setMode('albums');
-				view.albums.init();
-				lychee.animate('#content', 'contentZoomIn');
-			}, waitTime);
+			setTimeout(() => {
+				header.setMode('albums')
+				view.albums.init()
+				lychee.animate('#content', 'contentZoomIn')
+			}, waitTime)
 
-		});
+		})
 
 	} else {
 
-		setTimeout(function() {
-			header.setMode('albums');
-			view.albums.init();
-			lychee.animate('#content', 'contentZoomIn');
-		}, 300);
+		setTimeout(() => {
+			header.setMode('albums')
+			view.albums.init()
+			lychee.animate('#content', 'contentZoomIn')
+		}, 300)
 
 	}
 }
 
 albums.parse = function(album) {
 
-	if (album.password==='1'&&lychee.publicMode===true) {
-		album.thumbs[0] = 'src/images/password.svg';
-		album.thumbs[1] = 'src/images/password.svg';
-		album.thumbs[2] = 'src/images/password.svg';
+	if (album.password==='1' && lychee.publicMode===true) {
+		album.thumbs[0] = 'src/images/password.svg'
+		album.thumbs[1] = 'src/images/password.svg'
+		album.thumbs[2] = 'src/images/password.svg'
 	} else {
-		if (!album.thumbs[0])	album.thumbs[0]	= 'src/images/no_images.svg';
-		if (!album.thumbs[1])	album.thumbs[1]	= 'src/images/no_images.svg';
-		if (!album.thumbs[2])	album.thumbs[2]	= 'src/images/no_images.svg';
+		if (!album.thumbs[0]) album.thumbs[0] = 'src/images/no_images.svg'
+		if (!album.thumbs[1]) album.thumbs[1] = 'src/images/no_images.svg'
+		if (!album.thumbs[2]) album.thumbs[2] = 'src/images/no_images.svg'
 	}
 
 }
@@ -73,36 +71,36 @@ albums.parse = function(album) {
 albums._createSmartAlbums = function(data) {
 
 	data.unsorted = {
-		id:			0,
-		title:		'Unsorted',
-		sysdate:	data.unsorted.num + ' photos',
-		unsorted: 	'1',
-		thumbs:		data.unsorted.thumbs
-	};
+		id       : 0,
+		title    : 'Unsorted',
+		sysdate  : data.unsorted.num + ' photos',
+		unsorted : '1',
+		thumbs   : data.unsorted.thumbs
+	}
 
 	data.starred = {
-		id:			'f',
-		title:		'Starred',
-		sysdate:	data.starred.num + ' photos',
-		star:		'1',
-		thumbs:		data.starred.thumbs
-	};
+		id      : 'f',
+		title   : 'Starred',
+		sysdate : data.starred.num + ' photos',
+		star    : '1',
+		thumbs  : data.starred.thumbs
+	}
 
 	data.public = {
-		id:			's',
-		title:		'Public',
-		sysdate:	data.public.num + ' photos',
-		public:		'1',
-		thumbs:		data.public.thumbs
-	};
+		id      : 's',
+		title   : 'Public',
+		sysdate : data.public.num + ' photos',
+		public  : '1',
+		thumbs  : data.public.thumbs
+	}
 
 	data.recent = {
-		id:			'r',
-		title:		'Recent',
-		sysdate:	data.recent.num + ' photos',
-		recent:		'1',
-		thumbs:		data.recent.thumbs
-	};
+		id      : 'r',
+		title   : 'Recent',
+		sysdate : data.recent.num + ' photos',
+		recent  : '1',
+		thumbs  : data.recent.thumbs
+	}
 
 }
 
@@ -110,21 +108,21 @@ albums.getByID = function(albumID) {
 
 	// Function returns the JSON of an album
 
-	if (albumID===undefined||albumID===null)	return undefined;
-	if (!albums.json)							return undefined;
-	if (!albums.json.albums)					return undefined;
+	if (albumID==null)       return undefined
+	if (!albums.json)        return undefined
+	if (!albums.json.albums) return undefined
 
-	var json = undefined;
+	let json = undefined
 
 	$.each(albums.json.albums, function(i) {
 
-		let elem = albums.json.albums[i];
+		let elem = albums.json.albums[i]
 
-		if (elem.id==albumID) json = elem;
+		if (elem.id==albumID) json = elem
 
-	});
+	})
 
-	return json;
+	return json
 
 }
 
@@ -132,28 +130,28 @@ albums.deleteByID = function(albumID) {
 
 	// Function returns the JSON of an album
 
-	if (albumID===undefined||albumID===null)	return false;
-	if (!albums.json)							return false;
-	if (!albums.json.albums)					return false;
+	if (albumID==null)       return false
+	if (!albums.json)        return false
+	if (!albums.json.albums) return false
 
-	var deleted = false;
+	var deleted = false
 
 	$.each(albums.json.albums, function(i) {
 
 		if (albums.json.albums[i].id==albumID) {
-			albums.json.albums.splice(i, 1);
-			deleted = true;
-			return false;
+			albums.json.albums.splice(i, 1)
+			deleted = true
+			return false
 		}
 
-	});
+	})
 
-	return deleted;
+	return deleted
 
 }
 
 albums.refresh = function() {
 
-	albums.json = null;
+	albums.json = null
 
 }

Some files were not shown because too many files changed in this diff