},searchString:function(e){for(var t=0;t<e.length;t++){var n=e[t].string,o=e[t].prop;if(this.versionSearchString=e[t].versionSearch||e[t].identity,n){if(-1!=n.indexOf(e[t].subString))return e[t].identity}else if(o)return e[t].identity}},searchVersion:function(e){var t=e.indexOf(this.versionSearchString);if(-1!=t)return parseFloat(e.substring(t+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init(),function(e){e.fn.retina=function(t){var n={"retina-background":!1,"retina-suffix":"@2x"};t&&e.extend(n,t);var o=function(e,t){var n=new Image;n.onload=function(){t(n)},n.src=e};window.devicePixelRatio>1&&this.each(function(){var t=e(this);if("img"==this.tagName.toLowerCase()&&t.attr("src")){var i=t.attr("src").replace(/\.(?!.*\.)/,n["retina-suffix"]+".");o(i,function(n){t.attr("src",n.src);var o=e("<div>").append(t.clone()).remove().html();/(width|height)=["']\d+["']/.test(o)||t.attr("width",n.width/2)})}if(n["retina-background"]){var a=t.css("background-image");if(/^url\(.*\)$/.test(a)){var i=a.substring(4,a.length-1).replace(/\.(?!.*\.)/,n["retina-suffix"]+".");o(i,function(e){t.css("background-image","url("+e.src+")"),"auto auto"==t.css("background-size")&&t.css("background-size",e.width/2+"px auto")})}}})}}(jQuery),function(e){var t=function(t){var n=this;this.el=e(t),this.pos={start:{x:0,y:0},end:{x:0,y:0}},this.startTime,t.on("touchstart",function(e){n.touchStart(e)}),t.on("touchmove",function(e){n.touchMove(e)}),t.on("touchend",function(){n.swipeEnd()}),t.on("mousedown",function(e){n.mouseDown(e)})};t.prototype={touchStart:function(e){var t=e.originalEvent.touches[0];this.swipeStart(e,t.pageX,t.pageY)},touchMove:function(e){var t=e.originalEvent.touches[0];this.swipeMove(e,t.pageX,t.pageY)},mouseDown:function(e){var t=this;this.swipeStart(e,e.pageX,e.pageY),this.el.on("mousemove",function(e){t.mouseMove(e)}),this.el.on("mouseup",function(){t.mouseUp()})},mouseMove:function(e){this.swipeMove(e,e.pageX,e.pageY)},mouseUp:function(e){this.swipeEnd(e),this.el.off("mousemove"),this.el.off("mouseup")},swipeStart:function(e,t,n){this.pos.start.x=t,this.pos.start.y=n,this.pos.end.x=t,this.pos.end.y=n,this.startTime=(new Date).getTime(),this.trigger("swipeStart",e)},swipeMove:function(e,t,n){this.pos.end.x=t,this.pos.end.y=n,this.trigger("swipeMove",e)},swipeEnd:function(e){this.trigger("swipeEnd",e)},trigger:function(t,n){var o=this,i=e.Event(t),a=o.pos.start.x-o.pos.end.x,r=o.pos.end.y-o.pos.start.y,s=Math.atan2(r,a),l="up",u=Math.round(Math.sqrt(Math.pow(a,2)+Math.pow(r,2))),c=Math.round(180*s/Math.PI),d=Math.round(u/((new Date).getTime()-o.startTime)*1e3);0>c&&(c=360-Math.abs(c)),45>=c&&c>=0||360>=c&&c>=315?l="left":c>=135&&225>=c?l="right":c>45&&135>c&&(l="down"),i.originalEvent=n,i.swipe={x:a,y:r,direction:l,distance:u,angle:c,speed:d},e(o.el).trigger(i)}},e.fn.swipe=function(){new t(this);return this}}(jQuery),album={json:null,getID:function(){var e;return e=photo.json?photo.json.album:album.json?album.json.id:$(".album:hover, .album.active").attr("data-id"),e||(e=$(".album:hover, .album.active").attr("data-id")),e||(e=$(".photo:hover, .photo.active").attr("data-album-id")),e?e:!1},load:function(e,t){var n,o,i,a;password.get(e,function(){t||(loadingBar.show(),lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)","contentZoomOut"),lychee.animate(".divider","fadeOut")),n=(new Date).getTime(),o="getAlbum&albumID="+e+"&password="+password.value,lychee.api(o,function(o){return"Warning: Album private!"===o?(void 0!=document.location.hash.replace("#","").split("/")[1]?lychee.setMode("view"):(lychee.content.show(),lychee.goto("")),!1):"Warning: Wrong password!"===o?(album.load(e,t),!1):(album.json=o,i=(new Date).getTime()-n,a=i>300?0:t?0:300-i,visible.albums()||visible.photo()||visible.album()||(a=0),void setTimeout(function(){view.album.init(),t||(lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)","contentZoomIn"),view.header.mode("album"))},a))})})},parse:function(){album.json.title||(album.json.title="Untitled")},add:function(){var e,t,n,o=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};n=[["Create Album",function(){e=$(".message input.text").val(),0===e.length&&(e="Untitled"),modal.close(),t="addAlbum&title="+escape(encodeURI(e)),lychee.api(t,function(e){e===!0&&(e=1),e!==!1&&o(e)?lychee.goto(e):lychee.error(null,t,e)})}],["Cancel",function(){}]],modal.show("New Album","Enter a title for this album: <input class='text' type='text' maxlength='30' placeholder='Title' value='Untitled'>",n)},"delete":function(e){var t,n,o;return e?(e instanceof Array==!1&&(e=[e]),n=[["",function(){t="deleteAlbum&albumIDs="+e,lychee.api(t,function(n){visible.albums()?e.forEach(function(e){albums.json.num--,view.albums.content.delete(e)}):lychee.goto(""),n!==!0&&lychee.error(null,t,n)})}],["",function(){}]],void("0"===e.toString()?(n[0][0]="Clear Unsorted",n[1][0]="Keep Unsorted",modal.show("Clear Unsorted","Are you sure you want to delete all photos from 'Unsorted'?<br>This action can't be undone!",n)):1===e.length?(n[0][0]="Delete Album and Photos",n[1][0]="Keep Album",album.json?o=album.json.title:albums.json&&(o=albums.json.content[e].title),modal.show("Delete Album","Are you sure you want to delete the album '"+o+"' and all of the photos it contains? This action can't be undone!",n)):(n[0][0]="Delete Albums and Photos",n[1][0]="Keep Albums",modal.show("Delete Albums","Are you sure you want to delete all "+e.length+" selected albums and all of the photos they contain? This action can't be undone!",n)))):!1},setTitle:function(e){var t,n,o,i="";return e?(e instanceof Array==!1&&(e=[e]),1===e.length&&(album.json?i=album.json.title:albums.json&&(i=albums.json.content[e].title),i||(i=""),i=i.replace("'","'")),o=[["Set Title",function(){t=$(".message input.text").val(),t=lychee.removeHTML(t),t=""===t?"Untitled":t,visible.album()?(album.json.title=t,view.album.title()):visible.albums()&&e.forEach(function(e){albums.json.content[e].title=t,view.albums.content.title(e)}),n="setAlbumTitle&albumIDs="+e+"&title="+escape(encodeURI(t)),lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})}],["Cancel",function(){}]],void(1===e.length?modal.show("Set Title","Enter a new title for this album: <input class='text' type='text' maxlength='30' placeholder='Title' value='"+i+"'>",o):modal.show("Set Titles","Enter a title for all "+e.length+" selected album: <input class='text' type='text' maxlength='30' placeholder='Title' value='"+i+"'>",o))):!1},setDescription:function(e){var t,n,o,i=album.json.description.replace("'","'");o=[["Set Description",function(){t=$(".message input.text").val(),t=lychee.removeHTML(t),visible.album()&&(album.json.description=t,view.album.description()),n="setAlbumDescription&albumID="+e+"&description="+escape(encodeURI(t)),lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})}],["Cancel",function(){}]],modal.show("Set Description","Please enter a description for this album: <input class='text' type='text' maxlength='800' placeholder='Description' value='"+i+"'>",o)},setPublic:function(e,t){var n,o="",i=!1;return visible.message()||0!=album.json.public?(visible.message()&&("password"===$(".message .choice input[name='password']:checked").val()?(o=md5($(".message input.text").val()),album.json.password=1):(o="",album.json.password=0),"listed"===$(".message .choice input[name='listed']:checked").val()&&(i=!0)),n="setAlbumPublic&albumID="+e+"&password="+o+"&visible="+i,visible.album()&&(album.json.public=0==album.json.public?1:0,album.json.password=0==album.json.public?0:album.json.password,view.album.public(),view.album.password(),1==album.json.public&&contextMenu.shareAlbum(e,t)),void lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})):(modal.show("Share Album","This album will be shared with one of the following properties:</p><form><div class='choice'><input type='checkbox' name='listed' value='listed' checked><h2>Visible</h2><p>Listed to visitors of your Lychee.</p></div><div class='choice'><input type='checkbox' name='password' value='password'><h2>Password protected</h2><p>Only accessible with a valid password.<input class='text' type='password' placeholder='password' value='' style='display: none;'></p></div></form><p style='display: none;'>",[["Share Album",function(){album.setPublic(album.getID(),t)}],["Cancel",function(){}]],-160),$(".message .choice input[name='password']").on("change",function(){$(this).prop("checked")===!0?$(".message .choice input.text").show():$(".message .choice input.text").hide()}),!0)},share:function(e){var t="",n=location.href;switch(e){case 0:t="https://twitter.com/share?url="+encodeURI(n);break;case 1:t="http://www.facebook.com/sharer.php?u="+encodeURI(n)+"&t="+encodeURI(album.json.title);break;case 2:t="mailto:?subject="+encodeURI(album.json.title)+"&body="+encodeURI(n);break;default:t=""}t.length>5&&(location.href=t)},getArchive:function(e){var t;t=location.href.indexOf("index.html")>0?location.href.replace(location.hash,"").replace("index.html","php/api.php?function=getAlbumArchive&albumID="+e):location.href.replace(location.hash,"")+"php/api.php?function=getAlbumArchive&albumID="+e,lychee.publicMode&&(t+="&password="+password.value),location.href=t}},albums={json:null,load:function(){var e,t,n;lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)","contentZoomOut"),lychee.animate(".divider","fadeOut"),e=(new Date).getTime(),lychee.api("getAlbums",function(o){o.unsortedAlbum={id:0,title:"Unsorted",sysdate:o.unsortedNum+" photos",unsorted:1,thumb0:o.unsortedThumb0,thumb1:o.unsortedThumb1,thumb2:o.unsortedThumb2},o.starredAlbum={id:"f",title:"Starred",sysdate:o.starredNum+" photos",star:1,thumb0:o.starredThumb0,thumb1:o.starredThumb1,thumb2:o.starredThumb2},o.publicAlbum={id:"s",title:"Public",sysdate:o.publicNum+" photos","public":1,thumb0:o.publicThumb0,thumb1:o.publicThumb1,thumb2:o.publicThumb2},o.recentAlbum={id:"r",title:"Recent",sysdate:o.recentNum+" photos",recent:1,thumb0:o.recentThumb0,thumb1:o.recentThumb1,thumb2:o.recentThumb2},albums.json=o,t=(new Date).getTime()-e,n=t>300?0:300-t,visible.albums()||visible.photo()||visible.album()||(n=0),visible.album()&&""===lychee.content.html()&&(n=0),setTimeout(function(){view.header.mode("albums"),view.albums.init(),lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)","contentZoomIn")},n)})},parse:function(e){e.password&&lychee.publicMode?(e.thumb0="assets/img/password.svg",e.thumb1="assets/img/password.svg",e.thumb2="assets/img/password.svg"):(e.thumb0||(e.thumb0="assets/img/no_images.svg"),e.thumb1||(e.thumb1="assets/img/no_images.svg"),e.thumb2||(e.thumb2="assets/img/no_images.svg"))}},build={divider:function(e){return"<div class='divider fadeIn'><h1>"+e+"</h1></div>"},editIcon:function(e){return"<div id='"+e+"' class='edit'><a class='icon-pencil'></a></div>"},multiselect:function(e,t){return"<div id='multiselect' style='top: "+e+"px; left: "+t+"px;'></div>"},album:function(e){if(!e)return"";var t="",n="",o=e.title,i="";return o.length>18&&(o=e.title.substr(0,18)+"...",n=e.title),"svg"===e.thumb0.split(".").pop()&&(i="nonretina"),t+="<div class='album' data-id='"+e.id+"' data-password='"+e.password+"'>",t+="<img src='"+e.thumb2+"' width='200' height='200' alt='thumb' data-type='nonretina'>",t+="<img src='"+e.thumb1+"' width='200' height='200' alt='thumb' data-type='nonretina'>",t+="<img src='"+e.thumb0+"' width='200' height='200' alt='thumb' data-type='"+i+"'>",t+="<div class='overlay'>",t+=e.password&&!lychee.publicMode?"<h1><span class='icon-lock'></span> "+o+"</h1>":"<h1 title='"+n+"'>"+o+"</h1>",t+="<a>"+e.sysdate+"</a>",t+="</div>",lychee.publicMode||(1==e.star&&(t+="<a class='badge red icon-star'></a>"),1==e.public&&(t+="<a class='badge red icon-share'></a>"),1==e.unsorted&&(t+="<a class='badge red icon-reorder'></a>"),1==e.recent&&(t+="<a class='badge red icon-time'></a>")),t+="</div>"},photo:function(e){if(!e)return"";var t="",n="",o=e.title;return o.length>18&&(o=e.title.substr(0,18)+"...",n=e.title),t+="<div class='photo' data-album-id='"+e.album+"' data-id='"+e.id+"'>",t+="<img src='"+e.thumbUrl+"' width='200' height='200' alt='thumb'>",t+="<div class='overlay'>",t+="<h1 title='"+n+"'>"+o+"</h1>",t+=1==e.cameraDate?"<a><span class='icon-camera' title='Photo Date'></span>"+e.sysdate+"</a>":"<a>"+e.sysdate+"</a>",t+="</div>",1==e.star&&(t+="<a class='badge red icon-star'></a>"),lychee.publicMode||1!=e.public||1==album.json.public||(t+="<a class='badge red icon-share'></a>"),t+="</div>"},imageview:function(e,t,n){if(!e)return"";var o="";return o+="<div class='arrow_wrapper previous'><a id='previous' class='icon-caret-left'></a></div>",o+="<div class='arrow_wrapper next'><a id='next' class='icon-caret-right'></a></div>",o+=t?n?"<div id='image' class='small' style='background-image: url("+e.url+"); width: "+e.width+"px; height: "+e.height+"px; margin-top: -"+parseInt(e.height/2-20)+"px; margin-left: -"+e.width/2+"px;'></div>":"<div id='image' class='small' style='background-image: url("+e.url+"); width: "+e.width+"px; height: "+e.height+"px; margin-top: -"+parseInt(e.height/2)+"px; margin-left: -"+e.width/2+"px;'></div>":n?"<div id='image' style='background-image: url("+e.url+")'></div>":"<div id='image' style='background-image: url("+e.url+");' class='full'></div>"},no_content:function(e){var t="";return t+="<div class='no_content fadeIn'>",t+="<a class='icon icon-"+e+"'></a>","search"===e?t+="<p>No results</p>":"picture"===e?t+="<p>No public albums</p>":"cog"===e&&(t+="<p>No Configuration!</p>"),t+="</div>"},modal:function(e,t,n,o,i){var a="",r="";return o&&(r="style='margin-top: "+o+"px;'"),a+="<div class='message_overlay fadeIn'>",a+="<div class='message center'"+r+">",a+="<h1>"+e+"</h1>",i!==!1&&(a+="<a class='close icon-remove-sign'></a>"),a+="<p>"+t+"</p>",$.each(n,function(e){""!==this[0]&&(a+=0===e?"<a class='button active'>"+this[0]+"</a>":"<a class='button'>"+this[0]+"</a>")}),a+="</div>",a+="</div>"},signInModal:function(){var e="";return e+="<div class='message_overlay'>",e+="<div class='message center'>",e+="<h1><a class='icon-lock'></a> Sign In</h1>",e+="<a class='close icon-remove-sign'></a>",e+="<div class='sign_in'>",e+="<input id='username' type='text' name='' value='' placeholder='username'>",e+="<input id='password' type='password' name='' value='' placeholder='password'>",e+="</div>",e+="<div id='version'>Version "+lychee.version+"<span> – <a target='_blank' href='"+lychee.updateURL+"'>Update available!</a><span></div>",e+="<a onclick='lychee.login()' class='button active'>Sign in</a>",e+="</div>",e+="</div>"},uploadModal:function(e,t){var n="";n+="<div class='upload_overlay fadeIn'>",n+="<div class='upload_message center'>",n+="<h1>"+e+"</h1>",n+="<div class='rows'>";for(var o=0;o<t.length;o++)t[o].name.length>40&&(t[o].name=t[o].name.substr(0,17)+"..."+t[o].name.substr(t[o].name.length-20,20)),t[o].supported===!0?(n+="<div class='row'>",n+="<a class='name'>"+lychee.escapeHTML(t[o].name)+"</a>",n+="<a class='status'></a>",n+="</div>"):(n+="<div class='row'>",n+="<a class='name'>"+lychee.escapeHTML(t[o].name)+"</a>",n+="<a class='status error'>Not supported</a>",n+="</div>");return n+="</div>",n+="</div>",n+="</div>"},contextMenu:function(e){var t="";return t+="<div class='contextmenu_bg'></div>",t+="<div class='contextmenu'>",t+="<table>",t+="<tbody>",$.each(e,function(n){t+="separator"===e[n][0]&&-1===e[n][1]?"<tr class='separator'></tr>":-1===e[n][1]?"<tr class='no_hover'><td>"+e[n][0]+"</td></tr>":void 0!=e[n][2]?"<tr><td onclick='"+e[n][2]+"; window.contextMenu.close();'>"+e[n][0]+"</td></tr>":"<tr><td onclick='window.contextMenu.fns["+e[n][1]+"](); window.contextMenu.close();'>"+e[n][0]+"</td></tr>"}),t+="</tbody>",t+="</table>",t+="</div>"},tags:function(e,t){var n="",o=t===!0||lychee.publicMode?"":" "+build.editIcon("edit_tags");return""!==e?(e=e.split(","),e.forEach(function(e,t){n+="<a class='tag'>"+e+"<span class='icon-remove' data-index='"+t+"'></span></a>"}),n+=o):n="<div class='empty'>No Tags"+o+"</div>",n},infoboxPhoto:function(e,t){if(!e)return"";var n,o,i,a,r="";switch(r+="<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>",r+="<div class='wrapper'>",e.public){case"0":n="Private";break;case"1":n="Public";break;case"2":n="Public (Album)";break;default:n="-"}return o=t===!0||lychee.publicMode?"":" "+build.editIcon("edit_title"),i=t===!0||lychee.publicMode?"":" "+build.editIcon("edit_description"),a=[["","Basics"],["Title",e.title+o],["Uploaded",e.sysdate],["Description",e.description+i],["","Image"],["Size",e.size],["Format",e.type],["Resolution",e.width+" x "+e.height],["Tags",build.tags(e.tags,t)]],e.takestamp+e.make+e.model+e.shutter+e.aperture+e.focal+e.iso!="0"&&(a=a.concat([["","Camera"],["Captured",e.takedate],["Make",e.make],["Type/Model",e.model],["Shutter Speed",e.shutter],["Aperture",e.aperture],["Focal Length",e.focal],["ISO",e.iso]])),a=a.concat([["","Share"],["Visibility",n]]),$.each(a,function(e){switch((""===a[e][1]||void 0===a[e][1]||null===a[e][1])&&(a[e][1]="-"),a[e][0]){case"":r+="</table>",r+="<div class='separator'><h1>"+a[e][1]+"</h1></div>",r+="<table>";break;case"Tags":t===!0||lychee.publicMode||(r+="</table>",r+="<div class='separator'><h1>"+a[e][0]+"</h1></div>",r+="<div id='tags'>"+a[e][1]+"</div>");break;default:r+="<tr>",r+="<td>"+a[e][0]+"</td>",r+="<td class='attr_"+a[e][0].toLowerCase()+"'>"+a[e][1]+"</td>",r+="</tr>"}}),r+="</table>",r+="<div class='bumper'></div>",r+="</div>"},infoboxAlbum:function(e,t){if(!e)return"";var n,o,i,a,r,s="";switch(s+="<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>",s+="<div class='wrapper'>",e.public){case"0":n="Private";break;case"1":n="Public";break;default:n="-"}switch(e.password){case!1:o="No";break;case!0:o="Yes";break;default:o="-"}return i=t===!0||lychee.publicMode?"":" "+build.editIcon("edit_title_album"),a=t===!0||lychee.publicMode?"":" "+build.editIcon("edit_description_album"),r=[["","Basics"],["Title",e.title+i],["Description",e.description+a],["","Album"],["Created",e.sysdate],["Images",e.num],["","Share"],["Visibility",n],["Password",o]],$.each(r,function(e){(""===r[e][1]||void 0===r[e][1]||null===r[e][1])&&(r[e][1]="-"),""===r[e][0]?(s+="</table>",s+="<div class='separator'><h1>"+r[e][1]+"</h1></div>",s+="<table id='infos'>"):(s+="<tr>",s+="<td>"+r[e][0]+"</td>",s+="<td class='attr_"+r[e][0].toLowerCase()+"'>"+r[e][1]+"</td>",s+="</tr>")}),s+="</table>",s+="<div class='bumper'></div>",s+="</div>"}},contextMenu={fns:null,show:function(e,t,n,o){contextMenu.close(),$("body").css("overflow","hidden").append(build.contextMenu(e)),t+$(".contextmenu").outerWidth(!0)>$("html").width()&&(o="left"),n+$(".contextmenu").outerHeight(!0)>$("html").height()&&(n-=n+$(".contextmenu").outerHeight(!0)-$("html").height()),t>$(document).width()&&(t=$(document).width()),0>t&&(t=0),n>$(document).height()&&(n=$(document).height()),0>n&&(n=0),"left"===o&&(t-=$(".contextmenu").outerWidth(!0)),(null===t||void 0===t||isNaN(t)||null===n||void 0===n||isNaN(n))&&(t="10px",n="10px"),$(".contextmenu").css({top:n,left:t,opacity:.98})},add:function(e){var t,n=e.pageX,o=e.pageY-$(document).scrollTop();upload.notify(),contextMenu.fns=[function(){$("#upload_files").click()},function(){upload.start.url()},function(){upload.start.dropbox()},function(){upload.start.server()},function(){album.add()}],t=[["<a class='icon-picture'></a> Upload Photo",0],["separator",-1],["<a class='icon-link'></a> Import from Link",1],["<a class='icon-folder-open'></a> Import from Dropbox",2],["<a class='icon-hdd'></a> Import from Server",3],["separator",-1],["<a class='icon-folder-close'></a> New Album",4]],contextMenu.show(t,n,o,"left")},settings:function(e){var t,n=e.pageX,o=e.pageY-$(document).scrollTop();contextMenu.fns=[function(){settings.setLogin()},function(){settings.setSorting()},function(){settings.setDropboxKey()},function(){window.open(lychee.website)},function(){window.open("plugins/check/")},function(){window.open("plugins/displaylog/")},function(){lychee.logout()}],t=[["<a class='icon-user'></a> Change Login",0],["<a class='icon-sort'></a> Change Sorting",1],["<a class='icon-folder-open'></a> Set Dropbox",2],["separator",-1],["<a class='icon-info-sign'></a> About Lychee",3],["<a class='icon-dashboard'></a> Diagnostics",4],["<a class='icon-list'></a> Show Log",5],["separator",-1],["<a class='icon-signout'></a> Sign Out",6]],contextMenu.show(t,n,o,"right")},album:function(e,t){var n,o=t.pageX,i=t.pageY-$(document).scrollTop();return"0"===e||"f"===e||"s"===e||"r"===e?!1:(contextMenu.fns=[function(){album.setTitle([e])},function(){album.delete([e])}],n=[["<a class='icon-edit'></a> Rename",0],["<a class='icon-trash'></a> Delete",1]],contextMenu.show(n,o,i,"right"),void $(".album[data-id='"+e+"']").addClass("active"))},albumMulti:function(e,t){var n,o=t.pageX,i=t.pageY-$(document).scrollTop();multiselect.stopResize(),contextMenu.fns=[function(){album.setTitle(e)},function(){album.delete(e)}],n=[["<a class='icon-edit'></a> Rename All",0],["<a class='icon-trash'></a> Delete All",1]],contextMenu.show(n,o,i,"right")},photo:function(e,t){var n,o=t.pageX,i=t.pageY-$(document).scrollTop();contextMenu.fns=[function(){photo.setStar([e])},function(){photo.editTags([e])},function(){photo.setTitle([e])},function(){contextMenu.move([e],t,"right")},function(){photo.delete([e])}],n=[["<a class='icon-star'></a> Star",0],["<a class='icon-tags'></a> Tags",1],["separator",-1],["<a class='icon-edit'></a> Rename",2],["<a class='icon-folder-open'></a> Move",3],["<a class='icon-trash'></a> Delete",4]],contextMenu.show(n,o,i,"right"),$(".photo[data-id='"+e+"']").addClass("active")},photoMulti:function(e,t){var n,o=t.pageX,i=t.pageY-$(document).scrollTop();multiselect.stopResize(),contextMenu.fns=[function(){photo.setStar(e)},function(){photo.editTags(e)},function(){photo.setTitle(e)},function(){contextMenu.move(e,t,"right")},function(){photo.delete(e)}],n=[["<a class='icon-star'></a> Star All",0],["<a class='icon-tags'></a> Tag All",1],["separator",-1],["<a class='icon-edit'></a> Rename All",2],["<a class='icon-folder-open'></a> Move All",3],["<a class='icon-trash'></a> Delete All",4]],contextMenu.show(n,o,i,"right")},photoMore:function(e,t){var n,o=t.pageX,i=t.pageY-$(document).scrollTop();contextMenu.fns=[function(){window.open(photo.getDirectLink())},function(){photo.getArchive(e)}],n=[["<a class='icon-resize-full'></a> Full Photo",0],["<a class='icon-circle-arrow-down'></a> Download",1]],contextMenu.show(n,o,i,"right")},move:function(e,t){var n=t.pageX,o=t.pageY-$(document).scrollTop(),i=[];contextMenu.close(!0),"0"!==album.getID()&&(i=[["Unsorted",0,"photo.setAlbum(["+e+"], 0)"],["separator",-1]]),lychee.api("getAlbums",function(t){0===t.num?i=[["New Album",0,"album.add()"]]:$.each(t.content,function(){this.id!=album.getID()&&i.push([this.title,0,"photo.setAlbum(["+e+"], "+this.id+")"])}),visible.photo()?contextMenu.show(i,n,o,"left"):contextMenu.show(i,n,o,"right")})},sharePhoto:function(e,t){var n,o=t.pageX,i=t.pageY;i-=$(document).scrollTop(),contextMenu.fns=[function(){photo.setPublic(e)},function(){photo.share(e,0)},function(){photo.share(e,1)},function(){photo.share(e,2)},function(){photo.share(e,3)},function(){window.open(photo.getDirectLink())}],link=photo.getViewLink(e),"2"===photo.json.public&&(link=location.href),n=[["<input readonly id='link' value='"+link+"'>",-1],["separator",-1],["<a class='icon-eye-close'></a> Make Private",0],["separator",-1],["<a class='icon-twitter'></a> Twitter",1],["<a class='icon-facebook'></a> Facebook",2],["<a class='icon-envelope'></a> Mail",3],["<a class='icon-hdd'></a> Dropbox",4],["<a class='icon-link'></a> Direct Link",5]],contextMenu.show(n,o,i,"left"),$(".contextmenu input").focus().select()},shareAlbum:function(e,t){var n,o=t.pageX,i=t.pageY;i-=$(document).scrollTop(),contextMenu.fns=[function(){album.setPublic(e)},function(){album.share(0)},function(){album.share(1)},function(){album.share(2)},function(){password.remove(e)}],n=[["<input readonly id='link' value='"+location.href+"'>",-1],["separator",-1],["<a class='icon-eye-close'></a> Make Private",0],["separator",-1],["<a class='icon-twitter'></a> Twitter",1],["<a class='icon-facebook'></a> Facebook",2],["<a class='icon-envelope'></a> Mail",3]],contextMenu.show(n,o,i,"left"),$(".contextmenu input").focus().select()},close:function(e){return visible.contextMenu()?(contextMenu.fns=[],$(".contextmenu_bg, .contextmenu").remove(),$("body").css("overflow","auto"),void(e!==!0&&($(".photo.active, .album.active").removeClass("active"),visible.multiselect()&&multiselect.close()))):!1}},$(document).ready(function(){var e=mobileBrowser()?"touchend":"click";$(document).bind("contextmenu",function(e){e.preventDefault()}),mobileBrowser()||$(".tools").tipsy({gravity:"n",fade:!1,delayIn:0,opacity:1}),$("#content").on("mousedown",multiselect.show),$(document).on("mouseup",multiselect.getSelection),$("#hostedwith").on(e,function(){window.open(lychee.website)}),$("#button_signin").on(e,lychee.loginDialog),$("#button_settings").on("click",contextMenu.settings),$("#button_share").on(e,function(e){1==photo.json.public||2==photo.json.public?contextMenu.sharePhoto(photo.getID(),e):photo.setPublic(photo.getID(),e)}),$("#button_share_album").on(e,function(e){1==album.json.public?contextMenu.shareAlbum(album.getID(),e):album.setPublic(album.getID(),e)}),$("#button_more").on(e,function(e){contextMenu.photoMore(photo.getID(),e)}),$("#button_trash_album").on(e,function(){album.delete([album.getID()])}),$("#button_move").on(e,function(e){contextMenu.move([photo.getID()],e)}),$("#button_trash").on(e,function(){photo.delete([photo.getID()])}),$("#button_info_album").on(e,function(){view.infobox.show()}),$("#button_info").on(e,function(){view.infobox.show()}),$("#button_archive").on(e,function(){album.getArchive(album.getID())}),$("#button_star").on(e,function(){photo.setStar([photo.getID()])}),$("#search").on("keyup click",function(){search.find($(this).val())}),$("#clearSearch").on(e,function(){$("#search").focus(),search.reset()}),$("#button_back_home").on(e,function(){lychee.goto("")}),$("#button_back").on(e,function(){lychee.goto(album.getID())}),lychee.imageview.on(e,".arrow_wrapper.previous",photo.previous).on(e,".arrow_wrapper.next",photo.next),$("#infobox").on(e,".header a",function(){view.infobox.hide()}).on(e,"#edit_title_album",function(){album.setTitle([album.getID()])}).on(e,"#edit_description_album",function(){album.setDescription(album.getID())}).on(e,"#edit_title",function(){photo.setTitle([photo.getID()])}).on(e,"#edit_description",function(){photo.setDescription(photo.getID())}).on(e,"#edit_tags",function(){photo.editTags([photo.getID()])}).on(e,"#tags .tag span",function(){photo.deleteTag(photo.getID(),$(this).data("index"))}),Mousetrap.bind("left",function(){visible.photo()&&$("#imageview a#previous").click()}).bind("right",function(){visible.photo()&&$("#imageview a#next").click()}).bind(["u","ctrl+u"],function(){$("#upload_files").click()}).bind(["s","ctrl+s","f","ctrl+f"],function(e){visible.photo()?$("#button_star").click():visible.albums()&&(e.preventDefault(),$("#search").focus())}).bind(["r","ctrl+r"],function(e){e.preventDefault(),visible.album()?album.setTitle(album.getID()):visible.photo()&&photo.setTitle([photo.getID()])}).bind(["d","ctrl+d"],function(e){e.preventDefault(),visible.photo()?photo.setDescription(photo.getID()):visible.album()&&album.setDescription(album.getID())}).bind(["t","ctrl+t"],function(e){visible.photo()&&(e.preventDefault(),photo.editTags([photo.getID()]))}).bind(["i","ctrl+i"],function(){visible.infobox()?view.infobox.hide():visible.infoboxbutton()&&view.infobox.show()}).bind(["command+backspace","ctrl+backspace"],function(){visible.photo()&&!visible.message()?photo.delete([photo.getID()]):visible.album()&&!visible.message()&&album.delete([album.getID()])}),Mousetrap.bindGlobal("enter",function(){$(".message .button.active").length&&$(".message .button.active").addClass("pressed").click()}),Mousetrap.bindGlobal(["esc","command+up"],function(e){e.preventDefault(),visible.message()&&$(".message .close").length>0?modal.close():visible.contextMenu()?contextMenu.close():visible.infobox()?view.infobox.hide():visible.photo()?lychee.goto(album.getID()):visible.album()?lychee.goto(""):visible.albums()&&0!==$("#search").val().length&&search.reset()}),mobileBrowser()&&$(document).on("touchend","#image",function(e){(null===swipe.obj||swipe.offset>=-5&&swipe.offset<=5)&&(visible.controls()?view.header.hide(e,0):view.header.show())}).swipe().on("swipeStart",function(){visible.photo()&&swipe.start($("#image"))}).swipe().on("swipeMove",function(e){visible.photo()&&swipe.move(e.swipe)}).swipe().on("swipeEnd",function(e){visible.photo()&&swipe.stop(e.swipe,photo.previous,photo.next)}),$(document).on("keyup","#password",function(){$(this).val().length>0&&$(this).removeClass("error")}).on(e,"#title.editable",function(){visible.photo()?photo.setTitle([photo.getID()]):album.setTitle([album.getID()])}).on("click",".album",function(){lychee.goto($(this).attr("data-id"))}).on("click",".photo",function(){lychee.goto(album.getID()+"/"+$(this).attr("data-id"))}).on(e,".message .close",modal.close).on(e,".message .button:first",function(){null!==modal.fns&&modal.fns[0](),visible.signin()||modal.close()}).on(e,".message .button:last",function(){null!==modal.fns&&modal.fns[1](),visible.signin()||modal.close()}).on(e,".button_add",function(e){contextMenu.add(e)}).on("change","#upload_files",function(){modal.close(),upload.start.local(this.files)}).on("contextmenu",".photo",function(e){contextMenu.photo(photo.getID(),e)}).on("contextmenu",".album",function(e){contextMenu.album(album.getID(),e)}).on(e,".contextmenu_bg",contextMenu.close).on("contextmenu",".contextmenu_bg",contextMenu.close).on(e,"#infobox_overlay",view.infobox.hide).on("dragover",function(e){e.preventDefault()},!1).on("drop",function(e){return e.stopPropagation(),e.preventDefault(),e.originalEvent.dataTransfer.files.length>0?upload.start.local(e.originalEvent.dataTransfer.files):e.originalEvent.dataTransfer.getData("Text").length>3&&upload.start.url(e.originalEvent.dataTransfer.getData("Text")),!0}),lychee.init()}),loadingBar={status:null,show:function(e,t){return"error"===e?(loadingBar.status="error",t&&(t=t.replace("<br>","")),t||(t="Whoops, it looks like something went wrong. Please reload the site and try again!"),visible.controls()&&lychee.header.addClass("error"),lychee.loadingBar.removeClass("loading uploading error").addClass(e).html("<h1>Error: <span>"+t+"</span></h1>").show().css("height","40px"),clearTimeout(lychee.loadingBar.data("timeout")),lychee.loadingBar.data("timeout",setTimeout(function(){loadingBar.hide(!0)},3e3)),!0):null===loadingBar.status?(loadingBar.status="loading",clearTimeout(lychee.loadingBar.data("timeout")),lychee.loadingBar.data("timeout",setTimeout(function(){visible.controls()&&lychee.header.addClass("loading"),lychee.loadingBar.removeClass("loading uploading error").addClass("loading").show()
},1e3)),!0):void 0},hide:function(e){("error"!==loadingBar.status&&null!==loadingBar.status||e)&&(loadingBar.status=null,visible.controls()&&lychee.header.removeClass("error loading"),lychee.loadingBar.html("").css("height","3px"),clearTimeout(lychee.loadingBar.data("timeout")),setTimeout(function(){lychee.loadingBar.hide()},300))}};var lychee={title:"",version:"2.6.0",version_code:"020600",api_path:"php/api.php",update_path:"http://lychee.electerious.com/version/index.php",updateURL:"https://github.com/electerious/Lychee",website:"http://lychee.electerious.com",publicMode:!1,viewMode:!1,debugMode:!1,username:"",checkForUpdates:!1,sorting:"",location:"",dropbox:!1,dropboxKey:"",loadingBar:$("#loading"),header:$("header"),content:$("#content"),imageview:$("#imageview"),infobox:$("#infobox"),init:function(){var e;e="init&version="+lychee.version_code,lychee.api(e,function(e){return e.loggedIn!==!0?lychee.setMode("public"):(lychee.username=e.config.username||"",lychee.sorting=e.config.sorting||"",lychee.dropboxKey=e.config.dropboxKey||"",lychee.location=e.config.location||""),"Warning: No configuration!"===e?(lychee.header.hide(),lychee.content.hide(),$("body").append(build.no_content("cog")),settings.createConfig(),!0):(e.config.login===!1&&settings.createLogin(),lychee.checkForUpdates=e.config.checkForUpdates,$(window).bind("popstate",lychee.load),void lychee.load())})},api:function(e,t,n){void 0===n&&loadingBar.show(),$.ajax({type:"POST",url:lychee.api_path,data:"function="+e,dataType:"text",success:function(n){return setTimeout(function(){loadingBar.hide()},100),"string"==typeof n&&"Error: "===n.substring(0,7)?(lychee.error(n.substring(7,n.length),e,n),upload.close(!0),!1):("1"===n?n=!0:""===n&&(n=!1),"string"==typeof n&&"{"===n.substring(0,1)&&"}"===n.substring(n.length-1,n.length)&&(n=$.parseJSON(n)),lychee.debugMode&&console.log(n),void t(n))},error:function(t,n,o){lychee.error("Server error or API not found.",e,o),upload.close(!0)}})},login:function(){var e,t=$("input#username").val(),n=md5($("input#password").val());e="login&user="+t+"&password="+n,lychee.api(e,function(e){e===!0?(localStorage.setItem("lychee_username",t),window.location.reload()):($("#password").val("").addClass("error").focus(),$(".message .button.active").removeClass("pressed"))})},loginDialog:function(){var e;$("body").append(build.signInModal()),$("#username").focus(),localStorage&&(e=localStorage.getItem("lychee_username"),null!==e&&(e.length>0&&$("#username").val(e),$("#password").focus())),"1"===lychee.checkForUpdates&&lychee.getUpdate()},logout:function(){lychee.api("logout",function(){window.location.reload()})},"goto":function(e){void 0===e&&(e=""),document.location.hash=e},load:function(){var e="",t="",n=document.location.hash.replace("#","").split("/");$(".no_content").remove(),contextMenu.close(),multiselect.close(),void 0!==n[0]&&(e=n[0]),void 0!==n[1]&&(t=n[1]),e&&t?(albums.json=null,photo.json=null,(""===lychee.content.html()||$("#search").length&&0!==$("#search").val().length)&&(lychee.content.hide(),album.load(e,!0)),photo.load(t,e)):e?(albums.json=null,photo.json=null,visible.photo()&&view.photo.hide(),album.json&&e==album.json.id?view.album.title():album.load(e)):(albums.json=null,album.json=null,photo.json=null,search.code="",visible.album()&&view.album.hide(),visible.photo()&&view.photo.hide(),albums.load())},getUpdate:function(){$.ajax({url:lychee.update_path,success:function(e){e!=lychee.version&&$("#version span").show()}})},setTitle:function(e,t){""===lychee.title&&(lychee.title=document.title),document.title="Albums"===e?lychee.title:lychee.title+" - "+e,t?$("#title").addClass("editable"):$("#title").removeClass("editable"),$("#title").html(e)},setMode:function(e){$("#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).on("mouseenter","#title.editable",function(){$(this).removeClass("editable")}).off("click","#title.editable").off("touchend","#title.editable").off("contextmenu",".photo").off("contextmenu",".album").off("drop"),Mousetrap.unbind(["u","ctrl+u"]).unbind(["s","ctrl+s"]).unbind(["r","ctrl+r"]).unbind(["d","ctrl+d"]).unbind(["t","ctrl+t"]).unbind(["command+backspace","ctrl+backspace"]),"public"===e?($("header #button_signin, header #hostedwith").show(),lychee.publicMode=!0):"view"===e&&(Mousetrap.unbind("esc"),$("#button_back, a#next, a#previous").remove(),$(".no_content").remove(),lychee.publicMode=!0,lychee.viewMode=!0)},animate:function(e,t){var n=[["fadeIn","fadeOut"],["contentZoomIn","contentZoomOut"]];e.jQuery||(e=$(e));for(var o=0;o<n.length;o++)for(var i=0;i<n[o].length;i++)if(n[o][i]==t)return e.removeClass(n[o][0]+" "+n[o][1]).addClass(t),!0;return!1},escapeHTML:function(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},loadDropbox:function(e){if(!lychee.dropbox&&lychee.dropboxKey){loadingBar.show();var t=document.createElement("script"),n=document.getElementsByTagName("script")[0];t.src="https://www.dropbox.com/static/api/1/dropins.js",t.id="dropboxjs",t.type="text/javascript",t.async="true",t.setAttribute("data-app-key",lychee.dropboxKey),t.onload=t.onreadystatechange=function(){var t=this.readyState;t&&"complete"!==t&&"loaded"!==t||(lychee.dropbox=!0,loadingBar.hide(),e())},n.parentNode.insertBefore(t,n)}else lychee.dropbox&&lychee.dropboxKey?e():settings.setDropboxKey(e)},removeHTML:function(e){var t=document.createElement("DIV");return t.innerHTML=e,t.textContent||t.innerText},error:function(e,t,n){console.log("Error Description: "+e),console.log("Error Params: "+t),console.log("Server Response: "+n),loadingBar.show("error",e)}};modal={fns:null,show:function(e,t,n,o,i){n||(n=[["",function(){}],["",function(){}]]),modal.fns=[n[0][1],n[1][1]],$("body").append(build.modal(e,t,n,o,i)),$(".message input:first-child").focus().select()},close:function(){modal.fns=null,$(".message_overlay").removeClass("fadeIn").css("opacity",0),setTimeout(function(){$(".message_overlay").remove()},300)}},multiselect={position:{top:null,right:null,bottom:null,left:null},show:function(e){return mobileBrowser()?!1:lychee.publicMode?!1:visible.search()?!1:0!==$(".album:hover, .photo:hover").length?!1:(visible.multiselect()&&$("#multiselect").remove(),multiselect.position.top=e.pageY,multiselect.position.right=-1*(e.pageX-$(document).width()),multiselect.position.bottom=-1*(multiselect.position.top-$(window).height()),multiselect.position.left=e.pageX,$("body").append(build.multiselect(multiselect.position.top,multiselect.position.left)),void $(document).on("mousemove",multiselect.resize))},resize:function(e){var t,n,o=e.pageX,i=e.pageY;return null===multiselect.position.top||null===multiselect.position.right||null===multiselect.position.bottom||null===multiselect.position.left?!1:(i>=multiselect.position.top?(t=e.pageY-multiselect.position.top,multiselect.position.top+t>=$(document).height()&&(t-=multiselect.position.top+t-$(document).height()+2),$("#multiselect").css({top:multiselect.position.top,bottom:"inherit",height:t})):$("#multiselect").css({top:"inherit",bottom:multiselect.position.bottom,height:multiselect.position.top-e.pageY}),void(o>=multiselect.position.left?(n=e.pageX-multiselect.position.left,multiselect.position.left+n>=$(document).width()&&(n-=multiselect.position.left+n-$(document).width()+2),$("#multiselect").css({right:"inherit",left:multiselect.position.left,width:n})):$("#multiselect").css({right:multiselect.position.right,left:"inherit",width:multiselect.position.left-e.pageX})))},stopResize:function(){$(document).off("mousemove")},getSize:function(){return visible.multiselect()?{top:$("#multiselect").offset().top,left:$("#multiselect").offset().left,width:parseInt($("#multiselect").css("width").replace("px","")),height:parseInt($("#multiselect").css("height").replace("px",""))}:!1},getSelection:function(e){var t,n,o=150,i=[],a=multiselect.getSize();return visible.contextMenu()?!1:visible.multiselect()?($(".photo, .album").each(function(){n=$(this).offset(),n.top>=a.top-o&&n.left>=a.left-o&&n.top+206<=a.top+a.height+o&&n.left+206<=a.left+a.width+o&&(t=$(this).data("id"),"0"!==t&&0!==t&&"f"!==t&&"s"!==t&&"r"!==t&&null!==t&void 0!==t&&(i.push(t),$(this).addClass("active")))}),void(0!==i.length&&visible.album()?contextMenu.photoMulti(i,e):0!==i.length&&visible.albums()?contextMenu.albumMulti(i,e):multiselect.close())):!1},close:function(){multiselect.stopResize(),multiselect.position.top=null,multiselect.position.right=null,multiselect.position.bottom=null,multiselect.position.left=null,lychee.animate("#multiselect","fadeOut"),setTimeout(function(){$("#multiselect").remove()},300)}},password={value:"",get:function(e,t){var n,o=$(".message input.text").val();lychee.publicMode?album.json&&0==album.json.password?t():albums.json&&0==albums.json.content[e].password?t():albums.json||album.json?void 0==o?password.getDialog(e,t):(n="checkAlbumAccess&albumID="+e+"&password="+md5(o),lychee.api(n,function(e){e===!0?(password.value=md5(o),t()):(lychee.goto(""),loadingBar.show("error","Access denied. Wrong password!"))})):(album.json={password:!0},t("")):t()},getDialog:function(e,t){var n;n=[["Enter",function(){password.get(e,t)}],["Cancel",lychee.goto]],modal.show("<a class='icon-lock'></a> Enter Password","This album is protected by a password. Enter the password below to view the photos of this album: <input class='text' type='password' placeholder='password' value=''>",n,-110,!1)}},photo={json:null,getID:function(){var e;return e=photo.json?photo.json.id:$(".photo:hover, .photo.active").attr("data-id"),e?e:!1},load:function(e,t){var n,o;n="getPhoto&photoID="+e+"&albumID="+t+"&password="+password.value,lychee.api(n,function(n){return"Warning: Wrong password!"===n?(o=function(){""!==password.value?photo.load(e,t):setTimeout(o,250)},o(),!1):(photo.json=n,visible.photo()||view.photo.show(),view.photo.init(),lychee.imageview.show(),void setTimeout(function(){lychee.content.show()},300))})},parse:function(){photo.json.title||(photo.json.title="Untitled")},previous:function(e){var t=0;photo.getID()!==!1&&album.json&&album.json.content[photo.getID()]&&""!==album.json.content[photo.getID()].previousPhoto&&(e===!0&&(t=200,$("#image").css({WebkitTransform:"translateX(100%)",MozTransform:"translateX(100%)",transform:"translateX(100%)",opacity:0})),setTimeout(function(){return photo.getID()===!1?!1:void lychee.goto(album.getID()+"/"+album.json.content[photo.getID()].previousPhoto)},t))},next:function(e){var t=0;photo.getID()!==!1&&album.json&&album.json.content[photo.getID()]&&""!==album.json.content[photo.getID()].nextPhoto&&(e===!0&&(t=200,$("#image").css({WebkitTransform:"translateX(-100%)",MozTransform:"translateX(-100%)",transform:"translateX(-100%)",opacity:0})),setTimeout(function(){return photo.getID()===!1?!1:void lychee.goto(album.getID()+"/"+album.json.content[photo.getID()].nextPhoto)},t))},"delete":function(e){var t,n,o;return e?(e instanceof Array==!1&&(e=[e]),1===e.length&&(o=visible.photo()?photo.json.title:album.json.content[e].title,""===o&&(o="Untitled")),n=[["",function(){e.forEach(function(e){(""!==album.json.content[e].nextPhoto||""!==album.json.content[e].previousPhoto)&&(nextPhoto=album.json.content[e].nextPhoto,previousPhoto=album.json.content[e].previousPhoto,album.json.content[previousPhoto].nextPhoto=nextPhoto,album.json.content[nextPhoto].previousPhoto=previousPhoto),album.json.content[e]=null,view.album.content.delete(e)}),visible.albums()||lychee.goto(album.getID()),t="deletePhoto&photoIDs="+e,lychee.api(t,function(e){e!==!0&&lychee.error(null,t,e)})}],["",function(){}]],void(1===e.length?(n[0][0]="Delete Photo",n[1][0]="Keep Photo",modal.show("Delete Photo","Are you sure you want to delete the photo '"+o+"'?<br>This action can't be undone!",n)):(n[0][0]="Delete Photos",n[1][0]="Keep Photos",modal.show("Delete Photos","Are you sure you want to delete all "+e.length+" selected photo?<br>This action can't be undone!",n)))):!1},setTitle:function(e){var t,n,o,i="";return e?(e instanceof Array==!1&&(e=[e]),1===e.length&&(photo.json?i=photo.json.title:album.json&&(i=album.json.content[e].title),i=i.replace("'","'")),o=[["Set Title",function(){t=$(".message input.text").val(),t=lychee.removeHTML(t),visible.photo()&&(photo.json.title=""===t?"Untitled":t,view.photo.title()),e.forEach(function(e){album.json.content[e].title=t,view.album.content.title(e)}),n="setPhotoTitle&photoIDs="+e+"&title="+escape(encodeURI(t)),lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})}],["Cancel",function(){}]],void(1===e.length?modal.show("Set Title","Enter a new title for this photo: <input class='text' type='text' maxlength='30' placeholder='Title' value='"+i+"'>",o):modal.show("Set Titles","Enter a title for all "+e.length+" selected photos: <input class='text' type='text' maxlength='30' placeholder='Title' value=''>",o))):!1},setAlbum:function(e,t){var n,o,i;return e?(visible.photo&&lychee.goto(album.getID()),e instanceof Array==!1&&(e=[e]),e.forEach(function(e){(""!==album.json.content[e].nextPhoto||""!==album.json.content[e].previousPhoto)&&(o=album.json.content[e].nextPhoto,i=album.json.content[e].previousPhoto,album.json.content[i].nextPhoto=o,album.json.content[o].previousPhoto=i),album.json.content[e]=null,view.album.content.delete(e)}),n="setPhotoAlbum&photoIDs="+e+"&albumID="+t,void lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})):!1},setStar:function(e){var t;return e?(visible.photo()&&(photo.json.star=0==photo.json.star?1:0,view.photo.star()),e.forEach(function(e){album.json.content[e].star=0==album.json.content[e].star?1:0,view.album.content.star(e)}),t="setPhotoStar&photoIDs="+e,void lychee.api(t,function(e){e!==!0&&lychee.error(null,t,e)})):!1},setPublic:function(e,t){var n;return 2==photo.json.public?(modal.show("Public Album","This photo is located in a public album. To make this photo private or public, edit the visibility of the associated album.",[["Show Album",function(){lychee.goto(photo.json.original_album)}],["Close",function(){}]]),!1):(visible.photo()&&(photo.json.public=0==photo.json.public?1:0,view.photo.public(),1==photo.json.public&&contextMenu.sharePhoto(e,t)),album.json.content[e].public=0==album.json.content[e].public?1:0,view.album.content.public(e),n="setPhotoPublic&photoID="+e,void lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)}))},setDescription:function(e){var t,n,o,i=photo.json.description.replace("'","'");o=[["Set Description",function(){t=$(".message input.text").val(),t=lychee.removeHTML(t),visible.photo()&&(photo.json.description=t,view.photo.description()),n="setPhotoDescription&photoID="+e+"&description="+escape(encodeURI(t)),lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})}],["Cancel",function(){}]],modal.show("Set Description","Enter a description for this photo: <input class='text' type='text' maxlength='800' placeholder='Description' value='"+i+"'>",o)},editTags:function(e){var t,n="",o="";if(!e)return!1;if(e instanceof Array==!1&&(e=[e]),visible.photo()&&(n=photo.json.tags),visible.album()&&1===e.length&&(n=album.json.content[e].tags),visible.album()&&e.length>1){var i=!0;e.forEach(function(t){i=album.json.content[t].tags===album.json.content[e[0]].tags&&i===!0?!0:!1}),i&&(n=album.json.content[e[0]].tags)}n=n.replace(/,/g,", "),t=[["Set Tags",function(){o=$(".message input.text").val(),photo.setTags(e,o)}],["Cancel",function(){}]],1===e.length?modal.show("Set Tags","Enter your tags for this photo. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='"+n+"'>",t):modal.show("Set Tags","Enter your tags for all "+e.length+" selected photos. Existing tags will be overwritten. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='"+n+"'>",t)},setTags:function(e,t){var n;return e?(e instanceof Array==!1&&(e=[e]),t=t.replace(/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/g,","),t=t.replace(/,$|^,|(\ ){0,}$/g,""),t=lychee.removeHTML(t),visible.photo()&&(photo.json.tags=t,view.photo.tags()),e.forEach(function(e){album.json.content[e].tags=t}),n="setPhotoTags&photoIDs="+e+"&tags="+t,void lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})):!1},deleteTag:function(e,t){var n;n=photo.json.tags.split(","),n.splice(t,1),photo.json.tags=n.toString(),photo.setTags([e],photo.json.tags)},share:function(e,t){var n="",o=photo.getViewLink(e),i="unknown";switch(t){case 0:n="https://twitter.com/share?url="+encodeURI(o);break;case 1:n="http://www.facebook.com/sharer.php?u="+encodeURI(o)+"&t="+encodeURI(photo.json.title);break;case 2:n="mailto:?subject="+encodeURI(photo.json.title)+"&body="+encodeURI(o);break;case 3:lychee.loadDropbox(function(){i=photo.json.title+"."+photo.getDirectLink().split(".").pop(),Dropbox.save(photo.getDirectLink(),i)});break;default:n=""}n.length>5&&(location.href=n)},isSmall:function(){var e={width:!1,height:!1};return photo.json.width<$(window).width()-60&&(e.width=!0),photo.json.height<$(window).height()-100&&(e.height=!0),e.width&&e.height?!0:!1},getArchive:function(e){var t;t=location.href.indexOf("index.html")>0?location.href.replace(location.hash,"").replace("index.html","php/api.php?function=getPhotoArchive&photoID="+e):location.href.replace(location.hash,"")+"php/api.php?function=getPhotoArchive&photoID="+e,lychee.publicMode&&(t+="&password="+password.value),location.href=t},getDirectLink:function(){return $("#imageview #image").css("background-image").replace(/"/g,"").replace(/url\(|\)$/gi,"")},getViewLink:function(e){return location.href.indexOf("index.html")>0?location.href.replace("index.html"+location.hash,"view.php?p="+e):location.href.replace(location.hash,"view.php?p="+e)}},search={code:null,find:function(e){var t,n,o="",i="";clearTimeout($(window).data("timeout")),$(window).data("timeout",setTimeout(function(){0!==$("#search").val().length?(t="search&term="+e,lychee.api(t,function(e){e&&e.albums&&(albums.json={content:e.albums},$.each(albums.json.content,function(){albums.parse(this),o+=build.album(this)})),e&&e.photos&&(album.json={content:e.photos},$.each(album.json.content,function(){i+=build.photo(this)})),n=""===o&&""===i?"error":""===o?build.divider("Photos")+i:""===i?build.divider("Albums")+o:build.divider("Photos")+i+build.divider("Albums")+o,search.code!==md5(n)&&($(".no_content").remove(),lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)","contentZoomOut"),lychee.animate(".divider","fadeOut"),search.code=md5(n),setTimeout(function(){"error"===n?$("body").append(build.no_content("search")):(lychee.content.html(n),lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)","contentZoomIn"),$("img[data-type!='svg']").retina())},300))})):search.reset()},250))},reset:function(){$("#search").val(""),$(".no_content").remove(),""!==search.code&&(albums.json=null,album.json=null,photo.json=null,search.code="",lychee.animate(".divider","fadeOut"),albums.load())}};var settings={createConfig:function(){var e,t,n,o,i,a;i=[["Connect",function(){o=$(".message input.text#dbHost").val(),t=$(".message input.text#dbUser").val(),n=$(".message input.text#dbPassword").val(),e=$(".message input.text#dbName").val(),o.length<1&&(o="localhost"),e.length<1&&(e="lychee"),a="dbCreateConfig&dbName="+escape(e)+"&dbUser="+escape(t)+"&dbPassword="+escape(n)+"&dbHost="+escape(o),lychee.api(a,function(e){e!==!0?setTimeout(function(){return-1!==e.indexOf("Warning: Connection failed!")?(i=[["Retry",function(){setTimeout(settings.createConfig,400)}],["",function(){}]],modal.show("Connection Failed","Unable to connect to host database because access was denied. Double-check your host, username and password and ensure that access from your current location is permitted.",i,null,!1),!1):-1!==e.indexOf("Warning: Creation failed!")?(i=[["Retry",function(){setTimeout(settings.createConfig,400)}],["",function(){}]],modal.show("Creation Failed","Unable to create the database. Double-check your host, username and password and ensure that the specified user has the rights to modify and add content to the database.",i,null,!1),!1):-1!==e.indexOf("Warning: Could not create file!")?(i=[["Retry",function(){setTimeout(settings.createConfig,400)}],["",function(){}]],modal.show("Saving Failed","Unable to save this configuration. Permission denied in <b>'data/'</b>. Please set the read, write and execute rights for others in <b>'data/'</b> and <b>'uploads/'</b>. Take a look the readme for more information.",i,null,!1),!1):(i=[["Retry",function(){setTimeout(settings.createConfig,400)}],["",function(){}]],modal.show("Configuration Failed","Something unexpected happened. Please try again and check your installation and server. Take a look the readme for more information.",i,null,!1),!1)},400):window.location.reload()})}],["",function(){}]],modal.show("Configuration","Enter your database connection details below: <input id='dbHost' class='text less' type='text' placeholder='Host (optional)' value=''><input id='dbUser' class='text less' type='text' placeholder='Username' value=''><input id='dbPassword' class='text more' type='password' placeholder='Password' value=''><br>Lychee will create its own database. If required, you can enter the name of an existing database instead:<input id='dbName' class='text more' type='text' placeholder='Database (optional)' value=''>",i,-215,!1)},createLogin:function(){var e,t,n,o;o=[["Create Login",function(){e=$(".message input.text#username").val(),t=$(".message input.text#password").val(),e.length<1||t.length<1?setTimeout(function(){return o=[["Retry",function(){setTimeout(settings.createLogin,400)}],["",function(){}]],modal.show("Wrong Input","The username or password you entered is not long enough. Please try again with another username and password!",o,null,!1),!1},400):(n="setLogin&username="+escape(e)+"&password="+md5(t),lychee.api(n,function(e){e!==!0&&setTimeout(function(){return o=[["Retry",function(){setTimeout(settings.createLogin,400)}],["",function(){}]],modal.show("Creation Failed","Unable to save login. Please try again with another username and password!",o,null,!1),!1},400)}))}],["",function(){}]],modal.show("Create Login","Enter a username and password for your installation: <input id='username' class='text less' type='text' placeholder='New Username' value=''><input id='password' class='text' type='password' placeholder='New Password' value=''>",o,-122,!1)},setLogin:function(){var e,t,n,o,i;i=[["Change Login",function(){return e=$(".message input.text#old_password").val(),t=$(".message input.text#username").val(),n=$(".message input.text#password").val(),e.length<1?(loadingBar.show("error","Your old password was entered incorrectly. Please try again!"),!1):t.length<1?(loadingBar.show("error","Your new username was entered incorrectly. Please try again!"),!1):n.length<1?(loadingBar.show("error","Your new password was entered incorrectly. Please try again!"),!1):(o="setLogin&oldPassword="+md5(e)+"&username="+escape(t)+"&password="+md5(n),void lychee.api(o,function(e){e!==!0&&lychee.error(null,o,e)}))}],["Cancel",function(){}]],modal.show("Change Login","Enter your current password: <input id='old_password' class='text more' type='password' placeholder='Current Password' value=''><br>Your username and password will be changed to the following: <input id='username' class='text less' type='text' placeholder='New Username' value=''><input id='password' class='text' type='password' placeholder='New Password' value=''>",i,-171)},setSorting:function(){var e,t,n;e=[["Change Sorting",function(){t[0]=$("select#settings_type").val(),t[1]=$("select#settings_order").val(),n="setSorting&type="+t[0]+"&order="+t[1],lychee.api(n,function(e){e===!0?(lychee.sorting="ORDER BY "+t[0]+" "+t[1],lychee.load()):lychee.error(null,n,e)})}],["Cancel",function(){}]],modal.show("Change Sorting","Sort photos by <select id='settings_type'> <option value='id'>Upload Time</option> <option value='takestamp'>Take Date</option> <option value='title'>Title</option> <option value='description'>Description</option> <option value='public'>Public</option> <option value='star'>Star</option> <option value='type'>Photo Format</option> </select> in an <select id='settings_order'> <option value='ASC'>Ascending</option> <option value='DESC'>Descending</option> </select> order. ",e),""!==lychee.sorting&&(t=lychee.sorting.replace("ORDER BY ","").split(" "),$("select#settings_type").val(t[0]),$("select#settings_order").val(t[1]))},setDropboxKey:function(e){var t,n,o;t=[["Set Key",function(){o=$(".message input.text#key").val(),n="setDropboxKey&key="+o,lychee.api(n,function(t){t===!0?(lychee.dropboxKey=o,e&&lychee.loadDropbox(e)):lychee.error(null,n,t)})}],["Cancel",function(){}]],modal.show("Set Dropbox Key","In order to import photos from your Dropbox, you need a valid drop-ins app key from <a href='https://www.dropbox.com/developers/apps/create'>their website</a>. Generate yourself a personal key and enter it below: <input id='key' class='text' type='text' placeholder='Dropbox API Key' value='"+lychee.dropboxKey+"'>",t)}};swipe={obj:null,tolerance:150,offset:0,start:function(e,t){return e&&(swipe.obj=e),t&&(swipe.tolerance=t),!0},move:function(e){return null===swipe.obj?!1:(swipe.offset=-1*e.x,void swipe.obj.css({WebkitTransform:"translateX("+swipe.offset+"px)",MozTransform:"translateX("+swipe.offset+"px)",transform:"translateX("+swipe.offset+"px)"}))},stop:function(e,t,n){e.x<=-swipe.tolerance?t(!0):e.x>=swipe.tolerance?n(!0):null!==swipe.obj&&swipe.obj.css({WebkitTransform:"translateX(0px)",MozTransform:"translateX(0px)",transform:"translateX(0px)"}),swipe.obj=null,swipe.offset=0}},upload={show:function(e,t,n){upload.close(!0),$("body").append(build.uploadModal(e,t)),null!=n&&void 0!=n&&n()},setIcon:function(e){$(".upload_message a").remove(),$(".upload_message").prepend("<a class='icon-"+e+"'></a>")},setProgress:function(e){$(".progressbar div").css("width",e+"%")},setText:function(e){$(".progressbar").remove(),$(".upload_message").append("<p>"+e+"</p>")},notify:function(e){var t;return window.webkitNotifications?(0!==window.webkitNotifications.checkPermission()&&window.webkitNotifications.requestPermission(),void(0===window.webkitNotifications.checkPermission()&&e&&(t=window.webkitNotifications.createNotification("",e,"You can now manage your new photo(s)."),t.show()))):!1},start:{local:function(e){var t=album.getID(),n=function(e,o){var i,a=new FormData,r=new XMLHttpRequest,s=0,l=function(){window.onbeforeunload=null,$("#upload_files").val(""),upload.close(),album.getID()===!1?lychee.goto("0"):album.load(t)};if(o.supported===!1){if(null!==o.next)n(e,o.next);else{for(var u=!1,c=0;c<e.length;c++)if(e[c].supported===!0){u=!0;break}u===!1&&setTimeout(l,2e3)}return!1}a.append("function","upload"),a.append("albumID",t),a.append(0,o),r.open("POST",lychee.api_path),r.onload=function(){if(200===r.status){var t;$(".upload_message .rows .row:nth-child("+(o.num+1)+") .status").html("Finished").addClass("success"),o.ready=!0,t=!1;for(var n=0;n<e.length;n++)if(e[n].ready===!1){t=!0;break}t===!1&&l()}},r.upload.onprogress=function(t){if(t.lengthComputable&&(i=t.loaded/t.total*100|0,i>s&&($(".upload_message .rows .row:nth-child("+(o.num+1)+") .status").html(i+"%"),s=i),i>=100)){var a=0;o.num+1>4&&(a=40*(o.num+1-4)),$(".upload_message .rows").scrollTop(a),$(".upload_message .rows .row:nth-child("+(o.num+1)+") .status").html("Processing"),null!==o.next&&n(e,o.next)}},r.send(a)};if(e.length<=0)return!1;(t===!1||visible.albums()===!0)&&(t=0);for(var o=0;o<e.length;o++)e[o].num=o,e[o].ready=!1,e[o].supported=!0,e[o].next=o<e.length-1?e[o+1]:null,"image/jpeg"!==e[o].type&&"image/jpg"!==e[o].type&&"image/png"!==e[o].type&&"image/gif"!==e[o].type&&(e[o].ready=!0,e[o].supported=!1);window.onbeforeunload=function(){return"Lychee is currently uploading!"},upload.show("Uploading",e),n(e,e[0])},url:function(){var e,t,n,o,i=album.getID(),a=[];i===!1&&(i=0),n=[["Import",function(){if(o=$(".message input.text").val(),o&&o.length>3){if(t=o.split(".").pop(),"jpeg"!==t&&"jpg"!==t&&"png"!==t&&"gif"!==t&&"webp"!==t)return loadingBar.show("error","The file format of this link is not supported."),!1;a[0]={name:o,supported:!0},upload.show("Importing URL",a,function(){$(".upload_message .rows .row .status").html("Importing")}),e="importUrl&url="+escape(encodeURI(o))+"&albumID="+i,lychee.api(e,function(t){upload.close(),upload.notify("Import complete"),album.getID()===!1?lychee.goto("0"):album.load(i),t!==!0&&lychee.error(null,e,t)})}else loadingBar.show("error","Link to short or too long. Please try another one!")}],["Cancel",function(){}]],modal.show("Import from Link","Please enter the direct link to a photo to import it: <input class='text' type='text' placeholder='http://' value='http://'>",n)},server:function(){var e,t,n,o=album.getID(),i=[];o===!1&&(o=0),t=[["Import",function(){n=$(".message input.text").val(),i[0]={name:n,supported:!0},upload.show("Importing from server",i,function(){$(".upload_message .rows .row .status").html("Importing")}),e="importServer&albumID="+o+"&path="+escape(encodeURI(n)),lychee.api(e,function(t){return upload.close(),upload.notify("Import complete"),"Notice: Import only contains albums!"===t?visible.albums()?lychee.load():lychee.goto(""):album.getID()===!1?lychee.goto("0"):album.load(o),"Notice: Import only contains albums!"===t?!0:void("Warning: Folder empty!"===t?lychee.error("Folder empty. No photos imported!",e,t):t!==!0&&lychee.error(null,e,t))})}],["Cancel",function(){}]],modal.show("Import from Server","This action will import all photos and albums which are located in the following directory. The original files will be deleted after the import. <input class='text' type='text' maxlength='100' placeholder='Absolute path to directory' value='"+lychee.location+"uploads/import/'>",t)},dropbox:function(){var e,t=album.getID(),n="";t===!1&&(t=0),lychee.loadDropbox(function(){Dropbox.choose({linkType:"direct",multiselect:!0,success:function(o){for(var i=0;i<o.length;i++)n+=o[i].link+",",o[i]={name:o[i].link,supported:!0};n=n.substr(0,n.length-1),upload.show("Importing from Dropbox",o,function(){$(".upload_message .rows .row .status").html("Importing")}),e="importUrl&url="+escape(n)+"&albumID="+t,lychee.api(e,function(n){upload.close(),upload.notify("Import complete"),album.getID()===!1?lychee.goto("0"):album.load(t),n!==!0&&lychee.error(null,e,n)})}})})}},close:function(e){e===!0?$(".upload_overlay").remove():(upload.setProgress(100),$(".upload_overlay").removeClass("fadeIn").css("opacity",0),setTimeout(function(){$(".upload_overlay").remove()},300))}},view={header:{show:function(){var e=-1*($("#imageview #image").height()/2)+20;clearTimeout($(window).data("timeout")),lychee.imageview.removeClass("full"),lychee.header.removeClass("hidden"),lychee.loadingBar.css("opacity",1),$("#imageview #image.small").length>0?$("#imageview #image").css("margin-top",e):$("#imageview #image").removeClass("full")},hide:function(e,t){var n=-1*($("#imageview #image").height()/2);void 0===t&&(t=500),!visible.photo()||visible.infobox()||visible.contextMenu()||visible.message()||(clearTimeout($(window).data("timeout")),$(window).data("timeout",setTimeout(function(){lychee.imageview.addClass("full"),lychee.header.addClass("hidden"),lychee.loadingBar.css("opacity",0),$("#imageview #image.small").length>0?$("#imageview #image").css("margin-top",n):$("#imageview #image").addClass("full")},t)))},mode:function(e){var t=album.getID();switch(e){case"albums":lychee.header.removeClass("view"),$("#tools_album, #tools_photo").hide(),$("#tools_albums").show();break;case"album":lychee.header.removeClass("view"),$("#tools_albums, #tools_photo").hide(),$("#tools_album").show(),album.json.content===!1?$("#button_archive").hide():$("#button_archive").show(),"s"===t||"f"===t||"r"===t?$("#button_info_album, #button_trash_album, #button_share_album").hide():"0"===t?($("#button_info_album, #button_share_album").hide(),$("#button_trash_album").show()):$("#button_info_album, #button_trash_album, #button_share_album").show();
},1e3)),!0):void 0},hide:function(e){("error"!==loadingBar.status&&null!==loadingBar.status||e)&&(loadingBar.status=null,visible.controls()&&lychee.header.removeClass("error loading"),lychee.loadingBar.html("").css("height","3px"),clearTimeout(lychee.loadingBar.data("timeout")),setTimeout(function(){lychee.loadingBar.hide()},300))}};var lychee={title:"",version:"2.6",version_code:"020600",api_path:"php/api.php",update_path:"http://lychee.electerious.com/version/index.php",updateURL:"https://github.com/electerious/Lychee",website:"http://lychee.electerious.com",publicMode:!1,viewMode:!1,debugMode:!1,username:"",checkForUpdates:!1,sorting:"",location:"",dropbox:!1,dropboxKey:"",loadingBar:$("#loading"),header:$("header"),content:$("#content"),imageview:$("#imageview"),infobox:$("#infobox"),init:function(){var e;e="init&version="+lychee.version_code,lychee.api(e,function(e){return e.loggedIn!==!0?lychee.setMode("public"):(lychee.username=e.config.username||"",lychee.sorting=e.config.sorting||"",lychee.dropboxKey=e.config.dropboxKey||"",lychee.location=e.config.location||""),"Warning: No configuration!"===e?(lychee.header.hide(),lychee.content.hide(),$("body").append(build.no_content("cog")),settings.createConfig(),!0):(e.config.login===!1&&settings.createLogin(),lychee.checkForUpdates=e.config.checkForUpdates,$(window).bind("popstate",lychee.load),void lychee.load())})},api:function(e,t,n){void 0===n&&loadingBar.show(),$.ajax({type:"POST",url:lychee.api_path,data:"function="+e,dataType:"text",success:function(n){return setTimeout(function(){loadingBar.hide()},100),"string"==typeof n&&"Error: "===n.substring(0,7)?(lychee.error(n.substring(7,n.length),e,n),upload.close(!0),!1):("1"===n?n=!0:""===n&&(n=!1),"string"==typeof n&&"{"===n.substring(0,1)&&"}"===n.substring(n.length-1,n.length)&&(n=$.parseJSON(n)),lychee.debugMode&&console.log(n),void t(n))},error:function(t,n,o){lychee.error("Server error or API not found.",e,o),upload.close(!0)}})},login:function(){var e,t=$("input#username").val(),n=md5($("input#password").val());e="login&user="+t+"&password="+n,lychee.api(e,function(e){e===!0?(localStorage.setItem("lychee_username",t),window.location.reload()):($("#password").val("").addClass("error").focus(),$(".message .button.active").removeClass("pressed"))})},loginDialog:function(){var e;$("body").append(build.signInModal()),$("#username").focus(),localStorage&&(e=localStorage.getItem("lychee_username"),null!==e&&(e.length>0&&$("#username").val(e),$("#password").focus())),"1"===lychee.checkForUpdates&&lychee.getUpdate()},logout:function(){lychee.api("logout",function(){window.location.reload()})},"goto":function(e){void 0===e&&(e=""),document.location.hash=e},load:function(){var e="",t="",n=document.location.hash.replace("#","").split("/");$(".no_content").remove(),contextMenu.close(),multiselect.close(),void 0!==n[0]&&(e=n[0]),void 0!==n[1]&&(t=n[1]),e&&t?(albums.json=null,photo.json=null,(""===lychee.content.html()||$("#search").length&&0!==$("#search").val().length)&&(lychee.content.hide(),album.load(e,!0)),photo.load(t,e)):e?(albums.json=null,photo.json=null,visible.photo()&&view.photo.hide(),album.json&&e==album.json.id?view.album.title():album.load(e)):(albums.json=null,album.json=null,photo.json=null,search.code="",visible.album()&&view.album.hide(),visible.photo()&&view.photo.hide(),albums.load())},getUpdate:function(){$.ajax({url:lychee.update_path,success:function(e){parseInt(e)>parseInt(lychee.version_code)&&$("#version span").show()}})},setTitle:function(e,t){""===lychee.title&&(lychee.title=document.title),document.title="Albums"===e?lychee.title:lychee.title+" - "+e,t?$("#title").addClass("editable"):$("#title").removeClass("editable"),$("#title").html(e)},setMode:function(e){$("#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).on("mouseenter","#title.editable",function(){$(this).removeClass("editable")}).off("click","#title.editable").off("touchend","#title.editable").off("contextmenu",".photo").off("contextmenu",".album").off("drop"),Mousetrap.unbind(["u","ctrl+u"]).unbind(["s","ctrl+s"]).unbind(["r","ctrl+r"]).unbind(["d","ctrl+d"]).unbind(["t","ctrl+t"]).unbind(["command+backspace","ctrl+backspace"]),"public"===e?($("header #button_signin, header #hostedwith").show(),lychee.publicMode=!0):"view"===e&&(Mousetrap.unbind("esc"),$("#button_back, a#next, a#previous").remove(),$(".no_content").remove(),lychee.publicMode=!0,lychee.viewMode=!0)},animate:function(e,t){var n=[["fadeIn","fadeOut"],["contentZoomIn","contentZoomOut"]];e.jQuery||(e=$(e));for(var o=0;o<n.length;o++)for(var i=0;i<n[o].length;i++)if(n[o][i]==t)return e.removeClass(n[o][0]+" "+n[o][1]).addClass(t),!0;return!1},escapeHTML:function(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},loadDropbox:function(e){if(!lychee.dropbox&&lychee.dropboxKey){loadingBar.show();var t=document.createElement("script"),n=document.getElementsByTagName("script")[0];t.src="https://www.dropbox.com/static/api/1/dropins.js",t.id="dropboxjs",t.type="text/javascript",t.async="true",t.setAttribute("data-app-key",lychee.dropboxKey),t.onload=t.onreadystatechange=function(){var t=this.readyState;t&&"complete"!==t&&"loaded"!==t||(lychee.dropbox=!0,loadingBar.hide(),e())},n.parentNode.insertBefore(t,n)}else lychee.dropbox&&lychee.dropboxKey?e():settings.setDropboxKey(e)},removeHTML:function(e){var t=document.createElement("DIV");return t.innerHTML=e,t.textContent||t.innerText},error:function(e,t,n){console.log("Error Description: "+e),console.log("Error Params: "+t),console.log("Server Response: "+n),loadingBar.show("error",e)}};modal={fns:null,show:function(e,t,n,o,i){n||(n=[["",function(){}],["",function(){}]]),modal.fns=[n[0][1],n[1][1]],$("body").append(build.modal(e,t,n,o,i)),$(".message input:first-child").focus().select()},close:function(){modal.fns=null,$(".message_overlay").removeClass("fadeIn").css("opacity",0),setTimeout(function(){$(".message_overlay").remove()},300)}},multiselect={position:{top:null,right:null,bottom:null,left:null},show:function(e){return mobileBrowser()?!1:lychee.publicMode?!1:visible.search()?!1:0!==$(".album:hover, .photo:hover").length?!1:(visible.multiselect()&&$("#multiselect").remove(),multiselect.position.top=e.pageY,multiselect.position.right=-1*(e.pageX-$(document).width()),multiselect.position.bottom=-1*(multiselect.position.top-$(window).height()),multiselect.position.left=e.pageX,$("body").append(build.multiselect(multiselect.position.top,multiselect.position.left)),void $(document).on("mousemove",multiselect.resize))},resize:function(e){var t,n,o=e.pageX,i=e.pageY;return null===multiselect.position.top||null===multiselect.position.right||null===multiselect.position.bottom||null===multiselect.position.left?!1:(i>=multiselect.position.top?(t=e.pageY-multiselect.position.top,multiselect.position.top+t>=$(document).height()&&(t-=multiselect.position.top+t-$(document).height()+2),$("#multiselect").css({top:multiselect.position.top,bottom:"inherit",height:t})):$("#multiselect").css({top:"inherit",bottom:multiselect.position.bottom,height:multiselect.position.top-e.pageY}),void(o>=multiselect.position.left?(n=e.pageX-multiselect.position.left,multiselect.position.left+n>=$(document).width()&&(n-=multiselect.position.left+n-$(document).width()+2),$("#multiselect").css({right:"inherit",left:multiselect.position.left,width:n})):$("#multiselect").css({right:multiselect.position.right,left:"inherit",width:multiselect.position.left-e.pageX})))},stopResize:function(){$(document).off("mousemove")},getSize:function(){return visible.multiselect()?{top:$("#multiselect").offset().top,left:$("#multiselect").offset().left,width:parseInt($("#multiselect").css("width").replace("px","")),height:parseInt($("#multiselect").css("height").replace("px",""))}:!1},getSelection:function(e){var t,n,o=150,i=[],a=multiselect.getSize();return visible.contextMenu()?!1:visible.multiselect()?($(".photo, .album").each(function(){n=$(this).offset(),n.top>=a.top-o&&n.left>=a.left-o&&n.top+206<=a.top+a.height+o&&n.left+206<=a.left+a.width+o&&(t=$(this).data("id"),"0"!==t&&0!==t&&"f"!==t&&"s"!==t&&"r"!==t&&null!==t&void 0!==t&&(i.push(t),$(this).addClass("active")))}),void(0!==i.length&&visible.album()?contextMenu.photoMulti(i,e):0!==i.length&&visible.albums()?contextMenu.albumMulti(i,e):multiselect.close())):!1},close:function(){multiselect.stopResize(),multiselect.position.top=null,multiselect.position.right=null,multiselect.position.bottom=null,multiselect.position.left=null,lychee.animate("#multiselect","fadeOut"),setTimeout(function(){$("#multiselect").remove()},300)}},password={value:"",get:function(e,t){var n,o=$(".message input.text").val();lychee.publicMode?album.json&&0==album.json.password?t():albums.json&&0==albums.json.content[e].password?t():albums.json||album.json?void 0==o?password.getDialog(e,t):(n="checkAlbumAccess&albumID="+e+"&password="+md5(o),lychee.api(n,function(e){e===!0?(password.value=md5(o),t()):(lychee.goto(""),loadingBar.show("error","Access denied. Wrong password!"))})):(album.json={password:!0},t("")):t()},getDialog:function(e,t){var n;n=[["Enter",function(){password.get(e,t)}],["Cancel",lychee.goto]],modal.show("<a class='icon-lock'></a> Enter Password","This album is protected by a password. Enter the password below to view the photos of this album: <input class='text' type='password' placeholder='password' value=''>",n,-110,!1)}},photo={json:null,getID:function(){var e;return e=photo.json?photo.json.id:$(".photo:hover, .photo.active").attr("data-id"),e?e:!1},load:function(e,t){var n,o;n="getPhoto&photoID="+e+"&albumID="+t+"&password="+password.value,lychee.api(n,function(n){return"Warning: Wrong password!"===n?(o=function(){""!==password.value?photo.load(e,t):setTimeout(o,250)},o(),!1):(photo.json=n,visible.photo()||view.photo.show(),view.photo.init(),lychee.imageview.show(),void setTimeout(function(){lychee.content.show()},300))})},parse:function(){photo.json.title||(photo.json.title="Untitled")},previous:function(e){var t=0;photo.getID()!==!1&&album.json&&album.json.content[photo.getID()]&&""!==album.json.content[photo.getID()].previousPhoto&&(e===!0&&(t=200,$("#image").css({WebkitTransform:"translateX(100%)",MozTransform:"translateX(100%)",transform:"translateX(100%)",opacity:0})),setTimeout(function(){return photo.getID()===!1?!1:void lychee.goto(album.getID()+"/"+album.json.content[photo.getID()].previousPhoto)},t))},next:function(e){var t=0;photo.getID()!==!1&&album.json&&album.json.content[photo.getID()]&&""!==album.json.content[photo.getID()].nextPhoto&&(e===!0&&(t=200,$("#image").css({WebkitTransform:"translateX(-100%)",MozTransform:"translateX(-100%)",transform:"translateX(-100%)",opacity:0})),setTimeout(function(){return photo.getID()===!1?!1:void lychee.goto(album.getID()+"/"+album.json.content[photo.getID()].nextPhoto)},t))},"delete":function(e){var t,n,o;return e?(e instanceof Array==!1&&(e=[e]),1===e.length&&(o=visible.photo()?photo.json.title:album.json.content[e].title,""===o&&(o="Untitled")),n=[["",function(){e.forEach(function(e){(""!==album.json.content[e].nextPhoto||""!==album.json.content[e].previousPhoto)&&(nextPhoto=album.json.content[e].nextPhoto,previousPhoto=album.json.content[e].previousPhoto,album.json.content[previousPhoto].nextPhoto=nextPhoto,album.json.content[nextPhoto].previousPhoto=previousPhoto),album.json.content[e]=null,view.album.content.delete(e)}),visible.albums()||lychee.goto(album.getID()),t="deletePhoto&photoIDs="+e,lychee.api(t,function(e){e!==!0&&lychee.error(null,t,e)})}],["",function(){}]],void(1===e.length?(n[0][0]="Delete Photo",n[1][0]="Keep Photo",modal.show("Delete Photo","Are you sure you want to delete the photo '"+o+"'?<br>This action can't be undone!",n)):(n[0][0]="Delete Photos",n[1][0]="Keep Photos",modal.show("Delete Photos","Are you sure you want to delete all "+e.length+" selected photo?<br>This action can't be undone!",n)))):!1},setTitle:function(e){var t,n,o,i="";return e?(e instanceof Array==!1&&(e=[e]),1===e.length&&(photo.json?i=photo.json.title:album.json&&(i=album.json.content[e].title),i=i.replace("'","'")),o=[["Set Title",function(){t=$(".message input.text").val(),t=lychee.removeHTML(t),visible.photo()&&(photo.json.title=""===t?"Untitled":t,view.photo.title()),e.forEach(function(e){album.json.content[e].title=t,view.album.content.title(e)}),n="setPhotoTitle&photoIDs="+e+"&title="+escape(encodeURI(t)),lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})}],["Cancel",function(){}]],void(1===e.length?modal.show("Set Title","Enter a new title for this photo: <input class='text' type='text' maxlength='30' placeholder='Title' value='"+i+"'>",o):modal.show("Set Titles","Enter a title for all "+e.length+" selected photos: <input class='text' type='text' maxlength='30' placeholder='Title' value=''>",o))):!1},setAlbum:function(e,t){var n,o,i;return e?(visible.photo&&lychee.goto(album.getID()),e instanceof Array==!1&&(e=[e]),e.forEach(function(e){(""!==album.json.content[e].nextPhoto||""!==album.json.content[e].previousPhoto)&&(o=album.json.content[e].nextPhoto,i=album.json.content[e].previousPhoto,album.json.content[i].nextPhoto=o,album.json.content[o].previousPhoto=i),album.json.content[e]=null,view.album.content.delete(e)}),n="setPhotoAlbum&photoIDs="+e+"&albumID="+t,void lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})):!1},setStar:function(e){var t;return e?(visible.photo()&&(photo.json.star=0==photo.json.star?1:0,view.photo.star()),e.forEach(function(e){album.json.content[e].star=0==album.json.content[e].star?1:0,view.album.content.star(e)}),t="setPhotoStar&photoIDs="+e,void lychee.api(t,function(e){e!==!0&&lychee.error(null,t,e)})):!1},setPublic:function(e,t){var n;return 2==photo.json.public?(modal.show("Public Album","This photo is located in a public album. To make this photo private or public, edit the visibility of the associated album.",[["Show Album",function(){lychee.goto(photo.json.original_album)}],["Close",function(){}]]),!1):(visible.photo()&&(photo.json.public=0==photo.json.public?1:0,view.photo.public(),1==photo.json.public&&contextMenu.sharePhoto(e,t)),album.json.content[e].public=0==album.json.content[e].public?1:0,view.album.content.public(e),n="setPhotoPublic&photoID="+e,void lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)}))},setDescription:function(e){var t,n,o,i=photo.json.description.replace("'","'");o=[["Set Description",function(){t=$(".message input.text").val(),t=lychee.removeHTML(t),visible.photo()&&(photo.json.description=t,view.photo.description()),n="setPhotoDescription&photoID="+e+"&description="+escape(encodeURI(t)),lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})}],["Cancel",function(){}]],modal.show("Set Description","Enter a description for this photo: <input class='text' type='text' maxlength='800' placeholder='Description' value='"+i+"'>",o)},editTags:function(e){var t,n="",o="";if(!e)return!1;if(e instanceof Array==!1&&(e=[e]),visible.photo()&&(n=photo.json.tags),visible.album()&&1===e.length&&(n=album.json.content[e].tags),visible.album()&&e.length>1){var i=!0;e.forEach(function(t){i=album.json.content[t].tags===album.json.content[e[0]].tags&&i===!0?!0:!1}),i&&(n=album.json.content[e[0]].tags)}n=n.replace(/,/g,", "),t=[["Set Tags",function(){o=$(".message input.text").val(),photo.setTags(e,o)}],["Cancel",function(){}]],1===e.length?modal.show("Set Tags","Enter your tags for this photo. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='"+n+"'>",t):modal.show("Set Tags","Enter your tags for all "+e.length+" selected photos. Existing tags will be overwritten. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='"+n+"'>",t)},setTags:function(e,t){var n;return e?(e instanceof Array==!1&&(e=[e]),t=t.replace(/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/g,","),t=t.replace(/,$|^,|(\ ){0,}$/g,""),t=lychee.removeHTML(t),visible.photo()&&(photo.json.tags=t,view.photo.tags()),e.forEach(function(e){album.json.content[e].tags=t}),n="setPhotoTags&photoIDs="+e+"&tags="+t,void lychee.api(n,function(e){e!==!0&&lychee.error(null,n,e)})):!1},deleteTag:function(e,t){var n;n=photo.json.tags.split(","),n.splice(t,1),photo.json.tags=n.toString(),photo.setTags([e],photo.json.tags)},share:function(e,t){var n="",o=photo.getViewLink(e),i="unknown";switch(t){case 0:n="https://twitter.com/share?url="+encodeURI(o);break;case 1:n="http://www.facebook.com/sharer.php?u="+encodeURI(o)+"&t="+encodeURI(photo.json.title);break;case 2:n="mailto:?subject="+encodeURI(photo.json.title)+"&body="+encodeURI(o);break;case 3:lychee.loadDropbox(function(){i=photo.json.title+"."+photo.getDirectLink().split(".").pop(),Dropbox.save(photo.getDirectLink(),i)});break;default:n=""}n.length>5&&(location.href=n)},isSmall:function(){var e={width:!1,height:!1};return photo.json.width<$(window).width()-60&&(e.width=!0),photo.json.height<$(window).height()-100&&(e.height=!0),e.width&&e.height?!0:!1},getArchive:function(e){var t;t=location.href.indexOf("index.html")>0?location.href.replace(location.hash,"").replace("index.html","php/api.php?function=getPhotoArchive&photoID="+e):location.href.replace(location.hash,"")+"php/api.php?function=getPhotoArchive&photoID="+e,lychee.publicMode&&(t+="&password="+password.value),location.href=t},getDirectLink:function(){return $("#imageview #image").css("background-image").replace(/"/g,"").replace(/url\(|\)$/gi,"")},getViewLink:function(e){return location.href.indexOf("index.html")>0?location.href.replace("index.html"+location.hash,"view.php?p="+e):location.href.replace(location.hash,"view.php?p="+e)}},search={code:null,find:function(e){var t,n,o="",i="";clearTimeout($(window).data("timeout")),$(window).data("timeout",setTimeout(function(){0!==$("#search").val().length?(t="search&term="+e,lychee.api(t,function(e){e&&e.albums&&(albums.json={content:e.albums},$.each(albums.json.content,function(){albums.parse(this),o+=build.album(this)})),e&&e.photos&&(album.json={content:e.photos},$.each(album.json.content,function(){i+=build.photo(this)})),n=""===o&&""===i?"error":""===o?build.divider("Photos")+i:""===i?build.divider("Albums")+o:build.divider("Photos")+i+build.divider("Albums")+o,search.code!==md5(n)&&($(".no_content").remove(),lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)","contentZoomOut"),lychee.animate(".divider","fadeOut"),search.code=md5(n),setTimeout(function(){"error"===n?$("body").append(build.no_content("search")):(lychee.content.html(n),lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)","contentZoomIn"),$("img[data-type!='svg']").retina())},300))})):search.reset()},250))},reset:function(){$("#search").val(""),$(".no_content").remove(),""!==search.code&&(albums.json=null,album.json=null,photo.json=null,search.code="",lychee.animate(".divider","fadeOut"),albums.load())}};var settings={createConfig:function(){var e,t,n,o,i,a;i=[["Connect",function(){o=$(".message input.text#dbHost").val(),t=$(".message input.text#dbUser").val(),n=$(".message input.text#dbPassword").val(),e=$(".message input.text#dbName").val(),o.length<1&&(o="localhost"),e.length<1&&(e="lychee"),a="dbCreateConfig&dbName="+escape(e)+"&dbUser="+escape(t)+"&dbPassword="+escape(n)+"&dbHost="+escape(o),lychee.api(a,function(e){e!==!0?setTimeout(function(){return-1!==e.indexOf("Warning: Connection failed!")?(i=[["Retry",function(){setTimeout(settings.createConfig,400)}],["",function(){}]],modal.show("Connection Failed","Unable to connect to host database because access was denied. Double-check your host, username and password and ensure that access from your current location is permitted.",i,null,!1),!1):-1!==e.indexOf("Warning: Creation failed!")?(i=[["Retry",function(){setTimeout(settings.createConfig,400)}],["",function(){}]],modal.show("Creation Failed","Unable to create the database. Double-check your host, username and password and ensure that the specified user has the rights to modify and add content to the database.",i,null,!1),!1):-1!==e.indexOf("Warning: Could not create file!")?(i=[["Retry",function(){setTimeout(settings.createConfig,400)}],["",function(){}]],modal.show("Saving Failed","Unable to save this configuration. Permission denied in <b>'data/'</b>. Please set the read, write and execute rights for others in <b>'data/'</b> and <b>'uploads/'</b>. Take a look the readme for more information.",i,null,!1),!1):(i=[["Retry",function(){setTimeout(settings.createConfig,400)}],["",function(){}]],modal.show("Configuration Failed","Something unexpected happened. Please try again and check your installation and server. Take a look the readme for more information.",i,null,!1),!1)},400):window.location.reload()})}],["",function(){}]],modal.show("Configuration","Enter your database connection details below: <input id='dbHost' class='text less' type='text' placeholder='Host (optional)' value=''><input id='dbUser' class='text less' type='text' placeholder='Username' value=''><input id='dbPassword' class='text more' type='password' placeholder='Password' value=''><br>Lychee will create its own database. If required, you can enter the name of an existing database instead:<input id='dbName' class='text more' type='text' placeholder='Database (optional)' value=''>",i,-215,!1)},createLogin:function(){var e,t,n,o;o=[["Create Login",function(){e=$(".message input.text#username").val(),t=$(".message input.text#password").val(),e.length<1||t.length<1?setTimeout(function(){return o=[["Retry",function(){setTimeout(settings.createLogin,400)}],["",function(){}]],modal.show("Wrong Input","The username or password you entered is not long enough. Please try again with another username and password!",o,null,!1),!1},400):(n="setLogin&username="+escape(e)+"&password="+md5(t),lychee.api(n,function(e){e!==!0&&setTimeout(function(){return o=[["Retry",function(){setTimeout(settings.createLogin,400)}],["",function(){}]],modal.show("Creation Failed","Unable to save login. Please try again with another username and password!",o,null,!1),!1},400)}))}],["",function(){}]],modal.show("Create Login","Enter a username and password for your installation: <input id='username' class='text less' type='text' placeholder='New Username' value=''><input id='password' class='text' type='password' placeholder='New Password' value=''>",o,-122,!1)},setLogin:function(){var e,t,n,o,i;i=[["Change Login",function(){return e=$(".message input.text#old_password").val(),t=$(".message input.text#username").val(),n=$(".message input.text#password").val(),e.length<1?(loadingBar.show("error","Your old password was entered incorrectly. Please try again!"),!1):t.length<1?(loadingBar.show("error","Your new username was entered incorrectly. Please try again!"),!1):n.length<1?(loadingBar.show("error","Your new password was entered incorrectly. Please try again!"),!1):(o="setLogin&oldPassword="+md5(e)+"&username="+escape(t)+"&password="+md5(n),void lychee.api(o,function(e){e!==!0&&lychee.error(null,o,e)}))}],["Cancel",function(){}]],modal.show("Change Login","Enter your current password: <input id='old_password' class='text more' type='password' placeholder='Current Password' value=''><br>Your username and password will be changed to the following: <input id='username' class='text less' type='text' placeholder='New Username' value=''><input id='password' class='text' type='password' placeholder='New Password' value=''>",i,-171)},setSorting:function(){var e,t,n;e=[["Change Sorting",function(){t[0]=$("select#settings_type").val(),t[1]=$("select#settings_order").val(),n="setSorting&type="+t[0]+"&order="+t[1],lychee.api(n,function(e){e===!0?(lychee.sorting="ORDER BY "+t[0]+" "+t[1],lychee.load()):lychee.error(null,n,e)})}],["Cancel",function(){}]],modal.show("Change Sorting","Sort photos by <select id='settings_type'> <option value='id'>Upload Time</option> <option value='takestamp'>Take Date</option> <option value='title'>Title</option> <option value='description'>Description</option> <option value='public'>Public</option> <option value='star'>Star</option> <option value='type'>Photo Format</option> </select> in an <select id='settings_order'> <option value='ASC'>Ascending</option> <option value='DESC'>Descending</option> </select> order. ",e),""!==lychee.sorting&&(t=lychee.sorting.replace("ORDER BY ","").split(" "),$("select#settings_type").val(t[0]),$("select#settings_order").val(t[1]))},setDropboxKey:function(e){var t,n,o;t=[["Set Key",function(){o=$(".message input.text#key").val(),n="setDropboxKey&key="+o,lychee.api(n,function(t){t===!0?(lychee.dropboxKey=o,e&&lychee.loadDropbox(e)):lychee.error(null,n,t)})}],["Cancel",function(){}]],modal.show("Set Dropbox Key","In order to import photos from your Dropbox, you need a valid drop-ins app key from <a href='https://www.dropbox.com/developers/apps/create'>their website</a>. Generate yourself a personal key and enter it below: <input id='key' class='text' type='text' placeholder='Dropbox API Key' value='"+lychee.dropboxKey+"'>",t)}};swipe={obj:null,tolerance:150,offset:0,start:function(e,t){return e&&(swipe.obj=e),t&&(swipe.tolerance=t),!0},move:function(e){return null===swipe.obj?!1:(swipe.offset=-1*e.x,void swipe.obj.css({WebkitTransform:"translateX("+swipe.offset+"px)",MozTransform:"translateX("+swipe.offset+"px)",transform:"translateX("+swipe.offset+"px)"}))},stop:function(e,t,n){e.x<=-swipe.tolerance?t(!0):e.x>=swipe.tolerance?n(!0):null!==swipe.obj&&swipe.obj.css({WebkitTransform:"translateX(0px)",MozTransform:"translateX(0px)",transform:"translateX(0px)"}),swipe.obj=null,swipe.offset=0}},upload={show:function(e,t,n){upload.close(!0),$("body").append(build.uploadModal(e,t)),null!=n&&void 0!=n&&n()},setIcon:function(e){$(".upload_message a").remove(),$(".upload_message").prepend("<a class='icon-"+e+"'></a>")},setProgress:function(e){$(".progressbar div").css("width",e+"%")},setText:function(e){$(".progressbar").remove(),$(".upload_message").append("<p>"+e+"</p>")},notify:function(e){var t;return window.webkitNotifications?(0!==window.webkitNotifications.checkPermission()&&window.webkitNotifications.requestPermission(),void(0===window.webkitNotifications.checkPermission()&&e&&(t=window.webkitNotifications.createNotification("",e,"You can now manage your new photo(s)."),t.show()))):!1},start:{local:function(e){var t=album.getID(),n=function(e,o){var i,a=new FormData,r=new XMLHttpRequest,s=0,l=function(){window.onbeforeunload=null,$("#upload_files").val(""),upload.close(),album.getID()===!1?lychee.goto("0"):album.load(t)};if(o.supported===!1){if(null!==o.next)n(e,o.next);else{for(var u=!1,c=0;c<e.length;c++)if(e[c].supported===!0){u=!0;break}u===!1&&setTimeout(l,2e3)}return!1}a.append("function","upload"),a.append("albumID",t),a.append(0,o),r.open("POST",lychee.api_path),r.onload=function(){if(200===r.status){var t;$(".upload_message .rows .row:nth-child("+(o.num+1)+") .status").html("Finished").addClass("success"),o.ready=!0,t=!1;for(var n=0;n<e.length;n++)if(e[n].ready===!1){t=!0;break}t===!1&&l()}},r.upload.onprogress=function(t){if(t.lengthComputable&&(i=t.loaded/t.total*100|0,i>s&&($(".upload_message .rows .row:nth-child("+(o.num+1)+") .status").html(i+"%"),s=i),i>=100)){var a=0;o.num+1>4&&(a=40*(o.num+1-4)),$(".upload_message .rows").scrollTop(a),$(".upload_message .rows .row:nth-child("+(o.num+1)+") .status").html("Processing"),null!==o.next&&n(e,o.next)}},r.send(a)};if(e.length<=0)return!1;(t===!1||visible.albums()===!0)&&(t=0);for(var o=0;o<e.length;o++)e[o].num=o,e[o].ready=!1,e[o].supported=!0,e[o].next=o<e.length-1?e[o+1]:null,"image/jpeg"!==e[o].type&&"image/jpg"!==e[o].type&&"image/png"!==e[o].type&&"image/gif"!==e[o].type&&(e[o].ready=!0,e[o].supported=!1);window.onbeforeunload=function(){return"Lychee is currently uploading!"},upload.show("Uploading",e),n(e,e[0])},url:function(){var e,t,n,o,i=album.getID(),a=[];i===!1&&(i=0),n=[["Import",function(){if(o=$(".message input.text").val(),o&&o.length>3){if(t=o.split(".").pop(),"jpeg"!==t&&"jpg"!==t&&"png"!==t&&"gif"!==t&&"webp"!==t)return loadingBar.show("error","The file format of this link is not supported."),!1;a[0]={name:o,supported:!0},upload.show("Importing URL",a,function(){$(".upload_message .rows .row .status").html("Importing")}),e="importUrl&url="+escape(encodeURI(o))+"&albumID="+i,lychee.api(e,function(t){upload.close(),upload.notify("Import complete"),album.getID()===!1?lychee.goto("0"):album.load(i),t!==!0&&lychee.error(null,e,t)})}else loadingBar.show("error","Link to short or too long. Please try another one!")}],["Cancel",function(){}]],modal.show("Import from Link","Please enter the direct link to a photo to import it: <input class='text' type='text' placeholder='http://' value='http://'>",n)},server:function(){var e,t,n,o=album.getID(),i=[];o===!1&&(o=0),t=[["Import",function(){n=$(".message input.text").val(),i[0]={name:n,supported:!0},upload.show("Importing from server",i,function(){$(".upload_message .rows .row .status").html("Importing")}),e="importServer&albumID="+o+"&path="+escape(encodeURI(n)),lychee.api(e,function(t){return upload.close(),upload.notify("Import complete"),"Notice: Import only contains albums!"===t?visible.albums()?lychee.load():lychee.goto(""):album.getID()===!1?lychee.goto("0"):album.load(o),"Notice: Import only contains albums!"===t?!0:void("Warning: Folder empty!"===t?lychee.error("Folder empty. No photos imported!",e,t):t!==!0&&lychee.error(null,e,t))})}],["Cancel",function(){}]],modal.show("Import from Server","This action will import all photos and albums which are located in the following directory. The original files will be deleted after the import. <input class='text' type='text' maxlength='100' placeholder='Absolute path to directory' value='"+lychee.location+"uploads/import/'>",t)},dropbox:function(){var e,t=album.getID(),n="";t===!1&&(t=0),lychee.loadDropbox(function(){Dropbox.choose({linkType:"direct",multiselect:!0,success:function(o){for(var i=0;i<o.length;i++)n+=o[i].link+",",o[i]={name:o[i].link,supported:!0};n=n.substr(0,n.length-1),upload.show("Importing from Dropbox",o,function(){$(".upload_message .rows .row .status").html("Importing")}),e="importUrl&url="+escape(n)+"&albumID="+t,lychee.api(e,function(n){upload.close(),upload.notify("Import complete"),album.getID()===!1?lychee.goto("0"):album.load(t),n!==!0&&lychee.error(null,e,n)})}})})}},close:function(e){e===!0?$(".upload_overlay").remove():(upload.setProgress(100),$(".upload_overlay").removeClass("fadeIn").css("opacity",0),setTimeout(function(){$(".upload_overlay").remove()},300))}},view={header:{show:function(){var e=-1*($("#imageview #image").height()/2)+20;clearTimeout($(window).data("timeout")),lychee.imageview.removeClass("full"),lychee.header.removeClass("hidden"),lychee.loadingBar.css("opacity",1),$("#imageview #image.small").length>0?$("#imageview #image").css("margin-top",e):$("#imageview #image").removeClass("full")},hide:function(e,t){var n=-1*($("#imageview #image").height()/2);void 0===t&&(t=500),!visible.photo()||visible.infobox()||visible.contextMenu()||visible.message()||(clearTimeout($(window).data("timeout")),$(window).data("timeout",setTimeout(function(){lychee.imageview.addClass("full"),lychee.header.addClass("hidden"),lychee.loadingBar.css("opacity",0),$("#imageview #image.small").length>0?$("#imageview #image").css("margin-top",n):$("#imageview #image").addClass("full")},t)))},mode:function(e){var t=album.getID();switch(e){case"albums":lychee.header.removeClass("view"),$("#tools_album, #tools_photo").hide(),$("#tools_albums").show();break;case"album":lychee.header.removeClass("view"),$("#tools_albums, #tools_photo").hide(),$("#tools_album").show(),album.json.content===!1?$("#button_archive").hide():$("#button_archive").show(),"s"===t||"f"===t||"r"===t?$("#button_info_album, #button_trash_album, #button_share_album").hide():"0"===t?($("#button_info_album, #button_share_album").hide(),$("#button_trash_album").show()):$("#button_info_album, #button_trash_album, #button_share_album").show();