elsephoto.setPublic(photo.getID(),e)});$("#button_share_album").on(event_name,function(e){if(album.json.public==1)contextMenu.shareAlbum(album.getID(),e);elsemodal.show("Share Album","All photos inside this album will be public and visible for everyone. Existing public photos will have the same sharing permission as this album. Are your sure you want to share this album? <input class='text' type='password' placeholder='password (optional)' value=''>",[["Share Album",function(){album.setPublic(album.getID(),e)}],["Cancel",function(){}]])});$("#button_more").on(event_name,function(e){contextMenu.photoMore(photo.getID(),e)});$("#button_trash_album").on(event_name,function(){album.delete([album.getID()])});$("#button_move").on(event_name,function(e){contextMenu.move([photo.getID()],e)});$("#button_trash").on(event_name,function(){photo.delete([photo.getID()])});$("#button_info_album").on(event_name,function(){view.infobox.show()});$("#button_info").on(event_name,function(){view.infobox.show()});$("#button_archive").on(event_name,function(){album.getArchive(album.getID())});$("#button_star").on(event_name,function(){photo.setStar([photo.getID()])});$("#search").on("keyup click",function(){search.find($(this).val())});$("#clearSearch").on(event_name,function(){$("#search").focus();search.reset()});$("#button_back_home").on(event_name,function(){lychee.goto("")});$("#button_back").on(event_name,function(){lychee.goto(album.getID())});lychee.imageview.on(event_name,".arrow_wrapper.previous",function(){if(album.json&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].previousPhoto!=="")lychee.goto(album.getID()+"/"+album.json.content[photo.getID()].previousPhoto)}).on(event_name,".arrow_wrapper.next",function(){if(album.json&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].nextPhoto!=="")lychee.goto(album.getID()+"/"+album.json.content[photo.getID()].nextPhoto)});$("#infobox").on(event_name,".header a",function(){view.infobox.hide()}).on(event_name,"#edit_title_album",function(){album.setTitle([album.getID()])}).on(event_name,"#edit_description_album",function(){album.setDescription(album.getID())}).on(event_name,"#edit_title",function(){photo.setTitle([photo.getID()])}).on(event_name,"#edit_description",function(){photo.setDescription(photo.getID())}).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(swipe.obj!==null&&(swipe.offset<=-5||swipe.offset>=5))returnfalse;if(visible.controls())view.header.hide(e,0);elseview.header.show()})}if(mobileBrowser()){$(document).swipe().on("swipeStart",function(e){swipe.start($("#image"))}).on("swipeMove",function(e){swipe.move(e.swipe)}).on("swipeEnd",function(e){swipe.stop(e.swipe,function(){if(album.json&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].p
},setLogin:function(){varold_password,username,password,params,buttons;buttons=[["Change Login",function(){old_password=$(".message input.text#old_password").val();username=$(".message input.text#username").val();password=$(".message input.text#password").val();if(old_password.length<1){loadingBar.show("error","Your old password was entered incorrectly. Please try again!");returnfalse}if(username.length<1){loadingBar.show("error","Your new username was entered incorrectly. Please try again!");returnfalse}if(password.length<1){loadingBar.show("error","Your new password was entered incorrectly. Please try again!");returnfalse}params="setLogin&oldPassword="+hex_md5(old_password)+"&username="+escape(username)+"&password="+hex_md5(password);lychee.api(params,function(data){if(data!==true)lychee.error(null,params,data)})}],["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=''>",buttons,-171)},setSorting:function(){varbuttons,sorting;buttons=[["Change Sorting",function(){sorting[0]=$("select#settings_type").val();sorting[1]=$("select#settings_order").val();params="setSorting&type="+sorting[0]+"&order="+sorting[1];lychee.api(params,function(data){if(data===true){lychee.sorting="ORDER BY "+sorting[0]+" "+sorting[1];lychee.load()}elselychee.error(null,params,data)})}],["Cancel",function(){}]];modal.show("Change Sorting","Sort photos by <select id='settings_type'> <option value='id'>Upload Time</option> <option value='take'>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. ",buttons);if(lychee.sorting!==""){sorting=lychee.sorting.replace("ORDER BY ","").split(" ");if(sorting[0]==='UNIX_TIMESTAMP(STR_TO_DATE(CONCAT(takedate,"-",taketime),"%d.%m.%Y-%H:%i:%S"))')sorting[0]="take";$("select#settings_type").val(sorting[0]);$("select#settings_order").val(sorting[1])}},setDropboxKey:function(callback){varbuttons,params,key;buttons=[["Set Key",function(){key=$(".message input.text#key").val();params="setDropboxKey&key="+key;lychee.api(params,function(data){if(data===true){lychee.dropboxKey=key;if(callback)lychee.loadDropbox(callback)}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)}};swipe={obj:null,tolerance:150,offset:0,start:function(obj,tolerance){console.log("start with "+obj);if(obj)swipe.obj=obj;if(tolerance)swipe.tolerance=tolerance;returntrue},move:function(e){console.log(e);swipe.offset=-1*e.x;swipe.obj.css({WebkitTransform:"translateX("+swipe.offset+"px)",MozTransform:"translateX("+swipe.offset+"px)",transform:"translateX("+swipe.offset+"px)"})},stop:function(e,left,right){console.log("stop with "+e.x);if(e.x<=-swipe.tolerance)left();elseif(e.x>=swipe.tolerance)right();else{console.log("reset");swipe.obj.css({WebkitTransform:"translateX(0px)",MozTransform:"translateX(0px)",transform:"translateX(0px)"})}swipe.obj=null;swipe.offset=0}};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();$