Updated code style

This commit is contained in:
Tobias Reich 2016-01-24 15:16:03 +01:00
parent eb887c7ca8
commit 606968f349
17 changed files with 218 additions and 207 deletions

View File

@ -2,9 +2,9 @@ function gup(b) {
b = b.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]")
let a = "[\\?&]" + b + "=([^&#]*)",
d = new RegExp(a),
c = d.exec(window.location.href)
let a = "[\\?&]" + b + "=([^&#]*)"
let d = new RegExp(a)
let c = d.exec(window.location.href)
if (c === null) return ''
else return c[1]

View File

@ -146,12 +146,12 @@ album.add = function() {
album.delete = function(albumIDs) {
let action = {},
cancel = {},
msg = ''
let action = {}
let cancel = {}
let msg = ''
if (!albumIDs) return false
if (albumIDs instanceof Array===false) albumIDs = [albumIDs]
if (albumIDs instanceof Array===false) albumIDs = [ albumIDs ]
action.fn = function() {
@ -234,11 +234,11 @@ album.delete = function(albumIDs) {
album.setTitle = function(albumIDs) {
let oldTitle = '',
msg = ''
let oldTitle = ''
let msg = ''
if (!albumIDs) return false
if (albumIDs instanceof Array===false) albumIDs = [albumIDs]
if (albumIDs instanceof Array===false) albumIDs = [ albumIDs ]
if (albumIDs.length===1) {
@ -365,12 +365,12 @@ album.setPublic = function(albumID, modal, e) {
if (modal===true) {
let text = '',
action = {}
let text = ''
let action = {}
action.fn = () => {
// setPublic function without showing the modal
// Call setPublic function without showing the modal
album.setPublic(album.getID(), false, e)
}
@ -515,8 +515,8 @@ album.setPublic = function(albumID, modal, e) {
album.share = function(service) {
let link = '',
url = location.href
let link = ''
let url = location.href
switch (service) {
case 'twitter':
@ -539,8 +539,8 @@ album.share = function(service) {
album.getArchive = function(albumID) {
let link,
url = `${ api.path }?function=Album::getArchive&albumID=${ albumID }`
let link = ''
let url = `${ api.path }?function=Album::getArchive&albumID=${ albumID }`
if (location.href.indexOf('index.html')>0) link = location.href.replace(location.hash, '').replace('index.html', url)
else link = location.href.replace(location.hash, '') + url
@ -553,12 +553,12 @@ album.getArchive = function(albumID) {
album.merge = function(albumIDs) {
let title = '',
sTitle = '',
msg = ''
let title = ''
let sTitle = ''
let msg = ''
if (!albumIDs) return false
if (albumIDs instanceof Array===false) albumIDs = [albumIDs]
if (albumIDs instanceof Array===false) albumIDs = [ albumIDs ]
// Get title of first album
if (albums.json) title = albums.getByID(albumIDs[0]).title

View File

@ -134,7 +134,7 @@ albums.deleteByID = function(albumID) {
if (!albums.json) return false
if (!albums.json.albums) return false
var deleted = false
let deleted = false
$.each(albums.json.albums, function(i) {

View File

@ -14,7 +14,7 @@ api.post = function(fn, params, callback) {
loadingBar.show()
params = $.extend({function: fn}, params)
params = $.extend({ function: fn }, params)
const success = (data) => {
@ -31,9 +31,9 @@ api.post = function(fn, params, callback) {
else if (data==='') data = false
// Convert to JSON if string start with '{' and ends with '}'
if (typeof data==='string' &&
data.substring(0, 1)==='{' &&
data.substring(data.length-1, data.length)==='}') data = $.parseJSON(data)
if (typeof data==='string' && data.substring(0, 1)==='{' && data.substring(data.length - 1, data.length)==='}') {
data = $.parseJSON(data)
}
// Output response when debug mode is enabled
if (lychee.debugMode) console.log(data)

View File

@ -115,8 +115,8 @@ build.photo = function(data) {
build.imageview = function(data, visibleControls) {
let html = '',
hasMedium = data.medium!==''
let html = ''
let hasMedium = data.medium!==''
if (hasMedium===false) {
@ -182,7 +182,7 @@ build.uploadModal = function(title, files) {
let file = files[i]
if (file.name.length>40) file.name = file.name.substr(0, 17) + '...' + file.name.substr(file.name.length-20, 20)
if (file.name.length>40) file.name = file.name.substr(0, 17) + '...' + file.name.substr(file.name.length - 20, 20)
html += lychee.html`
<div class='row'>

View File

@ -53,9 +53,9 @@ contextMenu.album = function(albumID, e) {
let showMerge = (albums.json && albums.json.albums && Object.keys(albums.json.albums).length>1)
let items = [
{ title: build.iconic('pencil') + 'Rename', fn: () => album.setTitle([albumID]) },
{ title: build.iconic('pencil') + 'Rename', fn: () => album.setTitle([ albumID ]) },
{ title: build.iconic('collapse-left') + 'Merge', visible: showMerge, fn: () => { basicContext.close(); contextMenu.mergeAlbum(albumID, e) } },
{ title: build.iconic('trash') + 'Delete', fn: () => album.delete([albumID]) }
{ title: build.iconic('trash') + 'Delete', fn: () => album.delete([ albumID ]) }
]
$('.album[data-id="' + albumID + '"]').addClass('active')
@ -111,7 +111,7 @@ contextMenu.albumTitle = function(albumID, e) {
}
items.unshift({ title: build.iconic('pencil') + 'Rename', fn: () => album.setTitle([albumID]) })
items.unshift({ title: build.iconic('pencil') + 'Rename', fn: () => album.setTitle([ albumID ]) })
basicContext.show(items, e.originalEvent, contextMenu.close)
@ -133,7 +133,7 @@ contextMenu.mergeAlbum = function(albumID, e) {
let title = lychee.html`<img class='cover' width='16' height='16' src='$${ this.thumbs[0] }'><div class='title'>$${ this.title }</div>`
if (this.id!=albumID) items.push({ title, fn: () => album.merge([albumID, this.id]) })
if (this.id!=albumID) items.push({ title, fn: () => album.merge([ albumID, this.id ]) })
})
@ -154,13 +154,13 @@ contextMenu.photo = function(photoID, e) {
// in order to keep the selection
let items = [
{ title: build.iconic('star') + 'Star', fn: () => photo.setStar([photoID]) },
{ title: build.iconic('tag') + 'Tags', fn: () => photo.editTags([photoID]) },
{ title: build.iconic('star') + 'Star', fn: () => photo.setStar([ photoID ]) },
{ title: build.iconic('tag') + 'Tags', fn: () => photo.editTags([ photoID ]) },
{ },
{ title: build.iconic('pencil') + 'Rename', fn: () => photo.setTitle([photoID]) },
{ title: build.iconic('layers') + 'Duplicate', fn: () => photo.duplicate([photoID]) },
{ title: build.iconic('folder') + 'Move', fn: () => { basicContext.close(); contextMenu.move([photoID], e) } },
{ title: build.iconic('trash') + 'Delete', fn: () => photo.delete([photoID]) }
{ title: build.iconic('pencil') + 'Rename', fn: () => photo.setTitle([ photoID ]) },
{ title: build.iconic('layers') + 'Duplicate', fn: () => photo.duplicate([ photoID ]) },
{ title: build.iconic('folder') + 'Move', fn: () => { basicContext.close(); contextMenu.move([ photoID ], e) } },
{ title: build.iconic('trash') + 'Delete', fn: () => photo.delete([ photoID ]) }
]
$('.photo[data-id="' + photoID + '"]').addClass('active')
@ -194,7 +194,7 @@ contextMenu.photoMulti = function(photoIDs, e) {
contextMenu.photoTitle = function(albumID, photoID, e) {
let items = [
{ title: build.iconic('pencil') + 'Rename', fn: () => photo.setTitle([photoID]) }
{ title: build.iconic('pencil') + 'Rename', fn: () => photo.setTitle([ photoID ]) }
]
let data = album.json
@ -236,7 +236,7 @@ contextMenu.photoMore = function(photoID, e) {
contextMenu.move = function(photoIDs, e) {
var items = []
let items = []
api.post('Album::getAll', {}, function(data) {
@ -278,8 +278,8 @@ contextMenu.move = function(photoIDs, e) {
contextMenu.sharePhoto = function(photoID, e) {
let link = photo.getViewLink(photoID),
iconClass = 'ionicons'
let link = photo.getViewLink(photoID)
let iconClass = 'ionicons'
let items = [
{ title: `<input readonly id="link" value="${ link }">`, fn: () => {}, class: 'basicContext__item--noHover' },

View File

@ -46,17 +46,17 @@ header.bind = function() {
header.dom('#button_info') .on(eventName, sidebar.toggle)
header.dom('.button_add') .on(eventName, contextMenu.add)
header.dom('#button_more') .on(eventName, function(e) { contextMenu.photoMore(photo.getID(), e) })
header.dom('#button_move') .on(eventName, function(e) { contextMenu.move([photo.getID()], e) })
header.dom('#button_move') .on(eventName, function(e) { contextMenu.move([ photo.getID() ], e) })
header.dom('.header__hostedwith') .on(eventName, function() { window.open(lychee.website) })
header.dom('#button_trash_album') .on(eventName, function() { album.delete([album.getID()]) })
header.dom('#button_trash') .on(eventName, function() { photo.delete([photo.getID()]) })
header.dom('#button_trash_album') .on(eventName, function() { album.delete([ album.getID() ]) })
header.dom('#button_trash') .on(eventName, function() { photo.delete([ photo.getID() ]) })
header.dom('#button_archive') .on(eventName, function() { album.getArchive(album.getID()) })
header.dom('#button_star') .on(eventName, function() { photo.setStar([photo.getID()]) })
header.dom('#button_star') .on(eventName, function() { photo.setStar([ photo.getID() ]) })
header.dom('#button_back_home') .on(eventName, function() { lychee.goto('') })
header.dom('#button_back') .on(eventName, function() { lychee.goto(album.getID()) })
header.dom('.header__search').on('keyup click', function() { search.find($(this).val()) })
header.dom('.header__clear').on(eventName, function () {
header.dom('.header__clear').on(eventName, function() {
header.dom('.header__search').focus()
search.reset()
})
@ -99,8 +99,8 @@ header.hide = function(e, delay = 500) {
header.setTitle = function(title = 'Untitled') {
let $title = header.dom('.header__title'),
html = lychee.html`$${ title }${ build.iconic('caret-bottom') }`
let $title = header.dom('.header__title')
let html = lychee.html`$${ title }${ build.iconic('caret-bottom') }`
$title.html(html)

View File

@ -24,38 +24,38 @@ $(document).ready(function() {
// Keyboard
Mousetrap
.bind('left', function() {
.bind([ 'left' ], function() {
if (visible.photo()) { $('#imageview a#previous').click(); return false }
})
.bind('right', function() {
.bind([ 'right' ], function() {
if (visible.photo()) { $('#imageview a#next').click(); return false }
})
.bind('u', function() {
.bind([ 'u' ], function() {
if (!visible.photo()) { $('#upload_files').click(); return false }
})
.bind(['s', 'f'], function() {
.bind([ 's', 'f' ], function() {
if (visible.photo()) { header.dom('#button_star').click(); return false }
else if (visible.albums()) { header.dom('.header__search').focus(); return false }
})
.bind('r', function() {
.bind([ 'r' ], function() {
if (visible.album()) { album.setTitle(album.getID()); return false }
else if (visible.photo()) { photo.setTitle([photo.getID()]); return false }
})
.bind('d', function() {
.bind([ 'd' ], function() {
if (visible.photo()) { photo.setDescription(photo.getID()); return false }
else if (visible.album()) { album.setDescription(album.getID()); return false }
})
.bind('t', function() {
.bind([ 't' ], function() {
if (visible.photo()) { photo.editTags([photo.getID()]); return false }
})
.bind('i', function() {
.bind([ 'i' ], function() {
if (!visible.multiselect()) { sidebar.toggle(); return false }
})
.bind(['command+backspace', 'ctrl+backspace'], function() {
.bind([ 'command+backspace', 'ctrl+backspace' ], function() {
if (visible.photo() && basicModal.visible()===false) { photo.delete([photo.getID()]); return false }
else if (visible.album() && basicModal.visible()===false) { album.delete([album.getID()]); return false }
})
.bind(['command+a', 'ctrl+a'], function() {
.bind([ 'command+a', 'ctrl+a' ], function() {
if (visible.album() && basicModal.visible()===false) { multiselect.selectAll(); return false }
else if (visible.albums() && basicModal.visible()===false) { multiselect.selectAll(); return false }
})
@ -64,7 +64,7 @@ $(document).ready(function() {
if (basicModal.visible()===true) basicModal.action()
})
Mousetrap.bindGlobal(['esc', 'command+up'], function() {
Mousetrap.bindGlobal([ 'esc', 'command+up' ], function() {
if (basicModal.visible()===true) basicModal.cancel()
else if (visible.contextMenu()) contextMenu.close()
else if (visible.photo()) lychee.goto(album.getID())

View File

@ -84,8 +84,8 @@ lychee.init = function() {
lychee.login = function(data) {
let user = data.username,
password = data.password
let user = data.username
let password = data.password
let params = {
user,
@ -169,9 +169,9 @@ lychee.goto = function(url) {
lychee.load = function() {
let albumID = '',
photoID = '',
hash = document.location.hash.replace('#', '').split('/')
let albumID = ''
let photoID = ''
let hash = document.location.hash.replace('#', '').split('/')
$('.no_content').remove()
contextMenu.close()
@ -227,9 +227,13 @@ lychee.load = function() {
lychee.getUpdate = function() {
const success = function(data) {
if (data.lychee.version>parseInt(lychee.versionCode)) $('.version span').show()
}
$.ajax({
url : lychee.updatePath,
success : function(data) { if (data.lychee.version>parseInt(lychee.versionCode)) $('.version span').show() },
success : success
})
}
@ -256,14 +260,14 @@ lychee.setMode = function(mode) {
.off('drop')
Mousetrap
.unbind('u')
.unbind('s')
.unbind('f')
.unbind('r')
.unbind('d')
.unbind('t')
.unbind(['command+backspace', 'ctrl+backspace'])
.unbind(['command+a', 'ctrl+a'])
.unbind([ 'u' ])
.unbind([ 's' ])
.unbind([ 'f' ])
.unbind([ 'r' ])
.unbind([ 'd' ])
.unbind([ 't' ])
.unbind([ 'command+backspace', 'ctrl+backspace' ])
.unbind([ 'command+a', 'ctrl+a' ])
if (mode==='public') {
@ -271,7 +275,8 @@ lychee.setMode = function(mode) {
} else if (mode==='view') {
Mousetrap.unbind(['esc', 'command+up'])
Mousetrap.unbind([ 'esc', 'command+up' ])
$('#button_back, a#next, a#previous').remove()
$('.no_content').remove()
@ -285,8 +290,8 @@ lychee.setMode = function(mode) {
lychee.animate = function(obj, animation) {
let animations = [
['fadeIn', 'fadeOut'],
['contentZoomIn', 'contentZoomOut']
[ 'fadeIn', 'fadeOut' ],
[ 'contentZoomIn', 'contentZoomOut' ]
]
if (!obj.jQuery) obj = $(obj)
@ -306,8 +311,8 @@ lychee.animate = function(obj, animation) {
lychee.retinize = function(path = '') {
let extention = path.split('.').pop(),
isPhoto = extention!=='svg'
let extention = path.split('.').pop()
let isPhoto = extention!=='svg'
if (isPhoto===true) {
@ -329,8 +334,8 @@ lychee.loadDropbox = function(callback) {
loadingBar.show()
let g = document.createElement('script'),
s = document.getElementsByTagName('script')[0]
let g = document.createElement('script')
let s = document.getElementsByTagName('script')[0]
g.src = 'https://www.dropbox.com/static/api/1/dropins.js'
g.id = 'dropboxjs'
@ -360,8 +365,8 @@ lychee.loadDropbox = function(callback) {
lychee.getEventName = function() {
let touchendSupport = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera) && ('ontouchend' in document.documentElement),
eventName = (touchendSupport===true ? 'touchend' : 'click')
let touchendSupport = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera) && ('ontouchend' in document.documentElement)
let eventName = (touchendSupport===true ? 'touchend' : 'click')
return eventName
@ -388,8 +393,8 @@ lychee.html = function(literalSections, ...substs) {
// Use raw literal sections: we dont want
// backslashes (\n etc.) to be interpreted
let raw = literalSections.raw,
result = ''
let raw = literalSections.raw
let result = ''
substs.forEach((subst, i) => {
@ -412,7 +417,7 @@ lychee.html = function(literalSections, ...substs) {
// Take care of last literal section
// (Never fails, because an empty template string
// produces one literal section, an empty string)
result += raw[raw.length-1]
result += raw[raw.length - 1]
return result

View File

@ -89,8 +89,8 @@ multiselect.resize = function(e) {
multiselect.position.bottom === null ||
multiselect.position.left === null) return false
let newSize = {},
documentSize = {}
let newSize = {}
let documentSize = {}
// Get the position of the mouse
let mousePos = {
@ -114,7 +114,7 @@ multiselect.resize = function(e) {
// Do not leave the screen
newSize.height = mousePos.y - multiselect.position.top
if ((multiselect.position.top+newSize.height)>=documentSize.height) {
if ((multiselect.position.top + newSize.height)>=documentSize.height) {
newSize.height -= (multiselect.position.top + newSize.height) - documentSize.height + 2
}
@ -136,7 +136,7 @@ multiselect.resize = function(e) {
// Do not leave the screen
newSize.width = mousePos.x - multiselect.position.left
if ((multiselect.position.left+newSize.width)>=documentSize.width) {
if ((multiselect.position.left + newSize.width)>=documentSize.width) {
newSize.width -= (multiselect.position.left + newSize.width) - documentSize.width + 2
}
@ -167,8 +167,8 @@ multiselect.getSize = function() {
if (!visible.multiselect()) return false
let $elem = $('#multiselect'),
offset = $elem.offset()
let $elem = $('#multiselect')
let offset = $elem.offset()
return {
top : offset.top,
@ -181,9 +181,9 @@ multiselect.getSize = function() {
multiselect.getSelection = function(e) {
let tolerance = 150,
ids = [],
size = multiselect.getSize()
let tolerance = 150
let ids = []
let size = multiselect.getSize()
if (visible.contextMenu()) return false
if (!visible.multiselect()) return false
@ -192,19 +192,19 @@ multiselect.getSelection = function(e) {
let offset = $(this).offset()
if (offset.top>=(size.top-tolerance) &&
offset.left>=(size.left-tolerance) &&
(offset.top+206)<=(size.top+size.height+tolerance) &&
(offset.left+206)<=(size.left+size.width+tolerance)) {
if (offset.top>=(size.top - tolerance) &&
offset.left>=(size.left - tolerance) &&
(offset.top + 206)<=(size.top + size.height + tolerance) &&
(offset.left + 206)<=(size.left + size.width + tolerance)) {
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)
$(this).addClass('active')
ids.push(id)
$(this).addClass('active')
}
}
}

View File

@ -71,8 +71,8 @@ photo.preloadNext = function(photoID) {
album.json.content[photoID] &&
album.json.content[photoID].nextPhoto!='') {
let nextPhoto = album.json.content[photoID].nextPhoto,
url = album.json.content[nextPhoto].url
let nextPhoto = album.json.content[photoID].nextPhoto
let url = album.json.content[nextPhoto].url
$('head [data-prefetch]').remove()
$('head').append(`<link data-prefetch rel="prefetch" href="${ url }">`)
@ -152,7 +152,7 @@ photo.next = function(animate) {
photo.duplicate = function(photoIDs) {
if (!photoIDs) return false
if (photoIDs instanceof Array===false) photoIDs = [photoIDs]
if (photoIDs instanceof Array===false) photoIDs = [ photoIDs ]
albums.refresh()
@ -171,13 +171,13 @@ photo.duplicate = function(photoIDs) {
photo.delete = function(photoIDs) {
let action = {},
cancel = {},
msg = '',
photoTitle = ''
let action = {}
let cancel = {}
let msg = ''
let photoTitle = ''
if (!photoIDs) return false
if (photoIDs instanceof Array===false) photoIDs = [photoIDs]
if (photoIDs instanceof Array===false) photoIDs = [ photoIDs ]
if (photoIDs.length===1) {
@ -192,8 +192,8 @@ photo.delete = function(photoIDs) {
action.fn = function() {
let nextPhoto,
previousPhoto
let nextPhoto
let previousPhoto
basicModal.close()
@ -269,11 +269,11 @@ photo.delete = function(photoIDs) {
photo.setTitle = function(photoIDs) {
let oldTitle = '',
msg = ''
let oldTitle = ''
let msg = ''
if (!photoIDs) return false
if (photoIDs instanceof Array===false) photoIDs = [photoIDs]
if (photoIDs instanceof Array===false) photoIDs = [ photoIDs ]
if (photoIDs.length===1) {
@ -300,8 +300,8 @@ photo.setTitle = function(photoIDs) {
})
let params = {
photoIDs: photoIDs.join(),
title: newTitle
photoIDs : photoIDs.join(),
title : newTitle
}
api.post('Photo::setTitle', params, function(data) {
@ -335,11 +335,11 @@ photo.setTitle = function(photoIDs) {
photo.setAlbum = function(photoIDs, albumID) {
let nextPhoto,
previousPhoto
let nextPhoto
let previousPhoto
if (!photoIDs) return false
if (photoIDs instanceof Array===false) photoIDs = [photoIDs]
if (photoIDs instanceof Array===false) photoIDs = [ photoIDs ]
if (visible.photo) lychee.goto(album.getID())
@ -416,7 +416,7 @@ photo.setPublic = function(photoID, e) {
}
basicModal.show({
body: "<p>This photo is located in a public album. To make this photo private or public, edit the visibility of the associated album.</p>",
body: '<p>This photo is located in a public album. To make this photo private or public, edit the visibility of the associated album.</p>',
buttons: {
action: {
title: 'Show Album',
@ -500,11 +500,11 @@ photo.setDescription = function(photoID) {
photo.editTags = function(photoIDs) {
let oldTags = '',
msg = ''
let oldTags = ''
let msg = ''
if (!photoIDs) return false
if (photoIDs instanceof Array===false) photoIDs = [photoIDs]
if (photoIDs instanceof Array===false) photoIDs = [ photoIDs ]
// Get tags
if (visible.photo()) oldTags = photo.json.tags
@ -591,14 +591,14 @@ photo.deleteTag = function(photoID, index) {
// Save
photo.json.tags = tags.toString()
photo.setTags([photoID], photo.json.tags)
photo.setTags([ photoID ], photo.json.tags)
}
photo.share = function(photoID, service) {
let link = '',
url = photo.getViewLink(photoID)
let link = ''
let url = photo.getViewLink(photoID)
switch (service) {
case 'twitter':
@ -627,8 +627,8 @@ photo.share = function(photoID, service) {
photo.getArchive = function(photoID) {
let link,
url = `${ api.path }?function=Photo::getArchive&photoID=${ photoID }`
let link
let url = `${ api.path }?function=Photo::getArchive&photoID=${ photoID }`
if (location.href.indexOf('index.html')>0) link = location.href.replace(location.hash, '').replace('index.html', url)
else link = location.href.replace(location.hash, '') + url

View File

@ -19,9 +19,9 @@ search.find = function(term) {
api.post('search', { term }, function(data) {
let html = '',
albumsData = '',
photosData = ''
let html = ''
let albumsData = ''
let photosData = ''
// Build albums
if (data && data.albums) {

View File

@ -9,11 +9,11 @@ settings.createConfig = function() {
const action = function(data) {
let dbName = data.dbName || '',
dbUser = data.dbUser || '',
dbPassword = data.dbPassword || '',
dbHost = data.dbHost || '',
dbTablePrefix = data.dbTablePrefix || ''
let dbName = data.dbName || ''
let dbUser = data.dbUser || ''
let dbPassword = data.dbPassword || ''
let dbHost = data.dbHost || ''
let dbTablePrefix = data.dbTablePrefix || ''
if (dbUser.length<1) {
basicModal.error('dbUser')
@ -140,8 +140,8 @@ settings.createLogin = function() {
const action = function(data) {
let username = data.username,
password = data.password
let username = data.username
let password = data.password
if (username.length<1) {
basicModal.error('username')
@ -204,9 +204,9 @@ settings.setLogin = function() {
const action = function(data) {
let oldPassword = data.oldPassword || '',
username = data.username || '',
password = data.password || ''
let oldPassword = data.oldPassword || ''
let username = data.username || ''
let password = data.password || ''
if (oldPassword.length<1) {
basicModal.error('oldPassword')
@ -269,8 +269,8 @@ settings.setLogin = function() {
settings.setSorting = function() {
let sortingPhotos = [],
sortingAlbums = []
let sortingPhotos = []
let sortingAlbums = []
const action = function() {

View File

@ -30,14 +30,14 @@ sidebar.bind = function() {
// event handlers should be removed before binding a new one.
// Event Name
let eventName = lychee.getEventName();
let eventName = lychee.getEventName()
sidebar
.dom('#edit_title')
.off(eventName)
.on(eventName, function() {
if (visible.photo()) photo.setTitle([photo.getID()])
else if (visible.album()) album.setTitle([album.getID()])
if (visible.photo()) photo.setTitle([ photo.getID() ])
else if (visible.album()) album.setTitle([ album.getID() ])
})
sidebar
@ -52,7 +52,7 @@ sidebar.bind = function() {
.dom('#edit_tags')
.off(eventName)
.on(eventName, function() {
photo.editTags([photo.getID()])
photo.editTags([ photo.getID() ])
})
sidebar
@ -114,10 +114,10 @@ sidebar.createStructure.photo = function(data) {
if (data==null || data==='') return false
let editable = false,
exifHash = data.takestamp + data.make + data.model + data.shutter + data.aperture + data.focal + data.iso,
structure = {},
_public = ''
let editable = false
let exifHash = data.takestamp + data.make + data.model + data.shutter + data.aperture + data.focal + data.iso
let structure = {}
let _public = ''
// Enable editable when user logged in
if (lychee.publicMode===false) editable = true
@ -220,12 +220,12 @@ sidebar.createStructure.album = function(data) {
if (data==null || data==='') return false
let editable = false,
structure = {},
_public = '',
visible = '',
downloadable = '',
password = ''
let editable = false
let structure = {}
let _public = ''
let visible = ''
let downloadable = ''
let password = ''
// Enable editable when user logged in
if (lychee.publicMode===false) editable = true
@ -367,8 +367,8 @@ sidebar.render = function(structure) {
let renderTags = function(section) {
let _html = '',
editable = ''
let _html = ''
let editable = ''
// Add edit-icon to the value when editable
if (section.editable===true) editable = build.editIcon('edit_tags')

View File

@ -40,16 +40,16 @@ upload.start = {
local: function(files) {
let albumID = album.getID(),
error = false,
warning = false
let albumID = album.getID()
let error = false
let warning = false
const process = function(files, file) {
let formData = new FormData(),
xhr = new XMLHttpRequest(),
pre_progress = 0,
progress = 0
let formData = new FormData()
let xhr = new XMLHttpRequest()
let pre_progress = 0
let progress = 0
const finish = function() {
@ -122,8 +122,8 @@ upload.start = {
xhr.onload = function() {
let wait = false,
errorText = ''
let wait = false
let errorText = ''
file.ready = true
@ -131,7 +131,7 @@ upload.start = {
if (xhr.status===200 && xhr.responseText==='1') {
// Success
$('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status')
$('.basicModal .rows .row:nth-child(' + (file.num + 1) + ') .status')
.html('Finished')
.addClass('success')
@ -143,7 +143,7 @@ upload.start = {
error = true
// Error Status
$('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status')
$('.basicModal .rows .row:nth-child(' + (file.num + 1) + ') .status')
.html('Failed')
.addClass('error')
@ -153,7 +153,7 @@ upload.start = {
warning = true
// Warning Status
$('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status')
$('.basicModal .rows .row:nth-child(' + (file.num + 1) + ') .status')
.html('Skipped')
.addClass('warning')
@ -163,13 +163,13 @@ upload.start = {
error = true
// Error Status
$('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status')
$('.basicModal .rows .row:nth-child(' + (file.num + 1) + ') .status')
.html('Failed')
.addClass('error')
}
$('.basicModal .rows .row:nth-child(' + (file.num+1) + ') p.notice')
$('.basicModal .rows .row:nth-child(' + (file.num + 1) + ') p.notice')
.html(errorText)
.show()
@ -210,11 +210,11 @@ upload.start = {
// Scroll to the uploading file
let scrollPos = 0
if ((file.num+1)>4) scrollPos = (file.num + 1 - 4) * 40
if ((file.num + 1)>4) scrollPos = (file.num + 1 - 4) * 40
$('.basicModal .rows').scrollTop(scrollPos)
// Set status to processing
$('.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
if (file.next!=null) process(files, file.next)
@ -236,7 +236,7 @@ upload.start = {
files[i].ready = false
files[i].supported = true
if (i < files.length-1) files[i].next = files[i+1]
if (i < files.length-1) files[i].next = files[i + 1]
else files[i].next = null
// Check if file is supported
@ -480,7 +480,7 @@ upload.start = {
}
// Remove last comma
links = links.substr(0, links.length-1)
links = links.substr(0, links.length - 1)
upload.show('Importing from Dropbox', files, function() {

View File

@ -26,8 +26,8 @@ view.albums = {
init: function() {
let smartData = '',
albumsData = ''
let smartData = ''
let albumsData = ''
// Smart Albums
if (lychee.publicMode===false) {
@ -271,8 +271,8 @@ view.album = {
if ((visible.album() || !album.json.init) && !visible.photo()) {
let structure = sidebar.createStructure.album(album.json),
html = sidebar.render(structure)
let structure = sidebar.createStructure.album(album.json)
let html = sidebar.render(structure)
sidebar.dom('.sidebar__wrapper').html(html)
sidebar.bind()
@ -408,27 +408,33 @@ view.photo = {
lychee.imageview.html(build.imageview(photo.json, visible.header()))
let $nextArrow = lychee.imageview.find('a#next'),
$previousArrow = lychee.imageview.find('a#previous'),
photoID = photo.getID(),
hasNext = album.json && album.json.content && album.json.content[photoID] && album.json.content[photoID].nextPhoto!=='',
hasPrevious = album.json && album.json.content && album.json.content[photoID] && album.json.content[photoID].previousPhoto!==''
let $nextArrow = lychee.imageview.find('a#next')
let $previousArrow = lychee.imageview.find('a#previous')
let photoID = photo.getID()
let hasNext = album.json && album.json.content && album.json.content[photoID] && album.json.content[photoID].nextPhoto!==''
let hasPrevious = album.json && album.json.content && album.json.content[photoID] && album.json.content[photoID].previousPhoto!==''
if (hasNext===false || lychee.viewMode===true) { $nextArrow.hide() }
else {
if (hasNext===false || lychee.viewMode===true) {
let nextPhotoID = album.json.content[photoID].nextPhoto,
nextPhoto = album.json.content[nextPhotoID]
$nextArrow.hide()
} else {
let nextPhotoID = album.json.content[photoID].nextPhoto
let nextPhoto = album.json.content[nextPhotoID]
$nextArrow.css('background-image', lychee.html`linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("$${ nextPhoto.thumbUrl }")`)
}
if (hasPrevious===false || lychee.viewMode===true) { $previousArrow.hide() }
else {
if (hasPrevious===false || lychee.viewMode===true) {
let previousPhotoID = album.json.content[photoID].previousPhoto,
previousPhoto = album.json.content[previousPhotoID]
$previousArrow.hide()
} else {
let previousPhotoID = album.json.content[photoID].previousPhoto
let previousPhoto = album.json.content[previousPhotoID]
$previousArrow.css('background-image', lychee.html`linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("$${ previousPhoto.thumbUrl }")`)
@ -438,8 +444,8 @@ view.photo = {
sidebar: function() {
let structure = sidebar.createStructure.photo(photo.json),
html = sidebar.render(structure)
let structure = sidebar.createStructure.photo(photo.json)
let html = sidebar.render(structure)
sidebar.dom('.sidebar__wrapper').html(html)
sidebar.bind()

View File

@ -11,8 +11,8 @@ lychee.content = $('.content')
lychee.getEventName = function() {
let touchendSupport = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera) && ('ontouchend' in document.documentElement),
eventName = (touchendSupport===true ? 'touchend' : 'click')
let touchendSupport = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera) && ('ontouchend' in document.documentElement)
let eventName = (touchendSupport===true ? 'touchend' : 'click')
return eventName
@ -39,8 +39,8 @@ lychee.html = function(literalSections, ...substs) {
// Use raw literal sections: we dont want
// backslashes (\n etc.) to be interpreted
let raw = literalSections.raw,
result = ''
let raw = literalSections.raw
let result = ''
substs.forEach((subst, i) => {
@ -63,7 +63,7 @@ lychee.html = function(literalSections, ...substs) {
// Take care of last literal section
// (Never fails, because an empty template string
// produces one literal section, an empty string)
result += raw[raw.length-1]
result += raw[raw.length - 1]
return result
@ -127,8 +127,8 @@ const loadPhotoInfo = function(photoID) {
imageview.addClass('fadeIn').show()
// Render Sidebar
let structure = sidebar.createStructure.photo(data),
html = sidebar.render(structure)
let structure = sidebar.createStructure.photo(data)
let html = sidebar.render(structure)
sidebar.dom('.sidebar__wrapper').html(html)
sidebar.bind()