You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lychee/js/functions.js

1 line
37 KiB

album={json:null,getID:function(){var e;if(photo.json)e=photo.json.album;else if(album.json)e=album.json.id;else e=$(".album:hover, .album.active").attr("data-id");if(!e)e=$(".photo:hover, .photo.active").attr("data-album-id");if(e)return e;else return false},load:function(e,t){var n,r,i,s,o="";password.get(e,function(){if(!t){loadingBar.show();lychee.animate(".album, .photo","contentZoomOut");lychee.animate(".divider","fadeOut")}n=(new Date).getTime();r="getAlbum&albumID="+e+"&password="+password.value;lychee.api(r,"json",function(r){if(r=="HTTP/1.1 403 Album private!"){lychee.setMode("view");return false}if(r=="HTTP/1.1 403 Wrong password!"){album.load(e,t);return false}album.json=r;i=(new Date).getTime()-n;if(i>300)s=0;else if(t)s=0;else s=300-i;if(!visible.albums()&&!visible.photo()&&!visible.album())s=0;setTimeout(function(){view.album.init();if(!t){lychee.animate(".album, .photo","contentZoomIn");view.header.mode("album")}},s)})})},parse:function(e){if(e&&e.thumbUrl)e.thumbUrl=lychee.upload_path_thumb+e.thumbUrl;else if(!album.json.title)album.json.title="Untitled"},add:function(){var e=prompt("Please enter a title for this album:","Untitled"),t;if(e.length>0&&e.length<31){modal.close();t="addAlbum&title="+escape(encodeURI(e));lychee.api(t,"text",function(e){if(e)lychee.goto("a"+e);else loadingBar.show("error")})}else if(e.length>0)loadingBar.show("error","Error","Title to short or too long. Please try another one!")},"delete":function(e){var t,n,r;n=[["Delete Album and Photos",function(){t="deleteAlbum&albumID="+e+"&delAll=true";lychee.api(t,"text",function(t){if(visible.albums())view.albums.content.delete(e);else lychee.goto("");if(!t)loadingBar.show("error")})}],["Keep Album",function(){}]];if(e==0){n[0][0]="Clear Unsorted";modal.show("Clear Unsorted","Are you sure you want to delete all photos from 'Unsorted'?<br>This action can't be undone!",n)}else{if(album.json)r=album.json.title;else if(albums.json)r=albums.json.content[e].title;modal.show("Delete Album","Are you sure you want to delete the album '"+r+"' and all of the photos it contains? This action can't be undone!",n)}},setTitle:function(e){var t="",n,r;if(!e)e=album.getID();if(album.json)t=album.json.title;else if(albums.json)t=albums.json.content[e].title;n=prompt("Please enter a new title for this album:",t);if(e!=""&&e!=null&&e&&n.length>0&&n.length<31){if(visible.album()){album.json.title=n;view.album.title()}else if(visible.albums()){albums.json.content[e].title=n;view.albums.content.title(e)}r="setAlbumTitle&albumID="+e+"&title="+escape(encodeURI(n));lychee.api(r,"text",function(e){if(!e)loadingBar.show("error")})}else if(n.length>0)loadingBar.show("error","Error","New title to short or too long. Please try another one!")},setPublic:function(e,t){var n;if($("input.password").length>0&&$("input.password").val().length>0){n="setAlbumPublic&albumID="+e+"&password="+hex_md5($("input.password").val());album.json.password=true}else{n="setAlbumPublic&albumID="+e;album.json.password=false}if(visible.album()){album.json.public=album.json.public==0?1:0;view.album.public();if(album.json.public==1)contextMenu.shareAlbum(e,t)}lychee.api(n,"text",function(e){if(!e)loadingBar.show("error")})},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("Hi! Check this out: "+n);break;default:t="";break}if(t.length>5)location.href=t},getArchive:function(e){var t;if(location.href.indexOf("index.html")>0)t=location.href.replace(location.hash,"").replace("index.html","php/api.php?function=getAlbumArchive&albumID="+e);else t=location.href.replace(location.hash,"")+"php/api.php?function=getAlbumArchive&albumID="+e;location.href=t}};albums={json:null,load:function(){var e,t,n,r,i,s="",o="";lychee.animate(".album, .photo","contentZoomOut");lychee.animate(".divider","fadeOut");e=(new Date).getTime();lychee.api("getAlbums","json",function(n){n.u