lychee/dist/main.js

6 lines
168 KiB
JavaScript
Raw Normal View History

function gup(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t="[\\?&]"+e+"=([^&#]*)",n=new RegExp(t),o=n.exec(window.location.href);return null===o?"":o[1]}!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=e.length,n=J.type(e);return"function"===n||J.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function o(e,t,n){if(J.isFunction(t))return J.grep(e,function(e,o){return!!t.call(e,o,e)!==n});if(t.nodeType)return J.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(rt.test(t))return J.filter(t,e,n);t=J.filter(t,e)}return J.grep(e,function(e){return z.call(t,e)>=0!==n})}function i(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function a(e){var t=ft[e]={};return J.each(e.match(ht)||[],function(e,n){t[n]=!0}),t}function s(){Z.removeEventListener("DOMContentLoaded",s,!1),e.removeEventListener("load",s,!1),J.ready()}function r(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=J.expando+r.uid++}function l(e,t,n){var o;if(void 0===n&&1===e.nodeType)if(o="data-"+t.replace(wt,"-$1").toLowerCase(),n=e.getAttribute(o),"string"==typeof n){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)}else n=void 0;return n}function u(){return!0}function c(){return!1}function d(){try{return Z.activeElement}catch(e){}}function p(e,t){return J.nodeName(e,"table")&&J.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function h(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function f(e){var t=Lt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function m(e,t){for(var n=0,o=e.length;o>n;n++)gt.set(e[n],"globalEval",!t||gt.get(t[n],"globalEval"))}function b(e,t){var n,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)){delete s.handle,s.events={};for(i in u)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))}}function g(e,t){var n=e.getElementsByTagName?e.getElementsByTagName(t||"*"):e.querySelectorAll?e.querySelectorAll(t||"*"):[];return void 0===t||t&&J.nodeName(e,t)?J.merge([e],n):n}function v(e,t){var n=t.nodeName.toLowerCase();"input"===n&&Mt.test(e.type)?t.checked=e.checked:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}function y(t,n){var o,i=J(n.createElement(t)).appendTo(n.body),a=e.getDefaultComputedStyle&&(o=e.getDefaultComputedStyle(i[0]))?o.display:J.css(i[0],"display");return i.detach(),a}function w(e){var t=Z,n=Ot[e];return n||(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()),Ot[e]=n),n}function x(e,t,n){var o,i,a,s,r=e.style;return n=n||Bt(e),n&&(s=n.getPropertyValue(t)||n[t]),n&&(""!==s||J.contains(e.ownerDocument,e)||(s=J.style(e,t)),Ut.test(s)&&Rt.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)),void 0!==s?s+"":s}function T(e,t){return{get:function(){return e()?void delete this.get:(this.get=t).apply(this,arguments)}}}function j(e,t){if(t in e)return t;for(var n=t[0].toUpperCase()+t.slice(1),o=t,i=Vt.length;i--;)if(t=Vt[i]+n,t in e)return t;return o}function M(e,t,n){var o=Xt.exec(t);return o?Math.max(0,o[1]-(n||0))+(o[2]||"px"):t}function k(e,t,n,o,i){for(var a=n===(o?"border":"content")?4:"width"===t?1:0,s=0;4>a;a+=2)"margin"===n&&(s+=J.css(e,n+Tt[a],!0,i)),o?("content"===n&&(s-=J.css(e,"padding"+Tt[a],!0,i)),"margin"!==n&&(s-=J.css(e,"border"+Tt[a]+"Width",!0,i))):(s+=J.css(e,"padding"+Tt[a],!0,i),"padding"!==n&&(s+=J.css(e,"border"+Tt[a]+"Width",!0,i)));return s}function C(e,t,n){var o=!0,i="width"===t?e.
}))},J.fn.extend({find:function(e){var t,n=this.length,o=[],i=this;if("string"!=typeof e)return this.pushStack(J(e).filter(function(){for(t=0;n>t;t++)if(J.contains(i[t],this))return!0}));for(t=0;n>t;t++)J.find(e,i[t],o);return o=this.pushStack(n>1?J.unique(o):o),o.selector=this.selector?this.selector+" "+e:e,o},filter:function(e){return this.pushStack(o(this,e||[],!1))},not:function(e){return this.pushStack(o(this,e||[],!0))},is:function(e){return!!o(this,"string"==typeof e&&at.test(e)?J(e):e||[],!1).length}});var lt,ut=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,ct=J.fn.init=function(e,t){var n,o;if(!e)return this;if("string"==typeof e){if(n="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:ut.exec(e),!n||!n[1]&&t)return!t||t.jquery?(t||lt).find(e):this.constructor(t).find(e);if(n[1]){if(t=t instanceof J?t[0]:t,J.merge(this,J.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:Z,!0)),st.test(n[1])&&J.isPlainObject(t))for(n in t)J.isFunction(this[n])?this[n](t[n]):this.attr(n,t[n]);return this}return o=Z.getElementById(n[2]),o&&o.parentNode&&(this.length=1,this[0]=o),this.context=Z,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):J.isFunction(e)?"undefined"!=typeof lt.ready?lt.ready(e):e(J):(void 0!==e.selector&&(this.selector=e.selector,this.context=e.context),J.makeArray(e,this))};ct.prototype=J.fn,lt=J(Z);var dt=/^(?:parents|prev(?:Until|All))/,pt={children:!0,contents:!0,next:!0,prev:!0};J.extend({dir:function(e,t,n){for(var o=[],i=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(i&&J(e).is(n))break;o.push(e)}return o},sibling:function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}}),J.fn.extend({has:function(e){var t=J(e,this),n=t.length;return this.filter(function(){for(var e=0;n>e;e++)if(J.contains(this,t[e]))return!0})},closest:function(e,t){for(var n,o=0,i=this.length,a=[],s=at.test(e)||"string"!=typeof e?J(e,t||this.context):0;i>o;o++)for(n=this[o];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(s?s.index(n)>-1:1===n.nodeType&&J.find.matchesSelector(n,e))){a.push(n);break}return this.pushStack(a.length>1?J.unique(a):a)},index:function(e){return e?"string"==typeof e?z.call(J(e),this[0]):z.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(J.unique(J.merge(this.get(),J(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),J.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return J.dir(e,"parentNode")},parentsUntil:function(e,t,n){return J.dir(e,"parentNode",n)},next:function(e){return i(e,"nextSibling")},prev:function(e){return i(e,"previousSibling")},nextAll:function(e){return J.dir(e,"nextSibling")},prevAll:function(e){return J.dir(e,"previousSibling")},nextUntil:function(e,t,n){return J.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return J.dir(e,"previousSibling",n)},siblings:function(e){return J.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return J.sibling(e.firstChild)},contents:function(e){return e.contentDocument||J.merge([],e.childNodes)}},function(e,t){J.fn[e]=function(n,o){var i=J.map(this,t,n);return"Until"!==e.slice(-5)&&(o=n),o&&"string"==typeof o&&(i=J.filter(o,i)),this.length>1&&(pt[e]||J.unique(i),dt.test(e)&&i.reverse()),this.pushStack(i)}});var ht=/\S+/g,ft={};J.Callbacks=function(e){e="string"==typeof e?ft[e]||a(e):J.extend({},e);var t,n,o,i,s,r,l=[],u=!e.once&&[],c=function(a){for(t=e.memory&&a,n=!0,r=i||0,i=0,s=l.length,o=!0;l&&s>r;r++)if(l[r].apply(a[0],a[1])===!1&&e.stopOnFalse){t=!1;break}o=!1,l&&(u?u.length&&c(u.shift()):t?l=[]:d.disable())},d={add:function(){if(l){var n=l.length;!function a(t){J.each(t,function(t,n){var o=J.type(n);"function"===o?e.unique&&d.has(n)||l.push(n):n&&n.length&&"string"!==o&&a(n)})}(arguments),o?s=l.length:t&&(i=n,c(t))}return this},remove:function(){return l&&J.each(arguments,function(e,t){for(var n;(n=J.inArray(t,l,n))>-1;)l.splice(n,1),o&&(s>=n&&s--,r>=n&&r--)}),this},has:function(e){return e?J.i
for(n.finish=!0,J.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=a.length;t--;)a[t].elem===this&&a[t].queue===e&&(a[t].anim.stop(!0),a.splice(t,1));for(t=0;s>t;t++)o[t]&&o[t].finish&&o[t].finish.call(this);delete n.finish})}}),J.each(["toggle","show","hide"],function(e,t){var n=J.fn[t];J.fn[t]=function(e,o,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(S(t,!0),e,o,i)}}),J.each({slideDown:S("show"),slideUp:S("hide"),slideToggle:S("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){J.fn[e]=function(e,n,o){return this.animate(t,e,n,o)}}),J.timers=[],J.fx.tick=function(){var e,t=0,n=J.timers;for(Gt=J.now();t<n.length;t++)e=n[t],e()||n[t]!==e||n.splice(t--,1);n.length||J.fx.stop(),Gt=void 0},J.fx.timer=function(e){J.timers.push(e),e()?J.fx.start():J.timers.pop()},J.fx.interval=13,J.fx.start=function(){Zt||(Zt=setInterval(J.fx.tick,J.fx.interval))},J.fx.stop=function(){clearInterval(Zt),Zt=null},J.fx.speeds={slow:600,fast:200,_default:400},J.fn.delay=function(e,t){return e=J.fx?J.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var o=setTimeout(t,e);n.stop=function(){clearTimeout(o)}})},function(){var e=Z.createElement("input"),t=Z.createElement("select"),n=t.appendChild(Z.createElement("option"));e.type="checkbox",G.checkOn=""!==e.value,G.optSelected=n.selected,t.disabled=!0,G.optDisabled=!n.disabled,e=Z.createElement("input"),e.value="t",e.type="radio",G.radioValue="t"===e.value}();var on,an,sn=J.expr.attrHandle;J.fn.extend({attr:function(e,t){return bt(this,J.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){J.removeAttr(this,e)})}}),J.extend({attr:function(e,t,n){var o,i,a=e.nodeType;return e&&3!==a&&8!==a&&2!==a?typeof e.getAttribute===kt?J.prop(e,t,n):(1===a&&J.isXMLDoc(e)||(t=t.toLowerCase(),o=J.attrHooks[t]||(J.expr.match.bool.test(t)?an:on)),void 0===n?o&&"get"in o&&null!==(i=o.get(e,t))?i:(i=J.find.attr(e,t),null==i?void 0:i):null!==n?o&&"set"in o&&void 0!==(i=o.set(e,n,t))?i:(e.setAttribute(t,n+""),n):void J.removeAttr(e,t)):void 0},removeAttr:function(e,t){var n,o,i=0,a=t&&t.match(ht);if(a&&1===e.nodeType)for(;n=a[i++];)o=J.propFix[n]||n,J.expr.match.bool.test(n)&&(e[o]=!1),e.removeAttribute(n)},attrHooks:{type:{set:function(e,t){if(!G.radioValue&&"radio"===t&&J.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}}}),an={set:function(e,t,n){return t===!1?J.removeAttr(e,n):e.setAttribute(n,n),n}},J.each(J.expr.match.bool.source.match(/\w+/g),function(e,t){var n=sn[t]||J.find.attr;sn[t]=function(e,t,o){var i,a;return o||(a=sn[t],sn[t]=i,i=null!=n(e,t,o)?t.toLowerCase():null,sn[t]=a),i}});var rn=/^(?:input|select|textarea|button)$/i;J.fn.extend({prop:function(e,t){return bt(this,J.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[J.propFix[e]||e]})}}),J.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(e,t,n){var o,i,a,s=e.nodeType;return e&&3!==s&&8!==s&&2!==s?(a=1!==s||!J.isXMLDoc(e),a&&(t=J.propFix[t]||t,i=J.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(o=i.set(e,n,t))?o:e[t]=n:i&&"get"in i&&null!==(o=i.get(e,t))?o:e[t]):void 0},propHooks:{tabIndex:{get:function(e){return e.hasAttribute("tabindex")||rn.test(e.nodeName)||e.href?e.tabIndex:-1}}}}),G.optSelected||(J.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null}}),J.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){J.propFix[this.toLowerCase()]=this});var ln=/[\t\r\n\f]/g;J.fn.extend({addClass:function(e){var t,n,o,i,a,s,r="string"==typeof e&&e,l=0,u=this.length;if(J.isFunction(e))return this.each(function(t){J(this).addClass(e.call(this,t,this.className))});if(r)for(t=(e||"").match(ht)||[];u>l;l++)if(n=this[l],o=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(ln," "):" ")){for(a=0;i=t[a++];)o.indexOf(" "+i+" ")<0&&(o+=i+" ");s=J.trim(o),n.className!==s&&(n.className=s)}return this},remo
2015-04-01 20:20:28 +00:00
},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,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/((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:s,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},album.getID=function(){var e=null,t=function(e){return"0"===e||"f"===e||"s"===e||"r"===e?!0:$.isNumeric(e)};return photo.json?e=photo.json.album:album.json&&(e=album.json.id),t(e)===!1&&(e=$(".album:hover, .album.active").attr("data-id")),t(e)===!1&&(e=$(".photo:hover, .photo.active").attr("data-album-id")),t(e)===!0?e:!1},album.load=function(e,t){var n,o,i,a;password.get(e,function(){t||lychee.animate("#content","contentZoomOut"),n=(new Date).getTime(),o={albumID:e,password:password.value},api.post("Album::get",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:300-i,t===!0&&(a=0),visible.albums()||visible.photo()||visible.album()||(a=0),void setTimeout(function(){view.album.init(),t||(lychee.animate("#content","contentZoomIn"),header.setMode("album"))},a))})})},album.parse=function(){album.json.title||(album.json.title="Untitled")},album.add=function(){var e;e=function(e){var t,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){var t={},n={},o="",i="";return e?(e instanceof Array==!1&&(e=[e]),t.fn=function(){var t;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),delete albums.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="Delete Albums and Photos",n.title="Keep Albums",o="<p>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!</p>"),void basicModal.show({body:o,buttons:{action:{title:t.title,fn:t.fn,"class":"red"},cancel:{title:n.title,fn:basicModal.close}}})):!1},album.setTitle=function(e){var t,n="",o="",i="";return e?(e instanceof Array==!1&&(e=[e]),1===e.length&&(album.json?n=album.json.title:albums.json&&(n=albums.json.albums[e].title),n||(n=""),n=n.replace("'","&apos;")),t=function(t){var n,o=t.title;if(basicModal.close(),o=lychee.removeHTML(o),o=""===o?"Untitled":o,visible.album()){if(album.json.title=o,view.album.title(),albums.json){var i=e[0];albums.json.albums[i].title=o}}else visible.albums()&&e.forEach(function(e){albums.json.albums[e].title=o,view.albums.content.title(e)});n={albumIDs:e.join(),title:o},api.post("Album::setTitle",n,function(e){e!==
},lychee.logout=function(){api.post("Session::logout",{},function(){window.location.reload()})},lychee["goto"]=function(e){e=void 0===e?"#":"#"+e,history.pushState(null,null,e),lychee.load()},lychee.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?(photo.json=null,(""===lychee.content.html()||$("#search").length&&0!==$("#search").val().length)&&(lychee.content.hide(),album.load(e,!0)),photo.load(t,e)):e?(photo.json=null,visible.photo()&&view.photo.hide(),album.json&&e==album.json.id?view.album.title():album.load(e)):(null!==search.hash&&(albums.json=null,search.hash=null),album.json=null,photo.json=null,visible.photo()&&view.photo.hide(),visible.sidebar()&&sidebar.toggle(),albums.load())},lychee.getUpdate=function(){$.ajax({url:lychee.update_path,success:function(e){parseInt(e)>parseInt(lychee.version_code)&&$(".version span").show()}})},lychee.setTitle=function(e,t){document.title=lychee.title+" - "+e,header.setEditable(t),header.setTitle(e)},lychee.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).off("click","#title.editable").off("touchend","#title.editable").off("contextmenu",".photo").off("contextmenu",".album").off("drop"),Mousetrap.unbind("u").unbind("s").unbind("f").unbind("r").unbind("d").unbind("t").unbind(["command+backspace","ctrl+backspace"]).unbind(["command+a","ctrl+a"]),"public"===e?(header.dom("#button_signin, #hostedwith").show(),lychee.publicMode=!0):"view"===e&&(Mousetrap.unbind(["esc","command+up"]),$("#button_back, a#next, a#previous").remove(),$(".no_content").remove(),lychee.publicMode=!0,lychee.viewMode=!0)},lychee.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},lychee.escapeHTML=function(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},lychee.retinize=function(){var e=void 0===arguments[0]?"":arguments[0],t=window.devicePixelRatio,n=e.split(".").pop();return void 0!==t&&t>1&&"svg"!==n?(e=e.replace(/\.[^/.]+$/,""),e=e+"@2x."+n,{path:e,retina:!0}):{path:e,retina:!1}},lychee.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)},lychee.removeHTML=function(e){var t=document.createElement("DIV");return t.innerHTML=e,t.textContent||t.innerText},lychee.error=function(e,t,n){console.error({description:e,params:t,response:n}),loadingBar.show("error",e)},multiselect={},multiselect.position={top:null,right:null,bottom:null,left:null},multiselect.bind=function(){return $("#content").on("mousedown",function(e){1===e.which&&multiselect.show(e)}),$(document).on("mouseup",function(e){1===e.which&&multiselect.getSelection(e)}),!0},multiselect.show=function(e){return lychee.publicMode?!1:visible.search()?!1:visible.albums()||visible.album?0!==$(".album:hover, .photo:hover").length?!1:(visible.multiselect()&&$("#multiselect").remove(),sidebar.setSelectable(!1),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,multi
i.num+1>4&&(n=40*(i.num+1-4)),$(".basicModal .rows").scrollTop(n),$(".basicModal .rows .row:nth-child("+(i.num+1)+") .status").html("Processing"),null!==i.next&&o(e,i.next)}},s.send(a)});if(e.length<=0)return!1;(t===!1||visible.albums()===!0)&&(t=0);for(var i=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(){var e,t=album.getID();t===!1&&(t=0),e=function(e){var n,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)return loadingBar.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(){var n;$(".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)})})}else basicModal.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(){var e,t=album.getID();t===!1&&(t=0),e=function(e){var n=[];n[0]={name:e.path,supported:!0},upload.show("Importing from server",n,function(){var n;$(".basicModal .rows .row .status").html("Importing"),n={albumID:t,path:e.path},api.post("Import::server",n,function(e){return basicModal.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(){var e,t=album.getID(),n="";t===!1&&(t=0),e=function(e){for(var o=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(){var e;$(".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.albums={init:function(){view.albums.title(),view.albums.content.init()},title:function(){lychee.setTitle("Albums",!1)},content:{scrollPosition:0,init:function(){var e="",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(){albums.parse(this),t=build.album(this)+t}),lychee.publicMode===!1&&(t=build.divider("Albums")+t)),""===e&&""===t?(lychee.content.html(""),$(