}).on(event_name,"#edit_tags",function(){photo.editTags([photo.getID()])}).on(event_name,"#tags .tag span",function(){photo.deleteTag(photo.getID(),$(this).data("index"))});Mousetrap.bind("u",function(){$("#upload_files").click()}).bind("s",function(){if(visible.photo())$("#button_star").click()}).bind("left",function(){if(visible.photo())$("#imageview a#previous").click()}).bind("right",function(){if(visible.photo())$("#imageview a#next").click()}).bind("command+backspace",function(){if(visible.photo()&&!visible.message())photo.delete([photo.getID()]);elseif(visible.album()&&!visible.message())album.delete([album.getID()])}).bind("i",function(){if(visible.infobox())view.infobox.hide();elseif(!visible.albums())view.infobox.show()});Mousetrap.bindGlobal("enter",function(){if($(".message .button.active").length)$(".message .button.active").addClass("pressed").click()});Mousetrap.bindGlobal(["esc","command+up"],function(e){e.preventDefault();if(visible.message()&&$(".message .close").length>0)modal.close();elseif(visible.contextMenu())contextMenu.close();elseif(visible.infobox())view.infobox.hide();elseif(visible.photo())lychee.goto(album.getID());elseif(visible.album())lychee.goto("");elseif(visible.albums()&&$("#search").val().length!==0)search.reset()});if(mobileBrowser()){$(document).on("touchend","#image",function(e){if(visible.controls())view.header.hide(e,0);elsee.preventDefault()})}$(document).on("keyup","#password",function(){if($(this).val().length>0)$(this).removeClass("error")}).on(event_name,"#title.editable",function(){if(visible.photo())photo.setTitle([photo.getID()]);elsealbum.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(event_name,".message .close",modal.close).on(event_name,".message .button:first",function(){if(modal.fns!==null)modal.fns[0]();if(!visible.signin())modal.close()}).on(event_name,".message .button:last",function(){if(modal.fns!==null)modal.fns[1]();if(!visible.signin())modal.close()}).on(event_name,".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(event_name,".contextmenu_bg",contextMenu.close).on("contextmenu",".contextmenu_bg",contextMenu.close).on(event_name,"#infobox_overlay",view.infobox.hide).on("dragover",function(e){e.preventDefault()},false).on("drop",function(e){e.stopPropagation();e.preventDefault();if(e.originalEvent.dataTransfer.files.length>0)upload.start.local(e.originalEvent.dataTransfer.files);elseif(e.originalEvent.dataTransfer.getData("Text").length>3)upload.start.url(e.originalEvent.dataTransfer.getData("Text"));returntrue});lychee.init()});loadingBar={status:null,show:function(status,errorText){if(status==="error"){loadingBar.status="error";if(!errorText)errorText="Whoops, it looks like something went wrong. Please reload the site and try again!";lychee.loadingBar.removeClass("loading uploading error").addClass(status).html("<h1>Error: <span>"+errorText+"</span></h1>").show().css("height","40px");if(visible.controls())lychee.header.addClass("error");clearTimeout(lychee.loadingBar.data("timeout"));lychee.loadingBar.data("timeout",setTimeout(function(){loadingBar.hide(true)},3e3))}elseif(loadingBar.status===null){loadingBar.status="loading";clearTimeout(lychee.loadingBar.data("timeout"));lychee.loadingBar.data("timeout",setTimeout(function(){lychee.loadingBar.show().removeClass("loading uploading error").addClass("loading");if(visible.controls())lychee.header.addClass("loading")},1e3))}},hide:function(force_hide){if(loadingBar.status!=="error"&&loadingBar.status!==null||force_hide){loadingBar.status=null;clearTimeout(lychee.loadingBar.data("timeout"));lychee.loadingBar.html("").css("height","3px");if(visible.controls())lychee.header.removeClass("error loading");setTimeout(function(){lyche
}elselychee.error(null,params,data)})}],["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+"'>",buttons)}};upload={show:function(icon,text){if(icon===undefined)icon="upload";upload.close(true);$("body").append(build.uploadModal(icon,text))},setIcon:function(icon){$(".upload_message a").remove();$(".upload_message").prepend("<a class='icon-"+icon+"'></a>")},setProgress:function(progress){$(".progressbar div").css("width",progress+"%")},setText:function(text){$(".progressbar").remove();$(".upload_message").append("<p>"+text+"</p>")},notify:function(title){varpopup;if(!window.webkitNotifications)returnfalse;if(window.webkitNotifications.checkPermission()!==0)window.webkitNotifications.requestPermission();if(window.webkitNotifications.checkPermission()===0&&title){popup=window.webkitNotifications.createNotification("",title,"You can now manage your new photo(s).");popup.show()}},start:{local:function(files){varpre_progress=0,formData=newFormData,xhr=newXMLHttpRequest,albumID=album.getID(),popup,progress;if(files.length<=0)returnfalse;if(albumID===false)albumID=0;formData.append("function","upload");formData.append("albumID",albumID);for(vari=0;i<files.length;i++){if(files[i].type!=="image/jpeg"&&files[i].type!=="image/jpg"&&files[i].type!=="image/png"&&files[i].type!=="image/gif"&&files[i].type!=="image/webp"){loadingBar.show("error","The file format of "+files[i].name+" is not supported.");returnfalse}else{formData.append(i,files[i])}}upload.show();window.onbeforeunload=function(){return"Lychee is currently uploading!"};xhr.open("POST",lychee.api_path);xhr.onload=function(){if(xhr.status===200){upload.close();upload.notify("Upload complete");window.onbeforeunload=null;if(album.getID()===false)lychee.goto("0");elsealbum.load(albumID)}};xhr.upload.onprogress=function(e){if(e.lengthComputable){progress=e.loaded/e.total*100|0;if(progress>pre_progress){upload.setProgress(progress);pre_progress=progress}if(progress>=100){upload.setIcon("cog");upload.setText("Processing photos")}}};$("#upload_files").val("");xhr.send(formData)},url:function(){varalbumID=album.getID(),params,extension,buttons;if(albumID===false)albumID=0;buttons=[["Import",function(){link=$(".message input.text").val();if(link&&link.length>3){extension=link.split(".").pop();if(extension!=="jpeg"&&extension!=="jpg"&&extension!=="png"&&extension!=="gif"&&extension!=="webp"){loadingBar.show("error","The file format of this link is not supported.");returnfalse}modal.close();upload.show("cog","Importing from URL");params="importUrl&url="+escape(encodeURI(link))+"&albumID="+albumID;lychee.api(params,function(data){upload.close();upload.notify("Import complete");if(album.getID()===false)lychee.goto("0");elsealbum.load(albumID);if(data!==true)lychee.error(null,params,data)})}elseloadingBar.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://'>",buttons)},server:function(){varalbumID=album.getID(),params,buttons;if(albumID===false)albumID=0;buttons=[["Import",function(){modal.close();upload.show("cog","Importing photos");params="importServer&albumID="+albumID;lychee.api(params,function(data){upload.close();upload.notify("Import complete");if(data==="Notice: Import only contains albums!"){if(visible.albums())lychee.load();elselychee.goto("")}elseif(album.getID()===false)lychee.goto("0");elsealbum.load(albumID);if(data==="Notice: Import only contains albums!")returntrue;elseif(data==="Warning: Folder empty!")lychee.error("Folder empty. No photos imported!",params,data);elseif(data!==true)lychee.error(null,params,data)})}],["Cancel",function(){}]];modal.s