functiongup(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");vart="[\\?&]"+e+"=([^&#]*)",n=newRegExp(t),o=n.exec(window.location.href);returnnull===o?"":o[1]}!function(e,t){"object"==typeofmodule&&"object"==typeofmodule.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)thrownewError("jQuery requires a window with a document");returnt(e)}:t(e)}("undefined"!=typeofwindow?window:this,function(e,t){functionn(e){vart=e.length,n=J.type(e);return"function"===n||J.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeoft&&t>0&&t-1ine}functiono(e,t,n){if(J.isFunction(t))returnJ.grep(e,function(e,o){return!!t.call(e,o,e)!==n});if(t.nodeType)returnJ.grep(e,function(e){returne===t!==n});if("string"==typeoft){if(rt.test(t))returnJ.filter(t,e,n);t=J.filter(t,e)}returnJ.grep(e,function(e){returnz.call(t,e)>=0!==n})}functioni(e,t){for(;(e=e[t])&&1!==e.nodeType;);returne}functiona(e){vart=ft[e]={};returnJ.each(e.match(ht)||[],function(e,n){t[n]=!0}),t}functions(){Q.removeEventListener("DOMContentLoaded",s,!1),e.removeEventListener("load",s,!1),J.ready()}functionr(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=J.expando+r.uid++}functionl(e,t,n){varo;if(void0===n&&1===e.nodeType)if(o="data-"+t.replace(wt,"-$1").toLowerCase(),n=e.getAttribute(o),"string"==typeofn){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:yt.test(n)?J.parseJSON(n):n}catch(i){}vt.set(e,t,n)}elsen=void0;returnn}functionu(){return!0}functionc(){return!1}functiond(){try{returnQ.activeElement}catch(e){}}functionp(e,t){returnJ.nodeName(e,"table")&&J.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}functionh(e){returne.type=(null!==e.getAttribute("type"))+"/"+e.type,e}functionf(e){vart=Lt.exec(e.type);returnt?e.type=t[1]:e.removeAttribute("type"),e}functionm(e,t){for(varn=0,o=e.length;o>n;n++)gt.set(e[n],"globalEval",!t||gt.get(t[n],"globalEval"))}functionb(e,t){varn,o,i,a,s,r,l,u;if(1===t.nodeType){if(gt.hasData(e)&&(a=gt.access(e),s=gt.set(t,a),u=a.events)){deletes.handle,s.events={};for(iinu)for(n=0,o=u[i].length;o>n;n++)J.event.add(t,i,u[i][n])}vt.hasData(e)&&(r=vt.access(e),l=J.extend({},r),vt.set(t,l))}}functiong(e,t){varn=e.getElementsByTagName?e.getElementsByTagName(t||"*"):e.querySelectorAll?e.querySelectorAll(t||"*"):[];returnvoid0===t||t&&J.nodeName(e,t)?J.merge([e],n):n}functionv(e,t){varn=t.nodeName.toLowerCase();"input"===n&&Tt.test(e.type)?t.checked=e.checked:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}functiony(t,n){varo,i=J(n.createElement(t)).appendTo(n.body),a=e.getDefaultComputedStyle&&(o=e.getDefaultComputedStyle(i[0]))?o.display:J.css(i[0],"display");returni.detach(),a}functionw(e){vart=Q,n=Rt[e];returnn||(n=y(e,t),"none"!==n&&n||(Ht=(Ht||J("<iframe frameborder='0' width='0' height='0'/>")).appendTo(t.documentElement),t=Ht[0].contentDocument,t.write(),t.close(),n=y(e,t),Ht.detach()),Rt[e]=n),n}functionx(e,t,n){varo,i,a,s,r=e.style;returnn=n||Ut(e),n&&(s=n.getPropertyValue(t)||n[t]),n&&(""!==s||J.contains(e.ownerDocument,e)||(s=J.style(e,t)),Bt.test(s)&&Ft.test(t)&&(o=r.width,i=r.minWidth,a=r.maxWidth,r.minWidth=r.maxWidth=r.width=s,s=n.width,r.width=o,r.minWidth=i,r.maxWidth=a)),void0!==s?s+"":s}functionj(e,t){return{get:function(){returne()?voiddeletethis.get:(this.get=t).apply(this,arguments)}}}functionM(e,t){if(tine)returnt;for(varn=t[0].toUpperCase()+t.slice(1),o=t,i=Vt.length;i--;)if(t=Vt[i]+n,tine)returnt;returno}functionT(e,t,n){varo=Xt.exec(t);returno?Math.max(0,o[1]-(n||0))+(o[2]||"px"):t}functionk(e,t,n,o,i){for(vara=n===(o?"border":"content")?4:"width"===t?1:0,s=0;4>a;a+=2)"margin"===n&&(s+=J.css(e,n+jt[a],!0,i)),o?("content"===n&&(s-=J.css(e,"padding"+jt[a],!0,i)),"margin"!==n&&(s-=J.css(e,"border"+jt[a]+"Width",!0,i))):(s+=J.css(e,"padding"+jt[a],!0,i),"padding"!==n&&(s+=J.css(e,"border"+jt[a]+"Width",!0,i)));returns}functionC(e,t,n){varo=!0,i="width"===t?e.
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){vart=e.originalEvent.touches[0];this.swipeStart(e,t.pageX,t.pageY)},touchMove:function(e){vart=e.originalEvent.touches[0];this.swipeMove(e,t.pageX,t.pageY)},mouseDown:function(e){vart=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=(newDate).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){varo=this,i=e.Event(t),a=o.pos.start.x-o.pos.end.x,s=o.pos.end.y-o.pos.start.y,r=Math.atan2(s,a),l="up",u=Math.round(Math.sqrt(Math.pow(a,2)+Math.pow(s,2))),c=Math.round(180*r/Math.PI),d=Math.round(u/((newDate).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:s,direction:l,distance:u,angle:c,speed:d},e(o.el).trigger(i)}},e.fn.swipe=function(){newt(this);returnthis}}(jQuery),album={json:null},album.getID=function(){vare;returne=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},album.load=function(e,t){varn,o,i,a;password.get(e,function(){t||(lychee.animate(".album, .photo","contentZoomOut"),lychee.animate(".divider","fadeOut")),n=(newDate).getTime(),o={albumID:e,password:password.value},api.post("Album::get",o,function(o){return"Warning: Album private!"===o?(void0!=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=(newDate).getTime()-n,a=i>300?0:300-i,t===!0&&(a=0),visible.albums()||visible.photo()||visible.album()||(a=0),voidsetTimeout(function(){view.album.init(),t||(lychee.animate(".album, .photo","contentZoomIn"),header.setMode("album"))},a))})})},album.parse=function(){album.json.title||(album.json.title="Untitled")},album.add=function(){vare;e=function(e){vart,n=e.title;basicModal.close(),t=function(e){return!isNaN(parseFloat(e))&&isFinite(e)},0===n.length&&(n="Untitled"),api.post("Album::add",{title:n},function(e){e===!0&&(e=1),e!==!1&&t(e)?(albums.refresh(),lychee["goto"](e)):lychee.error(null,params,e)})},basicModal.show({body:"<p>Enter a title for the new album: <input class='text' data-name='title' type='text' maxlength='30' placeholder='Title' value='Untitled'></p>",buttons:{action:{title:"Create Album",fn:e},cancel:{title:"Cancel",fn:basicModal.close}}})},album["delete"]=function(e){vart={},n={},o="",i="";returne?(einstanceofArray==!1&&(e=[e]),t.fn=function(){vart;basicModal.close(),t={albumIDs:e.join()},api.post("Album::delete",t,function(n){visible.albums()?e.forEach(function(e){albums.json.num--,view.albums.content["delete"](e),deletealbums.json.albums[e]}):(albums.refresh(),lychee["goto"]("")),n!==!0&&lychee.error(null,t,n)})},"0"===e.toString()?(t.title="Clear Unsorted",n.title="Keep Unsorted",o="<p>Are you sure you want to delete all photos from 'Unsorted'?<br>This action can't be undone!</p>"):1===e.length?(t.title="Delete Album and Photos",n.title="Keep Album",album.json?i=album.json.title:albums.json&&(i=albums.json.albums[e].title),o="<p>Are you sure you want to delete the album '"+i+"' and all of the photos it contains? This action can't be undone!</p>"):(t.title="DeleteAlbumsandPh
}),"ontouchend"indocument.documentElement&&$(document).on("touchend","#image",function(e){(null===swipe.obj||swipe.offset>=-5&&swipe.offset<=5)&&(visible.header()?header.hide(e,0):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("click",".album",function(){lychee["goto"]($(this).attr("data-id"))}).on("click",".photo",function(){lychee["goto"](album.getID()+"/"+$(this).attr("data-id"))}).on("contextmenu",".photo",function(e){contextMenu.photo(photo.getID(),e)}).on("contextmenu",".album",function(e){contextMenu.album(album.getID(),e)}).on(e,"#infobox_overlay",view.infobox.hide).on("change","#upload_files",function(){basicModal.close(),upload.start.local(this.files)}).on("dragover",function(e){e.preventDefault()},!1).on("drop",function(e){returne.stopPropagation(),e.preventDefault(),visible.photo()&&lychee["goto"](album.getID()),visible.contextMenu()&&contextMenu.close(),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,_dom:$("#loading")},loadingBar.dom=function(e){returnvoid0===e||null===e||""===e?loadingBar._dom:loadingBar._dom.find(e)},loadingBar.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.header()&&header.dom().addClass("error"),loadingBar.dom().removeClass("loading uploading error").addClass(e).html("<h1>Error: <span>"+t+"</span></h1>").show().css("height","40px"),clearTimeout(loadingBar._timeout),loadingBar._timeout=setTimeout(function(){loadingBar.hide(!0)},3e3),!0):null===loadingBar.status?(loadingBar.status="loading",clearTimeout(loadingBar._timeout),loadingBar._timeout=setTimeout(function(){visible.header()&&header.dom().addClass("loading"),loadingBar.dom().removeClass("loading uploading error").addClass("loading").show()},1e3),!0):void0},loadingBar.hide=function(e){("error"!==loadingBar.status&&null!==loadingBar.status||e)&&(loadingBar.status=null,visible.header()&&header.dom().removeClass("error loading"),loadingBar.dom().html("").css("height","3px"),clearTimeout(loadingBar._timeout),setTimeout(function(){loadingBar.dom().hide()},300))},lychee={title:document.title,version:"3.0.0",version_code:"030000",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,checkForUpdates:!1,username:"",sorting:"",location:"",dropbox:!1,dropboxKey:"",content:$("#content"),imageview:$("#imageview"),infobox:$("#infobox")},lychee.init=function(){vare;e={version:lychee.version_code},api.post("Session::init",e,function(e){if(2===e.status)lychee.username=e.config.username||"",lychee.sorting=e.config.sorting||"",lychee.dropboxKey=e.config.dropboxKey||"",lychee.location=e.config.location||"",lychee.checkForUpdates=e.config.checkForUpdates||!0,e.config.login===!1&&settings.createLogin();elseif(1===e.status)lychee.setMode("public");elseif(0===e.status)returnlychee.setMode("public"),header.dom().hide(),lychee.content.hide(),$("body").append(build.no_content("cog")),settings.createConfig(),!0;$(window).bind("popstate",lychee.load),lychee.load()})},lychee.login=function(e){vart,n=e.username,o=e.password;t={user:n,password:o},api.post("Session::login",t,function(e){if(e===!0){try{localStorage.setItem("lychee_username",n)}catch(t){}window.location.reload()}elsebasicModal.error("password")})},lychee.loginDialog=function(){vare,t="";t="\n<pclass='signIn'>\n<inputclass='text'data-name='username'type='text'value=''pla
}},s.send(a)};if(e.length<=0)return!1;(t===!1||visible.albums()===!0)&&(t=0);for(vari=0;i<e.length;i++)e[i].num=i,e[i].ready=!1,e[i].supported=!0,e[i].next=i<e.length-1?e[i+1]:null,"image/jpeg"!==e[i].type&&"image/jpg"!==e[i].type&&"image/png"!==e[i].type&&"image/gif"!==e[i].type&&(e[i].ready=!0,e[i].supported=!1);window.onbeforeunload=function(){return"Lychee is currently uploading!"},upload.show("Uploading",e,function(){o(e,e[0])})},url:function(){vare,t=album.getID();t===!1&&(t=0),e=function(e){varn,o=[];if(e.link&&e.link.length>3){if(basicModal.close(),n=e.link.split(".").pop(),"jpeg"!==n&&"jpg"!==n&&"png"!==n&&"gif"!==n&&"webp"!==n)returnloadingBar.show("error","The file format of this link is not supported."),!1;o[0]={name:e.link,supported:!0},upload.show("Importing URL",o,function(){varn;$(".basicModal .rows .row .status").html("Importing"),n={url:e.link,albumID:t},api.post("Import::url",n,function(e){basicModal.close(),upload.notify("Import complete"),albums.refresh(),album.getID()===!1?lychee["goto"]("0"):album.load(t),e!==!0&&lychee.error(null,n,e)})})}elsebasicModal.error("link")},basicModal.show({body:"<p>Please enter the direct link to a photo to import it: <input class='text' data-name='link' type='text' placeholder='http://' value=''></p>",buttons:{action:{title:"Import",fn:e},cancel:{title:"Cancel",fn:basicModal.close}}})},server:function(){vare,t=album.getID();t===!1&&(t=0),e=function(e){varn=[];n[0]={name:e.path,supported:!0},upload.show("Importing from server",n,function(){varn;$(".basicModal .rows .row .status").html("Importing"),n={albumID:t,path:e.path},api.post("Import::server",n,function(e){returnbasicModal.close(),upload.notify("Import complete"),albums.refresh(),"Notice: Import only contains albums!"===e?visible.albums()?lychee.load():lychee["goto"](""):album.getID()===!1?lychee["goto"]("0"):album.load(t),"Notice: Import only contains albums!"===e?!0:void("Warning: Folder empty!"===e?lychee.error("Folder empty. No photos imported!",n,e):e!==!0&&lychee.error(null,n,e))})})},basicModal.show({body:"<p>This action will import all photos, folders and sub-folders which are located in the following directory. The <b>original files will be deleted</b> after the import when possible. <input class='text' data-name='path' type='text' maxlength='100' placeholder='Absolute path to directory' value='"+lychee.location+"uploads/import/'></p>",buttons:{action:{title:"Import",fn:e},cancel:{title:"Cancel",fn:basicModal.close}}})},dropbox:function(){vare,t=album.getID(),n="";t===!1&&(t=0),e=function(e){for(varo=0;o<e.length;o++)n+=e[o].link+",",e[o]={name:e[o].link,supported:!0};n=n.substr(0,n.length-1),upload.show("Importing from Dropbox",e,function(){vare;$(".basicModal .rows .row .status").html("Importing"),e={url:n,albumID:t},api.post("Import::url",e,function(n){basicModal.close(),upload.notify("Import complete"),albums.refresh(),album.getID()===!1?lychee["goto"]("0"):album.load(t),n!==!0&&lychee.error(null,e,n)})})},lychee.loadDropbox(function(){Dropbox.choose({linkType:"direct",multiselect:!0,success:e})})}},view={},view.infobox={show:function(){visible.infobox()||$("body").append("<div id='infobox_overlay' class='fadeIn'></div>"),lychee.infobox.addClass("active")},hide:function(){lychee.animate("#infobox_overlay","fadeOut"),setTimeout(function(){$("#infobox_overlay").remove()},300),lychee.infobox.removeClass("active")}},view.albums={init:function(){view.albums.title(),view.albums.content.init()},title:function(){lychee.setTitle("Albums",!1)},content:{scrollPosition:0,init:function(){vare="",t="";lychee.publicMode===!1&&(albums.parse(albums.json.smartalbums.unsorted),albums.parse(albums.json.smartalbums["public"]),albums.parse(albums.json.smartalbums.starred),albums.parse(albums.json.smartalbums.recent),e=build.divider("Smart Albums")+build.album(albums.json.smartalbums.unsorted)+build.album(albums.json.smartalbums["public"])+build.album(albums.json.smartalbums.starred)+build.album(albums.json.smartalbums.recent)),albums.json.albums&&0!==albums.json.num&&($.each(albums.json.albums,function(){al