From 710aa2bf5281fd22e2d915f8cb30ab9965cae06c Mon Sep 17 00:00:00 2001
From: Tobias Reich
Lychee ${ lychee.version } – Update available!
- ` + let msg = ` ++ + +
+Lychee ${ lychee.version } – Update available!
+ ` basicModal.show({ body: msg, @@ -145,95 +139,94 @@ lychee.loginDialog = function() { fn: basicModal.close } } - }); + }) if (localStorage) { - localUsername = localStorage.getItem('lychee_username'); - if (localUsername!==null) { - if (localUsername.length>0) $('.basicModal input[name="username"]').val(localUsername); - $('.basicModal input[name="password"]').focus(); + let localUsername = localStorage.getItem('lychee_username') + if (localUsername!==null && localUsername.length>0) { + $('.basicModal input[name="username"]').val(localUsername) + $('.basicModal input[name="password"]').focus() } } - if (lychee.checkForUpdates==='1') lychee.getUpdate(); + if (lychee.checkForUpdates==='1') lychee.getUpdate() } lychee.logout = function() { api.post('Session::logout', {}, function() { - window.location.reload(); - }); + window.location.reload() + }) } lychee.goto = function(url) { - if (url===undefined) url = '#'; - else url = '#' + url; + if (url===undefined) url = '#' + else url = '#' + url - history.pushState(null, null, url); - lychee.load(); + history.pushState(null, null, url) + lychee.load() } lychee.load = function() { - var albumID = '', - photoID = '', - hash = document.location.hash.replace('#', '').split('/'); + let albumID = '', + photoID = '', + hash = document.location.hash.replace('#', '').split('/') - $('.no_content').remove(); - contextMenu.close(); - multiselect.close(); + $('.no_content').remove() + contextMenu.close() + multiselect.close() - if (hash[0]!==undefined) albumID = hash[0]; - if (hash[1]!==undefined) photoID = hash[1]; + if (hash[0]!==undefined) albumID = hash[0] + if (hash[1]!==undefined) photoID = hash[1] - if (albumID&&photoID) { + if (albumID && photoID) { // Trash data - photo.json = null; + photo.json = null // Show Photo - if (lychee.content.html()===''|| - ($('#search').length&&$('#search').val().length!==0)) { - lychee.content.hide(); - album.load(albumID, true); + if (lychee.content.html()==='' || ($('#search').length && $('#search').val().length!==0)) { + lychee.content.hide() + album.load(albumID, true) } - photo.load(photoID, albumID); + photo.load(photoID, albumID) } else if (albumID) { // Trash data - photo.json = null; + photo.json = null // Hide sidebar - if (visible.sidebar()) sidebar.toggle(); + if (visible.sidebar()) sidebar.toggle() // Show Album - if (visible.photo()) view.photo.hide(); - if (album.json&&albumID==album.json.id) view.album.title(); - else album.load(albumID); + if (visible.photo()) view.photo.hide() + if (album.json && albumID==album.json.id) view.album.title() + else album.load(albumID) } else { // Trash albums.json when filled with search results if (search.hash!==null) { - albums.json = null; - search.hash = null; + albums.json = null + search.hash = null } // Trash data - album.json = null; - photo.json = null; + album.json = null + photo.json = null // Hide sidebar - if (visible.sidebar()) sidebar.toggle(); + if (visible.sidebar()) sidebar.toggle() // Show Albums - if (visible.photo()) view.photo.hide(); - albums.load(); + if (visible.photo()) view.photo.hide() + albums.load() } @@ -242,32 +235,32 @@ lychee.load = function() { lychee.getUpdate = function() { $.ajax({ - url: lychee.update_path, - success: function(data) { if (parseInt(data)>parseInt(lychee.version_code)) $('.version span').show(); } - }); + url : lychee.update_path, + success : function(data) { if (parseInt(data)>parseInt(lychee.version_code)) $('.version span').show() } + }) } lychee.setTitle = function(title, editable) { - document.title = lychee.title + ' - ' + title; + document.title = lychee.title + ' - ' + title - header.setEditable(editable); - header.setTitle(title); + header.setEditable(editable) + header.setTitle(title) } lychee.setMode = function(mode) { - $('#button_settings, #button_settings, #button_search, #search, #button_trash_album, #button_share_album, .button_add, .button_divider').remove(); - $('#button_trash, #button_move, #button_share, #button_star').remove(); + $('#button_settings, #button_settings, #button_search, #search, #button_trash_album, #button_share_album, .button_add, .button_divider').remove() + $('#button_trash, #button_move, #button_share, #button_star').remove() $(document) - .off('click', '#title.editable') - .off('touchend', '#title.editable') - .off('contextmenu', '.photo') - .off('contextmenu', '.album') - .off('drop'); + .off('click', '#title.editable') + .off('touchend', '#title.editable') + .off('contextmenu', '.photo') + .off('contextmenu', '.album') + .off('drop') Mousetrap .unbind('u') @@ -277,21 +270,21 @@ lychee.setMode = function(mode) { .unbind('d') .unbind('t') .unbind(['command+backspace', 'ctrl+backspace']) - .unbind(['command+a', 'ctrl+a']); + .unbind(['command+a', 'ctrl+a']) if (mode==='public') { - header.dom('#button_signin, #hostedwith').show(); - lychee.publicMode = true; + header.dom('#button_signin, #hostedwith').show() + lychee.publicMode = true } else if (mode==='view') { - Mousetrap.unbind(['esc', 'command+up']); - $('#button_back, a#next, a#previous').remove(); - $('.no_content').remove(); + Mousetrap.unbind(['esc', 'command+up']) + $('#button_back, a#next, a#previous').remove() + $('.no_content').remove() - lychee.publicMode = true; - lychee.viewMode = true; + lychee.publicMode = true + lychee.viewMode = true } @@ -299,86 +292,85 @@ lychee.setMode = function(mode) { lychee.animate = function(obj, animation) { - var animations = [ + let animations = [ ['fadeIn', 'fadeOut'], ['contentZoomIn', 'contentZoomOut'] - ]; + ] - if (!obj.jQuery) obj = $(obj); + if (!obj.jQuery) obj = $(obj) - for (var i = 0; i < animations.length; i++) { - for (var x = 0; x < animations[i].length; x++) { + for (let i = 0; i < animations.length; i++) { + for (let x = 0; x < animations[i].length; x++) { if (animations[i][x]==animation) { - obj.removeClass(animations[i][0] + ' ' + animations[i][1]).addClass(animation); - return true; + obj.removeClass(animations[i][0] + ' ' + animations[i][1]).addClass(animation) + return true } } } - return false; + return false } lychee.escapeHTML = function(s) { return s.replace(/&/g, '&') - .replace(/"/g, '"') - .replace(//g, '>'); + .replace(/"/g, '"') + .replace(//g, '>') } lychee.retinize = function(path = '') { - var pixelRatio = window.devicePixelRatio, - extention = path.split('.').pop(), - hasRetina = extention!=='svg'; + let pixelRatio = window.devicePixelRatio, + extention = path.split('.').pop(), + hasRetina = extention!=='svg' - if ((pixelRatio!==undefined&&pixelRatio>1)&& - (hasRetina===true)) { + if ((pixelRatio!==undefined && pixelRatio>1) && hasRetina===true) { - path = path.replace(/\.[^/.]+$/, ''); - path = path + '@2x' + '.' + extention; + path = path.replace(/\.[^/.]+$/, '') + path = path + '@2x' + '.' + extention } return { path, hasRetina - }; + } } lychee.loadDropbox = function(callback) { - if (!lychee.dropbox&&lychee.dropboxKey) { + if (!lychee.dropbox && lychee.dropboxKey) { - loadingBar.show(); + loadingBar.show() - var g = document.createElement('script'), - s = document.getElementsByTagName('script')[0]; + let g = document.createElement('script'), + s = document.getElementsByTagName('script')[0] - g.src = 'https://www.dropbox.com/static/api/1/dropins.js'; - g.id = 'dropboxjs'; - g.type = 'text/javascript'; - g.async = 'true'; - g.setAttribute('data-app-key', lychee.dropboxKey); + g.src = 'https://www.dropbox.com/static/api/1/dropins.js' + g.id = 'dropboxjs' + g.type = 'text/javascript' + g.async = 'true' + g.setAttribute('data-app-key', lychee.dropboxKey) g.onload = g.onreadystatechange = function() { - var rs = this.readyState; - if (rs&&rs!=='complete'&&rs!=='loaded') return; - lychee.dropbox = true; - loadingBar.hide(); - callback(); - }; - s.parentNode.insertBefore(g, s); + let rs = this.readyState + if (rs && rs!=='complete' && rs!=='loaded') return + lychee.dropbox = true + loadingBar.hide() + callback() + } + s.parentNode.insertBefore(g, s) } else if (lychee.dropbox&&lychee.dropboxKey) { - callback(); + callback() } else { - settings.setDropboxKey(callback); + settings.setDropboxKey(callback) } @@ -386,32 +378,32 @@ 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), + eventName = (touchendSupport===true ? 'touchend' : 'click') - return eventName; + return eventName } lychee.removeHTML = function(html = '') { - if (html==='') return html; + if (html==='') return html - var tmp = document.createElement('DIV'); - tmp.innerHTML = html; + let tmp = document.createElement('DIV') + tmp.innerHTML = html - return tmp.textContent || tmp.innerText; + return (tmp.textContent || tmp.innerText) } lychee.error = function(errorThrown, params, data) { console.error({ - description: errorThrown, - params: params, - response: data - }); + description : errorThrown, + params : params, + response : data + }) - loadingBar.show('error', errorThrown); + loadingBar.show('error', errorThrown) } \ No newline at end of file