lychee/js/functions.js

1 line
29 KiB
JavaScript
Raw Normal View History

albums={load:function(){loadingBar.show();lychee.animate(".album, .photo","contentZoomOut");lychee.content.attr("data-search","");lychee.animate(".divider","fadeOut");startTime=(new Date).getTime();lychee.api("getAlbums","json",function(e){durationTime=(new Date).getTime()-startTime;if(durationTime>300)waitTime=0;else waitTime=300-durationTime;$.timer(waitTime,function(){$("#tools_album, #tools_photo").hide();$("#tools_albums").show();unsortedAlbum=new Object;unsortedAlbum.id=0;unsortedAlbum.title="Unsorted";unsortedAlbum.sysdate=e.unsortNum+" photos";unsortedAlbum.unsorted=1;if(e.unsortThumb0)unsortedAlbum.thumb0=lychee.upload_path+e.unsortThumb0;else unsortedAlbum.thumb0="";if(e.unsortThumb1)unsortedAlbum.thumb1=lychee.upload_path+e.unsortThumb1;else unsortedAlbum.thumb1="";if(e.unsortThumb2)unsortedAlbum.thumb2=lychee.upload_path+e.unsortThumb2;else unsortedAlbum.thumb2="";starredAlbum=new Object;starredAlbum.id="f";starredAlbum.title="Starred";starredAlbum.sysdate=e.starredNum+" photos";starredAlbum.star=1;if(e.starredThumb0)starredAlbum.thumb0=lychee.upload_path+e.starredThumb0;else starredAlbum.thumb0="";if(e.starredThumb1)starredAlbum.thumb1=lychee.upload_path+e.starredThumb1;else starredAlbum.thumb1="";if(e.starredThumb2)starredAlbum.thumb2=lychee.upload_path+e.starredThumb2;else starredAlbum.thumb2="";publicAlbum=new Object;publicAlbum.id="s";publicAlbum.title="Public";publicAlbum.sysdate=e.publicNum+" photos";publicAlbum.public=1;if(e.publicThumb0)publicAlbum.thumb0=lychee.upload_path+e.publicThumb0;else publicAlbum.thumb0="";if(e.publicThumb1)publicAlbum.thumb1=lychee.upload_path+e.publicThumb1;else publicAlbum.thumb1="";if(e.publicThumb2)publicAlbum.thumb2=lychee.upload_path+e.publicThumb2;else publicAlbum.thumb2="";smartData=build.divider("Smart Albums")+build.album(unsortedAlbum)+build.album(starredAlbum)+build.album(publicAlbum);if(e.albums){albumsData=build.divider("Albums");$.each(e.album,function(){albumsData+=build.album(this)})}else albumsData="";lychee.content.html(smartData+albumsData);lychee.animate(".album, .photo","contentZoomIn");document.title="Lychee";lychee.headerTitle.html("Albums").removeClass("editable");$("img").retina();loadingBar.hide()})})},loadInfo:function(e){if(e=="f"||e=="s"||e==0){lychee.headerTitle.removeClass("editable");lychee.api("getSmartInfo","json",function(t){switch(e){case"f":document.title="Lychee - Starred";lychee.headerTitle.html("Starred<span> - "+t.starredNum+" photos</span>");$("#button_edit_album, #button_trash_album, .button_divider").hide();break;case"s":document.title="Lychee - Public";lychee.headerTitle.html("Public<span> - "+t.publicNum+" photos</span>");$("#button_edit_album, #button_trash_album, .button_divider").hide();break;case"0":document.title="Lychee - Unsorted";lychee.headerTitle.html("Unsorted<span> - "+t.unsortNum+" photos</span>");$("#button_edit_album").hide();$("#button_trash_album, .button_divider").show();break}loadingBar.hide()})}else{params="getAlbumInfo&albumID="+e;lychee.api(params,"json",function(e){$("#button_edit_album, #button_trash_album, .button_divider").show();if(!e.title)e.title="Untitled";document.title="Lychee - "+e.title;lychee.headerTitle.html(e.title+"<span> - "+e.num+" photos</span>").addClass("editable");loadingBar.hide()})}},add:function(){title=prompt("Please enter a title for this album:","Untitled");lychee.closeModal();if(title.length>2&&title.length<31){loadingBar.show();params="addAlbum&title="+escape(title);lychee.api(params,"text",function(e){if(e)lychee.goto("a"+e);else loadingBar.show("error")})}else if(title.length>0)loadingBar.show("error","Error","Title to short or too long. Please try another one!")},hide:function(e){$(".album[data-id='"+e+"']").css("opacity",0).animate({width:0,marginLeft:0},300,function(){$(this).remove()})},"delete":function(e,t){loadingBar.show();params="deleteAlbum&albumID="+e+"&delAll="+t;lychee.api(params,"text",function(t){if(t){if(visible.albums()){albums.hide(e);loadingBar.hide()}else lychee.goto("")}else loadingBar.show("error")})},deleteDialog:function(e){if(e==0){f1="albums.delete