diff --git a/css/style.css b/css/style.css index ef59421..9c805ff 100755 --- a/css/style.css +++ b/css/style.css @@ -25,10 +25,10 @@ html, body { body { background-color: #222; background-image: url(../img/background.jpg); font-family:'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; -webkit-font-smoothing: antialiased; } .center { left: 50%; top:50%; position: absolute; } * { - -webkit-transition: opacity .3s ease-out, -webkit-transform .3s ease-out, box-shadow .3s; + -webkit-transition: color .3s, opacity .3s ease-out, -webkit-transform .3s ease-out, box-shadow .3s; -moz-transition: opacity .3s ease-out, -moz-transform .3s ease-out, box-shadow .3s; -o-transition: opacity .3s ease-out, -o-transform .3s ease-out, box-shadow .3s; - transition: opacity .3s ease-out, transform .3s ease-out, box-shadow .3s; + transition: color .3s, opacity .3s ease-out, transform .3s ease-out, box-shadow .3s; } /* Tooltip ------------------------------------------------*/ @@ -193,6 +193,7 @@ body { background-color: #222; background-image: url(../img/background.jpg); fon background-color: #2f0d0e; background-repeat: repeat-x; z-index: 1; + display: none; /* Animation */ -webkit-animation-name: moveBackground; @@ -235,7 +236,7 @@ body { background-color: #222; background-image: url(../img/background.jpg); fon /* Header ------------------------------------------------*/ header { position: fixed; - height: 40px; + height: 41px; width: 100%; background-color: #333; @@ -279,7 +280,7 @@ header { position: absolute; margin: 0px 30%; width: 40%; - margin-top: 11px; + padding: 11px 0px; color: #fff; font-size: 16px; font-weight: bold; @@ -345,23 +346,17 @@ header { font-family: 'FontAwesome'; font-size: 16px; } - #tools_albums, #tools_album, #tools_photo { + #tools_albums, #tools_album, #tools_photo, #button_signin { display: none; } - /* Button Custom ------------------------------------------------*/ - header .button.icon-refresh { - padding: 7px 10px 4px 10px; - } - /* Button Divider ------------------------------------------------*/ header .button_divider { float: right; position: relative; - margin-right: 11px; - margin-top: 1px; + margin: 1px 12px 0px 0px; width: 1px; - height: 39px; + height: 40px; background-color: transparent; background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(68, 68, 68)), to(rgb(37, 37, 37))); background-image: -webkit-linear-gradient(top, rgba(68, 68, 68, 0), rgb(25, 25, 25)); @@ -372,7 +367,7 @@ header { border-right: 1px solid #555; } header .button_divider.less { - margin-right: 8px; + margin: 1px 6px 0px 6px; } @@ -380,7 +375,7 @@ header { #search { float: right; width: 80px; - margin: 7px 8px 0px 0px; + margin: 7px 12px 0px 0px; padding: 5px 10px 7px 10px; background-color: #444; color: #fff; @@ -398,31 +393,28 @@ header { #search:focus { box-shadow: 0px 1px 0px #555, inset 0px 0px 2px #333; opacity: 1; - width: 150px; + width: 140px; } /* Tools ------------------------------------------------*/ + .tools:first-of-type { + margin-right: 6px; + } .tools { float: right; - padding: 5px 5px 5px 5px; - margin: 5px 8px 0px 0px; - font-family: 'IconicStroke'; + padding: 10px 8px; color: #aaa; font-size: 21px; text-shadow: 0px -1px 0px #222; - border-radius: 3px; cursor: pointer; } - .tools a.list { - line-height: 21px; - } .tools:hover a { color: #fff; } .tools .icon-star { color: #f0ef77; } - .tools .icon-rss.active { + .tools .icon-share.active { color: #ff9737; } @@ -556,8 +548,13 @@ header { color: #fff; font-size: 24px; text-shadow: 0px 1px 0px #000; - font-family: 'IconicStroke'; - opacity: 0.9; + opacity: .9; + } + .album .badge.icon-star, .photo .badge.icon-star { + padding: 12px 8px 3px 8px; + } + .album .badge.icon-share, .photo .badge.icon-share { + padding: 12px 6px 3px 8px; } .album .badge::after, .photo .badge::after { content: ""; @@ -566,7 +563,6 @@ header { margin-left: -26px; width: 34px; height: 5px; - /* inset 0px 1px 1px rgba(0,0,0,.3); */ background: -moz-linear-gradient(top, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,1)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, rgba(0,0,0,1) 0%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */ @@ -580,12 +576,16 @@ header { margin-left: -28px; width: 36px; } + .album .badge.icon-share::after, .photo .badge.icon-share::after { + margin-left: -30px; + width: 38px; + } .album .badge.icon-reorder::after { margin-left: -30px; width: 38px; } .album .badge:nth-child(2n), .photo .badge:nth-child(2n) { - margin-left: 55px; + margin-left: 57px; } .album .badge.red, .photo .badge.red { background: #d64b4b; @@ -608,7 +608,7 @@ header { .divider { float: left; width: 100%; - height: 31px; + height: 32px; margin-top: 50px; opacity: 0; @@ -623,9 +623,10 @@ header { box-shadow: 0px 1px 0px #111, inset 0px 1px 0px rgba(255, 255, 255, .1); } .divider:first-child { - margin-top: 1px; + margin-top: 2px; } .divider h1 { + float: left; margin: 8px 0px 0px 30px; color: #fff; font-size: 14px; @@ -633,6 +634,29 @@ header { text-shadow: 0px -1px 0px #000; } + /* No Content ------------------------------------------------*/ + .no_content { + position: absolute; + top: 50%; + left: 50%; + height: 160px; + width: 180px; + margin-top: -80px; + margin-left: -90px; + padding-top: 20px; + color: rgba(20, 20, 20, 1); + text-shadow: 0px 1px 0px rgba(255, 255, 255, .05); + text-align: center; + } + + .no_content .icon { + font-size: 120px; + } + + .no_content p { + font-size: 18px; + } + /* Overlay ------------------------------------------------*/ .message_overlay { position: fixed; @@ -683,9 +707,6 @@ header { animation-timing-function: ease-out; animation-fill-mode: forwards; } - .message.add { - margin-top: -155px; - } .message h1 { float: left; width: 100%; @@ -698,13 +719,17 @@ header { } .message .close { position: absolute; - top: 10px; - right: 12px; + top: 0px; + right: 0px; + padding: 12px 14px 6px 7px; color: #aaa; font-size: 20px; text-shadow: 0px -1px 0px #111; cursor: pointer; } + .message .close:hover { + color: #fff; + } .message p { float: left; width: 90%; @@ -764,15 +789,21 @@ header { } /* Add Album ------------------------------------------------*/ + .message.add { + width: 588px; + margin-top: -152px; + margin-left: -294px; + } .add_album { float: left; display: inline-block; - width: 200px; + width: 150px; height: 200px; margin: 30px 0px 30px 30px; border-radius: 3px; border: 3px dashed #777; cursor: pointer; + text-align: center; -webkit-transition: border .3s; -moz-transition: border .3s; -o-transition: border .3s; @@ -782,15 +813,11 @@ header { border: 3px dashed #fff; } .add_album .icon { - margin: 55px 65px 0px 65px; + margin-top: 55px; color: #777; font-family: 'FontAwesome'; font-size: 80px; text-shadow: 0px 1px 2px #000; - -webkit-transition: color .3s; - -moz-transition: color .3s; - -o-transition: color .3s; - transition: color .3s; } .add_album:hover .icon { color: #fff; @@ -802,11 +829,6 @@ header { font-size: 14px; font-weight: bold; text-shadow: 0px 1px 0px #000; - text-align: center; - -webkit-transition: color .3s; - -moz-transition: color .3s; - -o-transition: color .3s; - transition: color .3s; } .add_album:hover a { color: #fff; @@ -853,8 +875,14 @@ header { color: #888; text-shadow: 0px -1px 0px #111; } + .message #version span { + display: none; + } + .message #version span a { + color: #888; + } - /* Sign in ------------------------------------------------*/ + /* Copy Link ------------------------------------------------*/ .copylink { float: left; width: 95%; @@ -1018,9 +1046,8 @@ header { text-shadow: 0px -1px 0px #000; } #infobox .header a { - position: absolute; - right: 15px; - margin: 10px 0px; + float: right; + padding: 10px 15px; color: #fff; font-size: 21px; font-weight: bold; @@ -1126,6 +1153,19 @@ header { background-image: -ms-linear-gradient(top, #6a84f2, #3959ef); background-image: linear-gradient(top, #6a84f2, #3959ef); } + .contextmenu tr.separator { + float: left; + height: 1px; + width: 100%; + background-color: #222; + box-shadow: 0px 1px 0px #555; + margin: 4px 0px 5px 0px; + cursor: inherit; + } + .contextmenu tr.separator:hover { + background-color: #222; + background-image: none; + } .contextmenu tr td { padding: 5px 20px 5px 10px; -webkit-transition: none; @@ -1287,10 +1327,7 @@ header { /* Screen behavior -------------------------------------------------*/ @media only screen and (max-width: 900px) { - #title { - margin: 11px 30% 0px 20%; - width: 50%; - } + #title { margin: 0px 30%; width: 50%; } #title.view { margin: 11px 20% 0px 20%; width: 60%; } #title span { display: none; } @@ -1302,10 +1339,10 @@ header { #button_move { display: none; } #button_archive { display: none; } - .center { - top: 0px; - left: 0px; - } + .center { top: 0px; left: 0px; } + + .album { margin: 40px 0px 0px 50px; } + .photo { margin: 40px 0px 0px 50px; } .message { position: fixed; @@ -1325,20 +1362,20 @@ header { animation-duration: .3s; } - .album { - margin: 40px 0px 0px 50px; - } - - .photo { - margin: 40px 0px 0px 50px; - } - .message.add { + width: 100%; margin-top: 0px; } .add_album { - margin: 30px 0px -10px 55px; + width: 88%; + height: 100px; + margin: 30px 5% -10px 5%; + } + + .add_album .icon { + margin-top: 18px; + font-size: 50px; } } \ No newline at end of file diff --git a/img/no_images.png b/img/no_images.png old mode 100644 new mode 100755 diff --git a/img/no_images@2x.png b/img/no_images@2x.png old mode 100644 new mode 100755 diff --git a/img/password.png b/img/password.png new file mode 100755 index 0000000..4d47bec Binary files /dev/null and b/img/password.png differ diff --git a/img/password@2x.png b/img/password@2x.png new file mode 100755 index 0000000..bde12a8 Binary files /dev/null and b/img/password@2x.png differ diff --git a/index.html b/index.html index f7cb81a..8fe45f7 100755 --- a/index.html +++ b/index.html @@ -31,6 +31,7 @@
Sign Out + Sign In @@ -38,21 +39,22 @@
Back -
+
+
Back
-
- -
-
+
+
+ +
diff --git a/js/functions.js b/js/functions.js index 051533a..b71fa10 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1 +1 @@ -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 - "+t.starredNum+" photos");$("#button_edit_album, #button_trash_album, .button_divider").hide();break;case"s":document.title="Lychee - Public";lychee.headerTitle.html("Public - "+t.publicNum+" photos");$("#button_edit_album, #button_trash_album, .button_divider").hide();break;case"0":document.title="Lychee - Unsorted";lychee.headerTitle.html("Unsorted - "+t.unsortNum+" photos");$("#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+" - "+e.num+" photos").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(0, true);";f2="";modal=build.modal("Clear Unsorted","Are you sure you want to delete all photos from 'Unsorted'?
This action can't be undone!",["Clear Unsorted","Keep Photos"],[f1,f2]);$("body").append(modal)}else{if(visible.albums())albumTitle=$(".album[data-id='"+e+"'] .overlay h1").html();else albumTitle=lychee.title();f1="albums.delete("+e+", true);";f2="albums.delete("+e+", false);";modal=build.modal("Delete Album","Are you sure you want to delete the album '"+albumTitle+"' and all of the photos it contains? This action can't be undone!",["Delete Album and Photos","Keep Photos"],[f1,f2]);$("body").append(modal)}},rename:function(e){if(!e)oldTitle=lychee.title();else oldTitle="";if(!e)e=lychee.content.attr("data-id");newTitle=prompt("Please enter a new title for this album:",oldTitle);if(e!=""&&e!=null&&e&&newTitle.length>2&&newTitle.length<31){loadingBar.show();params="setAlbumTitle&albumID="+e+"&title="+encodeURI(newTitle);lychee.api(params,"text",function(t){if(t){if(visible.albums())$(".album[data-id='"+e+"'] .overlay h1").html(newTitle);else{lychee.headerTitle.html(newTitle+""+$("#title span").html()+"");document.title="Lychee - "+newTitle}loadingBar.hide()}else loadingBar.show("error")})}else if(newTitle.length>0)loadingBar.show("error","Error","New title to short or too long. Please try another one!")},getArchive:function(){albumID=lychee.content.attr("data-id");if(location.href.indexOf("index.html")>0)link=location.href.replace(location.hash,"").replace("index.html","php/api.php?function=getAlbumArchive&albumID="+albumID);else link=location.href.replace(location.hash,"")+"php/api.php?function=getAlbumArchive&albumID="+albumID;location.href=link}};build={divider:function(e){return"

"+e+"

"},album:function(e){if(!e)return"";if(!e.thumb0)e.thumb0="img/no_images.png";if(!e.thumb1)e.thumb1="img/no_images.png";if(!e.thumb2)e.thumb2="img/no_images.png";if(!e.title)e.title="Untitled";if(e.title.length>18)e.title=e.title.substr(0,18)+"...";var t="";t+="
";t+="thumb";t+="thumb";t+="thumb";t+="
";t+="

"+e.title+"

";t+=""+e.sysdate+"";t+="
";if(e.star=="1")t+="";if(e.public=="1")t+="";if(e.unsorted=="1")t+="";t+="
";return t},photo:function(e){if(e=="")return"";if(!e.title)e.title="";if(!e.thumbUrl)e.thumbUrl="img/no_image.png";if(e.title.length>18)e.title=e.title.substr(0,18)+"...";var t="";t+="
";t+="thumb";t+="
";t+="

"+e.title+"

";t+=""+e.sysdate+"";t+="
";if(e.star=="1")t+="";if(e.public=="1")t+="";t+="
";return t},modal:function(e,t,n,r){var i="";i+="
";i+="
";i+="

"+e+"

";i+="";i+="

"+t+"

";$.each(n,function(e){if(e==0)i+=""+this+"";else i+=""+this+""});i+="
";i+="";i+="
";return i},addModal:function(){var e="";e+="
";e+="
";e+="

Add Album or Photo

";e+="";e+="
";e+="
";e+="Add new Album";e+="
";e+="
";e+="
";e+="Upload new Photo";e+="
";e+="
";e+="
";return e},signInModal:function(){var e="";e+="
";e+="
";e+="

Sign in

";e+="";e+="
Version "+lychee.version+"
";e+="Sign in";e+="
";e+="
";return e},uploadModal:function(){var e="";e+="
";e+="
";e+="";e+="
";e+="
";e+="
";return e},contextMenu:function(e){var t="";t+="
";t+="
";t+="";t+="";$.each(e,function(n){if(e[n][1].length!=0){t+=""}});t+="";t+="
"+e[n][0]+"
";t+="
";return t},infobox:function(e,t){var n="";n+="

About

";n+="
";if(e.public==1)e.public="Public";else e.public="Private";if(t==true)editTitleHTML="";else editTitleHTML="
";if(t==true)editDescriptionHTML="";else editDescriptionHTML="
";infos=[["","Basics"],["Name",e.title+editTitleHTML],["Uploaded",e.sysdate],["Description",e.description+editDescriptionHTML],["","Image"],["Size",e.size],["Format",e.type],["Resolution",e.width+" x "+e.height],["","Camera"],["Captured",e.takedate],["Make",e.make],["Type/Model",e.model],["Shutter Speed",e.shutter],["Aperture",e.aperture],["Focal Length",e.focal],["ISO",e.iso],["","Share"],["Privacy",e.public],["Short Link",e.shortlink]];$.each(infos,function(e){if(infos[e][1]==""||infos[e][1]==undefined||infos[e][1]==null)infos[e][1]="-";if(infos[e][0]==""){n+="";n+="

"+infos[e][1]+"

";n+=""}else{n+="";n+="";n+="";n+=""}});n+="
"+infos[e][0]+""+infos[e][1]+"
";n+="
";n+="
";return n}};contextMenu={album:function(e){e.preventDefault();mouse_x=e.pageX;mouse_y=e.pageY;albumID=$(this).attr("data-id");if(albumID=="0"||albumID=="f"||albumID=="s")return false;mouse_y-=$(document).scrollTop();items=[["Rename","albums.rename("+albumID+")"],["Delete","albums.deleteDialog("+albumID+")"]];contextMenu.close();$("body").css("overflow","hidden");$(".album[data-id='"+albumID+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:mouse_y,left:mouse_x})},photo:function(e){e.preventDefault();mouse_x=e.pageX;mouse_y=e.pageY;photoID=$(this).attr("data-id");mouse_y-=$(document).scrollTop();items=[["Rename","photos.rename("+photoID+")"],["Move to Album","contextMenu.move("+photoID+", "+(mouse_x+150)+", "+(mouse_y+$(document).scrollTop())+")"],["Delete","photos.deleteDialog("+photoID+")"]];contextMenu.close();$("body").css("overflow","hidden");$(".photo[data-id='"+photoID+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:mouse_y,left:mouse_x})},move:function(e,t,n){n-=$(document).scrollTop();lychee.api("getAlbums","json",function(r){if(lychee.content.attr("data-id")==0){items=[]}else{items=[["Unsorted","photos.move("+e+", 0)"]]}if(!r.albums){items=[["Create new Album","albums.add()"]]}else{$.each(r.album,function(t){if(this.id!=lychee.content.attr("data-id")){if(!this.title)this.title="Untitled";items[items.length]=new Array(this.title,"photos.move("+e+", "+this.id+")")}else{items[items.length]=new Array("","")}})}contextMenu.close();$("body").css("overflow","hidden");$(".photo[data-id='"+e+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:n,left:t-150})})},share:function(e,t,n){n-=$(document).scrollTop();items=[[" Make Private","photos.setPublic()"],[" Twitter","photos.share(0, "+e+")"],[" Facebook","photos.share(1, "+e+")"],[" Mail","photos.share(2, "+e+")"],[" Copy Link","photos.share(3, "+e+")"],[" Copy Shortlink","photos.share(4, "+e+")"]];contextMenu.close();$("body").css("overflow","hidden");$(".photo[data-id='"+e+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:n,left:t})},close:function(){$(".contextmenu_bg, .contextmenu").remove();$(".photo.active, .album.active").removeClass("active");$("body").css("overflow","scroll")}};loadingBar={show:function(e,t,n){if(!e)e="loading";switch(e){case"error":if(!t||!n){t="Error";n="Whoops, it looks like something went wrong. Please reload the site and try again!"}lychee.loadingBar.removeClass("loading uploading error").addClass(e).html("

"+t+": "+n+"

").show().css("height","40px");lychee.header.css("margin-Top","40px");$.timer(3e3,function(){loadingBar.hide()});break;case"loading":clearTimeout(lychee.loadingBar.data("timeout"));lychee.loadingBar.data("timeout",setTimeout(function(){lychee.loadingBar.show().removeClass("loading uploading error").addClass(e);if(visible.controls())lychee.header.css("margin-Top","3px")},1e3));break}},hide:function(){clearTimeout(lychee.loadingBar.data("timeout"));lychee.loadingBar.html("").css("height","3px");if(visible.controls())lychee.header.css("marginTop","0px");$.timer(300,function(){lychee.loadingBar.hide()})}};lychee={init:function(e,t){this.version="1.1";this.api_path=e;this.upload_path=t;this.loadingBar=$("#loading");this.header=$("header");this.headerTitle=$("#title");this.content=$("#content");this.image_view=$("#image_view");this.infobox=$("#infobox")},ready:function(){$("#tools_albums").show();if(!mobileBrowser())$(".tools").tipsy({gravity:"n"});if(window.webkitNotifications){window.webkitNotifications.requestPermission()}lychee.api("loggedIn","text",function(e){if(e!=1){$("body").append(build.signInModal());$("#username").focus();if(localStorage){local_username=localStorage.getItem("username");if(local_username==null)return false;if(local_username.length>1)$("#username").val(local_username);$("#password").focus()}}else if(e){$(window).bind("popstate",lychee.load);lychee.load()}})},api:function(e,t,n){$.ajax({type:"POST",url:lychee.api_path,data:"function="+e,dataType:t,success:n,error:lychee.error})},login:function(){user=$("input#username").val();password=hex_md5($("input#password").val());params="login&user="+user+"&password="+password;lychee.api(params,"text",function(e){if(e){if(localStorage){localStorage.setItem("username",user)}$(window).bind("popstate",lychee.load);lychee.load();lychee.closeModal()}else{$("#password").val("").addClass("error");$(".message .button.active").removeClass("pressed")}})},logout:function(){lychee.api("logout","text",function(e){window.location.reload()})},upload:function(e){pre_progress=0;$(".upload_overlay").remove();$("body").append(build.uploadModal());var t=new FormData;for(var n=0;npre_progress){$(".progressbar div").css("width",t+"%");pre_progress=t}if(t>=100)$(".progressbar div").css("opacity",.2)}};$("#upload_files").val("");r.send(t)},load:function(){contextMenu.close();hash=document.location.hash.replace("#","");albumID="";photoID="";if(hash.indexOf("a")!=-1)albumID=hash.split("p")[0].replace("a","");else albumID="";if(hash.indexOf("p")!=-1)photoID=hash.split("p")[1];else photoID="";lychee.content.attr("data-id",albumID);lychee.image_view.attr("data-id",photoID);if(albumID&&photoID){if(lychee.content.html()==""||$("#search").val().length!=0){lychee.content.hide();photos.load(albumID,true)}photos.loadInfo(photoID)}else if(albumID){if(visible.infobox)photos.hideInfobox();if(!visible.controls())lychee.showControls();if(visible.imageview())photos.hideView();else photos.load(albumID,false)}else{if(visible.infobox)photos.hideInfobox();if(!visible.controls())lychee.showControls();if(visible.imageview())photos.hideView();albums.load()}},"goto":function(e){document.location.hash=e},title:function(){return lychee.headerTitle.html().replace($("#title span").html(),"").replace("","")},showControls:function(){clearTimeout($(window).data("timeout"));if(visible.imageview()){lychee.image_view.removeClass("full");lychee.loadingBar.css("opacity",1);lychee.header.css("margin-Top","0px");if($("#image_view #image.small").length>0){$("#image_view #image").css({marginTop:-1*($("#image_view #image").height()/2)+20})}else{$("#image_view #image").css({top:70,right:30,bottom:30,left:30})}}},hideControls:function(){if(visible.imageview()){clearTimeout($(window).data("timeout"));$(window).data("timeout",setTimeout(function(){lychee.image_view.addClass("full");lychee.loadingBar.css("opacity",0);lychee.header.css("margin-Top","-45px");if($("#image_view #image.small").length>0){$("#image_view #image").css({marginTop:-1*($("#image_view #image").height()/2)})}else{$("#image_view #image").css({top:0,right:0,bottom:0,left:0})}},500))}},closeModal:function(){$(".message_overlay").removeClass("fadeIn").css("opacity",0);$.timer(300,function(){$(".message_overlay").remove()})},animate:function(e,t){animations=[["fadeIn","fadeOut"],["contentZoomIn","contentZoomOut"]];if(!e.jQuery)e=$(e);for(i=0;i300)waitTime=0;else if(t)waitTime=0;else waitTime=300-durationTime;$.timer(waitTime,function(){photosData="";$.each(n,function(){photosData+=build.photo(this)});lychee.content.html(photosData);if(!t){lychee.animate(".album, .photo","contentZoomIn");$("#tools_albums, #tools_photo").hide();$("#tools_album").show();$("img").retina();albums.loadInfo(e)}})})},loadInfo:function(e){photos.showView();loadingBar.show();params="getPhotoInfo&photoID="+e;lychee.api(params,"json",function(e){if(!e.title)e.title="Untitled";document.title="Lychee - "+e.title;lychee.headerTitle.html(e.title).addClass("editable");$("#button_star a").removeClass("icon-star-empty icon-star");if(e.star=="1"){$("#button_star a").addClass("icon-star");$("#button_star").attr("title","Unstar Photo")}else{$("#button_star a").addClass("icon-star-empty");$("#button_star").attr("title","Star Photo")}if(e.public=="1"){$("#button_share a").addClass("active");$("#button_share").attr("title","Make Photo Private")}else{$("#button_share a").removeClass("active");$("#button_share").attr("title","Share Photo")}e.url=lychee.upload_path+e.url;if(visible.controls()&&photos.isSmall(e))lychee.image_view.html("
");else if(visible.controls())lychee.image_view.html("
");else if(photos.isSmall(e))lychee.image_view.html("
");else lychee.image_view.html("
");lychee.animate(image_view,"fadeIn");lychee.image_view.show();if(!visible.controls())lychee.hideControls();lychee.infobox.html(build.infobox(e)).show();$.timer(300,function(){lychee.content.show()});loadingBar.hide()})},isSmall:function(e){size=[["width",false],["height",false]];if(e.width<$(window).width()-60)size["width"]=true;if(e.height<$(window).height()-100)size["height"]=true;if(size["width"]&&size["height"])return true;else return false},showView:function(){$("#tools_albums, #tools_album").hide();$("#tools_photo").show();$("body").css("overflow","hidden")},hideView:function(){$("#tools_photo, #tools_albums").hide();$("#tools_album").show();$("body").css("overflow","scroll");albums.loadInfo(lychee.content.attr("data-id"));lychee.animate(image_view,"fadeOut");$.timer(300,function(){lychee.image_view.hide()})},showInfobox:function(){if(!visible.infobox())$("body").append("
");lychee.infobox.css("right","0px")},hideInfobox:function(){$("#infobox_overlay").remove();lychee.infobox.css("right","-320px")},hide:function(e){$(".photo[data-id='"+e+"']").css("opacity",0).animate({width:0,marginLeft:0},300,function(){$(this).remove();if(!visible.imageview()){imgNum=parseInt($("#title span").html().replace("- ","").replace(" photos",""))-1;$("#title span").html(" - "+imgNum+" photos")}})},"delete":function(e){loadingBar.show();params="deletePhoto&photoID="+e;lychee.api(params,"text",function(t){if(t){photos.hide(e);lychee.goto("a"+lychee.content.attr("data-id"));loadingBar.hide()}else loadingBar.show("error")})},deleteDialog:function(e){if(!e)e=lychee.image_view.attr("data-id");if(visible.imageview())photoTitle=lychee.title();else photoTitle=$(".photo[data-id='"+e+"'] .overlay h1").html();if(photoTitle=="")photoTitle="Untitled";f1="photos.delete("+e+");";f2="";modal=build.modal("Delete Photo","Are you sure you want to delete the photo '"+photoTitle+"'?
This action can't be undone!",["Delete Photo","Keep Photo"],[f1,f2]);$("body").append(modal)},rename:function(e){if(!e)oldTitle=lychee.title();else oldTitle="";if(!e)e=lychee.image_view.attr("data-id");newTitle=prompt("Please enter a new title for this photo:",oldTitle);if(e!=null&&e&&newTitle.length<31){loadingBar.show();if(newTitle=="")newTitle="Untitled";params="setPhotoTitle&photoID="+e+"&title="+encodeURI(newTitle);lychee.api(params,"text",function(t){if(t){if(visible.imageview()){$("#infobox .attr_name").html($("#infobox .attr_name").html().replace(lychee.title(),newTitle));lychee.headerTitle.html(newTitle);document.title="Lychee - "+newTitle}$(".photo[data-id='"+e+"'] .overlay h1").html(newTitle);loadingBar.hide()}else loadingBar.show("error")})}else if(newTitle.length>0)loadingBar.show("error","Error","New title to short or too long. Please try another one!")},move:function(e,t){if(t>=0){loadingBar.show();params="movePhoto&photoID="+e+"&albumID="+t;lychee.api(params,"text",function(t){if(t){photos.hide(e);lychee.goto("a"+lychee.content.attr("data-id"));loadingBar.hide()}else loadingBar.show("error")})}},setStar:function(){loadingBar.show();photoID=lychee.image_view.attr("data-id");params="setPhotoStar&photoID="+photoID;lychee.api(params,"text",function(e){if(e){if($("#button_star a.icon-star-empty").length){$("#button_star a").removeClass("icon-star-empty icon-star").addClass("icon-star");$("#button_star").attr("title","Unstar Photo")}else{$("#button_star a").removeClass("icon-star-empty icon-star").addClass("icon-star-empty");$("#button_star").attr("title","Star Photo")}photos.load(lychee.content.attr("data-id"),true);loadingBar.hide()}else loadingBar.show("error")})},setPublic:function(e){loadingBar.show();photoID=lychee.image_view.attr("data-id");params="setPhotoPublic&photoID="+photoID+"&url="+photos.getViewLink(photoID);lychee.api(params,"text",function(t){if(t){if($("#button_share a.active").length){$("#button_share a").removeClass("active");$("#button_share").attr("title","Make Private")}else{$("#button_share a").addClass("active");$("#button_share").attr("title","Share Photo");contextMenu.share(photoID,e.pageX,e.pageY)}photos.load(lychee.content.attr("data-id"),true);loadingBar.hide()}else loadingBar.show("error")})},setDescription:function(){description=prompt("Please enter a description for this photo:","");photoID=lychee.image_view.attr("data-id");if(description.length>0&&description.length<160){loadingBar.show();params="setPhotoDescription&photoID="+photoID+"&description="+escape(description);lychee.api(params,"text",function(e){if(e)photos.loadInfo(photoID);else loadingBar.show("error")})}else if(description.length>0)loadingBar.show("error","Error","Description to short or too long. Please try another one!")},share:function(e,t){loadingBar.show();params="sharePhoto&photoID="+t+"&url="+photos.getViewLink(t);lychee.api(params,"json",function(n){switch(e){case 0:link=n.twitter;break;case 1:link=n.facebook;break;case 2:link=n.mail;break;case 3:link="copy";modal=build.modal("Copy Link","You can use this link to share your image with other people: ",["Close"],[""]);$("body").append(modal);$(".copylink").focus();break;case 4:link="copy";modal=build.modal("Copy Shortlink","You can use this link to share your image with other people: ",["Close"],[""]);$("body").append(modal);$(".copylink").focus();break;default:link="";break}if(link=="copy")loadingBar.hide();else if(link.length>5){location.href=link;loadingBar.hide()}else loadingBar.show("error")})},getViewLink:function(e){if(location.href.indexOf("index.html")>0)return location.href.replace("index.html"+location.hash,"view.php?p="+e);else return location.href.replace(location.hash,"view.php?p="+e)},previous:function(){albumID=lychee.content.attr("data-id");photoID=lychee.image_view.attr("data-id");params="previousPhoto&photoID="+photoID+"&albumID="+albumID;lychee.api(params,"json",function(e){if(e!=false)lychee.goto("a"+albumID+"p"+e.id)})},next:function(){albumID=lychee.content.attr("data-id");photoID=lychee.image_view.attr("data-id");params="nextPhoto&photoID="+photoID+"&albumID="+albumID;lychee.api(params,"json",function(e){if(e)lychee.goto("a"+albumID+"p"+e.id)})}};search={find:function(e){clearTimeout($(window).data("timeout"));$(window).data("timeout",setTimeout(function(){if($("#search").val().length!=0){params="search&term="+e;lychee.api(params,"json",function(e){albumsData="";if(e&&e.albums)$.each(e.albums,function(){albumsData+=build.album(this)});photosData="";if(e&&e.photos)$.each(e.photos,function(){photosData+=build.photo(this)});if(albumsData==""&&photosData=="")code="";else if(albumsData=="")code=build.divider("Photos")+photosData;else if(photosData=="")code=build.divider("Albums")+albumsData;else code=build.divider("Photos")+photosData+build.divider("Albums")+albumsData;if(lychee.content.attr("data-search")!=code){lychee.animate(".album, .photo","contentZoomOut");lychee.animate(".divider","fadeOut");$.timer(300,function(){lychee.content.attr("data-search",code);lychee.content.html(code);lychee.animate(".album, .photo","contentZoomIn")})}})}else search.reset()},250))},reset:function(){$("#search").val("");if(lychee.content.attr("data-search")!=""){lychee.content.attr("data-search","");lychee.animate(".divider","fadeOut");albums.load()}}};visible={albums:function(){if($("#tools_albums").css("display")=="block")return true;else return false},imageview:function(){if($("#image_view.fadeIn").length>0)return true;else return false},infobox:function(){if(parseInt(lychee.infobox.css("right").replace("px",""))==-320)return false;else return true},controls:function(){if(lychee.loadingBar.css("opacity")>0)return true;else return false}} \ No newline at end of file +albums={load:function(){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="";if(lychee.publicMode)smartData="";else 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="";if(smartData==""&&albumsData=="")$("body").append(build.no_content("picture"));else{lychee.content.html(smartData+albumsData);lychee.animate(".album, .photo","contentZoomIn")}document.title="Lychee";lychee.headerTitle.html("Albums").removeClass("editable");$("img").retina()})})},loadInfo:function(e,t){if(e=="f"||e=="s"||e==0){lychee.headerTitle.removeClass("editable");$("#button_edit_album, #button_trash_album, #button_share_album").hide();lychee.api("getSmartInfo","json",function(t){switch(e){case"f":document.title="Lychee - Starred";lychee.headerTitle.html("Starred - "+t.starredNum+" photos");break;case"s":document.title="Lychee - Public";lychee.headerTitle.html("Public - "+t.publicNum+" photos");break;case"0":document.title="Lychee - Unsorted";lychee.headerTitle.html("Unsorted - "+t.unsortNum+" photos");$("#button_trash_album").show();break}})}else{t="";$("#button_edit_album, #button_trash_album, #button_share_album, .button_divider").show();params="getAlbumInfo&albumID="+e+"&password="+t;lychee.api(params,"json",function(e){if(!e.title)e.title="Untitled";document.title="Lychee - "+e.title;lychee.headerTitle.html(e.title+" - "+e.num+" photos").addClass("editable");if(e.public=="1"){$("#button_share_album a").addClass("active");$("#button_share_album").attr("title","Share Album")}else{$("#button_share_album a").removeClass("active");$("#button_share_album").attr("title","Make Public")}})}},add:function(){title=prompt("Please enter a title for this album:","Untitled");lychee.closeModal();if(title.length>0&&title.length<31){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){params="deleteAlbum&albumID="+e+"&delAll="+t;lychee.api(params,"text",function(t){if(t){if(visible.albums())albums.hide(e);else lychee.goto("")}else loadingBar.show("error")})},deleteDialog:function(e){if(e==0){f1="albums.delete(0, true);";f2="";modal=build.modal("Clear Unsorted","Are you sure you want to delete all photos from 'Unsorted'?
This action can't be undone!",["Clear Unsorted","Keep Photos"],[f1,f2]);$("body").append(modal)}else{if(visible.albums())albumTitle=$(".album[data-id='"+e+"'] .overlay h1").html();else albumTitle=lychee.title();f1="albums.delete("+e+", true);";f2="albums.delete("+e+", false);";modal=build.modal("Delete Album","Are you sure you want to delete the album '"+albumTitle+"' and all of the photos it contains? This action can't be undone!",["Delete Album and Photos","Keep Photos"],[f1,f2]);$("body").append(modal)}},setTitle:function(e){if(!e)oldTitle=lychee.title();else oldTitle="";if(!e)e=lychee.content.attr("data-id");newTitle=prompt("Please enter a new title for this album:",oldTitle);if(e!=""&&e!=null&&e&&newTitle.length>0&&newTitle.length<31){params="setAlbumTitle&albumID="+e+"&title="+encodeURI(newTitle);lychee.api(params,"text",function(t){if(t){if(visible.albums())$(".album[data-id='"+e+"'] .overlay h1").html(newTitle);else{lychee.headerTitle.html(newTitle+""+$("#title span").html()+"");document.title="Lychee - "+newTitle}}else loadingBar.show("error")})}else if(newTitle.length>0)loadingBar.show("error","Error","New title to short or too long. Please try another one!")},setPublic:function(e){albumID=lychee.content.attr("data-id");params="setAlbumPublic&albumID="+albumID;lychee.api(params,"text",function(t){if(t){if($("#button_share_album a.active").length){$("#button_share_album a").removeClass("active");$("#button_share_album").attr("title","Make Public")}else{$("#button_share_album a").addClass("active");$("#button_share_album").attr("title","Share Album");contextMenu.share_album(albumID,e.pageX,e.pageY)}}else loadingBar.show("error")})},setPassword:function(e,t){if(!e)e=lychee.content.attr("data-id");if(!t)t=prompt("Please enter a password for this album:","");if(t!="")t=hex_md5(t);params="setAlbumPassword&albumID="+e+"&password="+t;lychee.api(params,"text",function(e){if(!e)loadingBar.show("error")})},share:function(e,t){link="";url=location.href;switch(e){case 0:link="https://twitter.com/share?url="+encodeURI(url);break;case 1:link="http://www.facebook.com/sharer.php?u="+encodeURI(url)+"&t="+encodeURI(lychee.title());break;case 2:link="mailto:?subject="+encodeURI(lychee.title())+"&body="+encodeURI("Hi! Check this out: "+url);break;case 3:modal=build.modal("Copy Link","Everyone can view your public albums, but only you can edit them. Use this link to share your album with others: ",["Close"],[""]);$("body").append(modal);$(".copylink").focus();break;default:link="";break}if(link.length>5)location.href=link},getArchive:function(){albumID=lychee.content.attr("data-id");if(location.href.indexOf("index.html")>0)link=location.href.replace(location.hash,"").replace("index.html","php/api.php?function=getAlbumArchive&albumID="+albumID);else link=location.href.replace(location.hash,"")+"php/api.php?function=getAlbumArchive&albumID="+albumID;location.href=link}};build={divider:function(e){return"

"+e+"

"},album:function(e){var t="";if(!e)return"";if(e.password&&lychee.publicMode){e.thumb0="img/password.png";e.thumb1="img/password.png";e.thumb2="img/password.png"}else{if(!e.thumb0)e.thumb0="img/no_images.png";if(!e.thumb1)e.thumb1="img/no_images.png";if(!e.thumb2)e.thumb2="img/no_images.png"}if(!e.title)e.title="Untitled";if(e.title.length>18)e.title=e.title.substr(0,18)+"...";t+="
";t+="thumb";t+="thumb";t+="thumb";t+="
";if(e.password&&!lychee.publicMode)t+="

"+e.title+"

";else t+="

"+e.title+"

";t+=""+e.sysdate+"";t+="
";if(!lychee.publicMode&&e.star=="1")t+="";if(!lychee.publicMode&&e.public=="1")t+="";if(!lychee.publicMode&&e.unsorted=="1")t+="";t+="
";return t},photo:function(e){var t="";if(e=="")return"";if(!e.title)e.title="";if(!e.thumbUrl)e.thumbUrl="img/no_image.png";if(e.title.length>18)e.title=e.title.substr(0,18)+"...";t+="
";t+="thumb";t+="
";t+="

"+e.title+"

";t+=""+e.sysdate+"";t+="
";if(e.star=="1")t+="";if(!lychee.publicMode&&e.public=="1")t+="";t+="
";return t},no_content:function(e){var t="";t+="
";t+="";if(e=="search")t+="

No results

";else if(e=="picture")t+="

No public albums

";t+="
";return t},modal:function(e,t,n,r){var i="";i+="
";i+="
";i+="

"+e+"

";i+="";i+="

"+t+"

";$.each(n,function(e){if(e==0)i+=""+this+"";else i+=""+this+""});i+="
";i+="";i+="
";return i},addModal:function(){var e="";e+="
";e+="
";e+="

Add Album or Photo

";e+="";e+="
";e+="
";e+="New Album";e+="
";e+="";e+="
";e+="
";e+="Upload Photo";e+="
";e+="
";e+="
";return e},signInModal:function(){var e="";e+="
";e+="
";e+="

Sign In

";e+="";e+="
Version "+lychee.version+"Update available!
";e+="Sign in";e+="
";e+="
";return e},uploadModal:function(){var e="";e+="
";e+="
";e+="";e+="
";e+="
";e+="
";return e},contextMenu:function(e){var t="";t+="
";t+="
";t+="";t+="";$.each(e,function(n){if(e[n][0]=="separator"&&e[n][1].length==0)t+="";else if(e[n][1].length!=0)t+=""});t+="";t+="
"+e[n][0]+"
";t+="
";return t},infobox:function(e,t){var n="";n+="

About

";n+="
";if(e.public==1)e.public="Public";else e.public="Private";if(t==true||lychee.publicMode)editTitleHTML="";else editTitleHTML="
";if(t==true||lychee.publicMode)editDescriptionHTML="";else editDescriptionHTML="
";infos=[["","Basics"],["Name",e.title+editTitleHTML],["Uploaded",e.sysdate],["Description",e.description+editDescriptionHTML],["","Image"],["Size",e.size],["Format",e.type],["Resolution",e.width+" x "+e.height],["","Camera"],["Captured",e.takedate],["Make",e.make],["Type/Model",e.model],["Shutter Speed",e.shutter],["Aperture",e.aperture],["Focal Length",e.focal],["ISO",e.iso],["","Share"],["Visibility",e.public],["Short Link",e.shortlink]];$.each(infos,function(e){if(infos[e][1]==""||infos[e][1]==undefined||infos[e][1]==null)infos[e][1]="-";if(infos[e][0]==""){n+="";n+="

"+infos[e][1]+"

";n+=""}else{n+="";n+="";n+="";n+=""}});n+="
"+infos[e][0]+""+infos[e][1]+"
";n+="
";n+="
";return n}};contextMenu={album:function(e){e.preventDefault();mouse_x=e.pageX;mouse_y=e.pageY;albumID=$(this).attr("data-id");if(albumID=="0"||albumID=="f"||albumID=="s")return false;mouse_y-=$(document).scrollTop();items=[["Rename","albums.setTitle("+albumID+")"],["Delete","albums.deleteDialog("+albumID+")"]];contextMenu.close();$("body").css("overflow","hidden");$(".album[data-id='"+albumID+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:mouse_y,left:mouse_x})},photo:function(e){e.preventDefault();mouse_x=e.pageX;mouse_y=e.pageY;photoID=$(this).attr("data-id");mouse_y-=$(document).scrollTop();items=[["Rename","photos.setTitle("+photoID+")"],["Move to Album","contextMenu.move("+photoID+", "+(mouse_x+150)+", "+(mouse_y+$(document).scrollTop())+")"],["Delete","photos.deleteDialog("+photoID+")"]];contextMenu.close();$("body").css("overflow","hidden");$(".photo[data-id='"+photoID+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:mouse_y,left:mouse_x})},move:function(e,t,n){n-=$(document).scrollTop();if(!t||!n){t="10px";n="10px"}lychee.api("getAlbums","json",function(r){if(lychee.content.attr("data-id")==0){items=[]}else{items=[["Unsorted","photos.setAlbum("+e+", 0)"]]}if(!r.albums){items=[["New Album","albums.add()"]]}else{$.each(r.album,function(t){if(this.id!=lychee.content.attr("data-id")){if(!this.title)this.title="Untitled";items[items.length]=new Array(this.title,"photos.setAlbum("+e+", "+this.id+")")}else{items[items.length]=new Array("","")}})}contextMenu.close();$("body").css("overflow","hidden");$(".photo[data-id='"+e+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:n,left:t-$(".contextmenu").width()})})},share:function(e,t,n){n-=$(document).scrollTop();if(!t||!n){t="10px";n="10px"}items=[[" Make Private","photos.setPublic()"],["separator",""],[" Twitter","photos.share(0, "+e+")"],[" Facebook","photos.share(1, "+e+")"],[" Mail","photos.share(2, "+e+")"],[" Copy Link","photos.share(3, "+e+")"]];if(lychee.bitlyUsername!="")items.push([" Copy Shortlink","photos.share(4, "+e+")"]);contextMenu.close();$("body").css("overflow","hidden").append(build.contextMenu(items));$(".photo[data-id='"+e+"']").addClass("active");$(".contextmenu").css({top:n,left:t})},share_album:function(e,t,n){n-=$(document).scrollTop();if(!t||!n){t="10px";n="10px"}items=[[" Make Private","albums.setPublic()"],["separator",""],[" Twitter","albums.share(0, "+e+")"],[" Facebook","albums.share(1, "+e+")"],[" Mail","albums.share(2, "+e+")"],[" Copy Link","albums.share(3, "+e+")"]];contextMenu.close();$("body").css("overflow","hidden").append(build.contextMenu(items));$(".contextmenu").css({top:n,left:t})},close:function(){$(".contextmenu_bg, .contextmenu").remove();$(".photo.active, .album.active").removeClass("active");$("body").css("overflow","scroll")}};loadingBar={status:null,show:function(e,t,n){clearTimeout(lychee.loadingBar.data("timeout"));if(e=="error"&&loadingBar.status!="error"){loadingBar.status="error";if(!t)t="Error";if(!n)n="Whoops, it looks like something went wrong. Please reload the site and try again!";lychee.loadingBar.removeClass("loading uploading error").addClass(e).html("

"+t+": "+n+"

").show().css("height","40px");if(visible.controls())lychee.header.css("margin-Top","40px");lychee.loadingBar.data("timeout",setTimeout(function(){loadingBar.hide(true)},3e3))}else if(loadingBar.status==null){loadingBar.status="loading";lychee.loadingBar.data("timeout",setTimeout(function(){lychee.loadingBar.show().removeClass("loading uploading error").addClass("loading");if(visible.controls())lychee.header.css("margin-Top","3px")},1e3))}},hide:function(e){if(loadingBar.status!="error"&&loadingBar.status!=null||e){loadingBar.status=null;clearTimeout(lychee.loadingBar.data("timeout"));lychee.loadingBar.html("").css("height","3px");if(visible.controls())lychee.header.css("marginTop","0px");$.timer(300,function(){lychee.loadingBar.hide()})}}};lychee={init:function(e,t){this.version="1.2";this.api_path=e;this.upload_path=t;this.update_path="http://lychee.electerious.com/version/index.php";this.updateURL="https://github.com/electerious/Lychee";this.publicMode=false;this.checkForUpdates=false;this.bitlyUsername="";this.loadingBar=$("#loading");this.header=$("header");this.headerTitle=$("#title");this.content=$("#content");this.image_view=$("#image_view");this.infobox=$("#infobox")},ready:function(){if(!mobileBrowser())$(".tools").tipsy({gravity:"n"});if(window.webkitNotifications)window.webkitNotifications.requestPermission();lychee.api("init","json",function(e){lychee.checkForUpdates=e.config.checkForUpdates;lychee.bitlyUsername=e.config.bitlyUsername;if(!e.loggedIn)lychee.setPublicMode();$(window).bind("popstate",lychee.load);lychee.load()})},setPublicMode:function(){this.publicMode=true;$("#button_signout, #search, #button_trash_album, #button_share_album, #button_edit_album, .button_add, #button_archive, .button_divider").remove();$("#button_trash, #button_move, #button_edit, #button_share, #button_star").remove();$(document).on("mouseenter","#title.editable",function(){$(this).removeClass("editable")}).off(event_name,"#title.editable").off("contextmenu",".photo").off("contextmenu",".album").off("drop");$("#button_signin").show()},api:function(e,t,n,r){if(r==undefined)loadingBar.show();$.ajax({type:"POST",url:lychee.api_path,data:"function="+e,dataType:t,success:function(e){$.timer(100,function(){loadingBar.hide()});n(e)},error:lychee.error})},showLogin:function(){$("body").append(build.signInModal());$("#username").focus();if(localStorage){local_username=localStorage.getItem("username");if(local_username==null)return false;if(local_username.length>0)$("#username").val(local_username);$("#password").focus()}if(lychee.checkForUpdates)lychee.update()},login:function(){user=$("input#username").val();password=hex_md5($("input#password").val());params="login&user="+user+"&password="+password;lychee.api(params,"text",function(e){if(e){localStorage.setItem("username",user);window.location.reload()}else{$("#password").val("").addClass("error");$(".message .button.active").removeClass("pressed")}})},logout:function(){lychee.api("logout","text",function(e){window.location.reload()})},update:function(){$.ajax({url:lychee.update_path,success:function(e){if(e!=lychee.version)$("#version span").show()}})},upload:function(e){pre_progress=0;$(".upload_overlay").remove();$("body").append(build.uploadModal());var t=new FormData;for(var n=0;npre_progress){$(".progressbar div").css("width",t+"%");pre_progress=t}if(t>=100)$(".progressbar div").css("opacity",.2)}};$("#upload_files").val("");r.send(t)},importUrl:function(){link=prompt("Please enter the direct link to a photo to import it:","");if(lychee.content.attr("data-id")=="")albumID=0;else albumID=lychee.content.attr("data-id");lychee.closeModal();if(link.length>3){params="importUrl&url="+escape(link)+"&albumID="+albumID;lychee.api(params,"text",function(e){if(e){if(lychee.content.attr("data-id")=="")lychee.goto("a0");else photos.load(lychee.content.attr("data-id"))}else loadingBar.show("error")})}else if(link.length>0)loadingBar.show("error","Error","Link to short or too long. Please try another one!")},load:function(){contextMenu.close();hash=document.location.hash.replace("#","");albumID="";photoID="";if(hash.indexOf("a")!=-1)albumID=hash.split("p")[0].replace("a","");else albumID="";if(hash.indexOf("p")!=-1)photoID=hash.split("p")[1];else photoID="";lychee.content.attr("data-id",albumID);lychee.image_view.attr("data-id",photoID);if(albumID&&photoID){if(lychee.content.html()==""||$("#search").length&&$("#search").val().length!=0){lychee.content.hide();photos.load(albumID,true)}photos.loadInfo(photoID,albumID)}else if(albumID){if(visible.infobox)photos.hideInfobox();if(!visible.controls())lychee.showControls();if(visible.imageview())photos.hideView();else photos.load(albumID,false)}else{if(visible.infobox)photos.hideInfobox();if(!visible.controls())lychee.showControls();if(visible.imageview())photos.hideView();albums.load()}},"goto":function(e){document.location.hash=e},title:function(){return lychee.headerTitle.html().replace($("#title span").html(),"").replace("","")},showControls:function(){clearTimeout($(window).data("timeout"));if(visible.imageview()){lychee.image_view.removeClass("full");lychee.loadingBar.css("opacity",1);lychee.header.css("margin-Top","0px");if($("#image_view #image.small").length>0){$("#image_view #image").css({marginTop:-1*($("#image_view #image").height()/2)+20})}else{$("#image_view #image").css({top:70,right:30,bottom:30,left:30})}}},hideControls:function(){if(visible.imageview()&&!visible.infobox()){clearTimeout($(window).data("timeout"));$(window).data("timeout",setTimeout(function(){lychee.image_view.addClass("full");lychee.loadingBar.css("opacity",0);lychee.header.css("margin-Top","-45px");if($("#image_view #image.small").length>0){$("#image_view #image").css({marginTop:-1*($("#image_view #image").height()/2)})}else{$("#image_view #image").css({top:0,right:0,bottom:0,left:0})}},500))}},closeModal:function(){$(".message_overlay").removeClass("fadeIn").css("opacity",0);$.timer(300,function(){$(".message_overlay").remove()})},animate:function(e,t){animations=[["fadeIn","fadeOut"],["contentZoomIn","contentZoomOut"]];if(!e.jQuery)e=$(e);for(i=0;i300)waitTime=0;else if(t)waitTime=0;else waitTime=300-durationTime;$.timer(waitTime,function(){photosData="";$.each(n,function(){photosData+=build.photo(this)});lychee.content.html(photosData);if(!t){lychee.animate(".album, .photo","contentZoomIn");$("#tools_albums, #tools_photo").hide();$("#tools_album").show();$("img").retina();albums.loadInfo(e,password)}},false)})},loadInfo:function(e,t){password="";photos.showView();params="getPhotoInfo&photoID="+e+"&password="+password;lychee.api(params,"json",function(n){if(n=="HTTP/1.1 403 Wrong password!"){localStorage.removeItem("album"+t);photos.loadInfo(e,t);return false}if(!n.title)n.title="Untitled";document.title="Lychee - "+n.title;lychee.headerTitle.html(n.title).addClass("editable");$("#button_star a").removeClass("icon-star-empty icon-star");if(n.star=="1"){$("#button_star a").addClass("icon-star");$("#button_star").attr("title","Unstar Photo")}else{$("#button_star a").addClass("icon-star-empty");$("#button_star").attr("title","Star Photo")}if(n.public=="1"){$("#button_share a").addClass("active");$("#button_share").attr("title","Share Photo")}else{$("#button_share a").removeClass("active");$("#button_share").attr("title","Make Public")}n.url=lychee.upload_path+n.url;if(visible.controls()&&photos.isSmall(n))lychee.image_view.html("
");else if(visible.controls())lychee.image_view.html("
");else if(photos.isSmall(n))lychee.image_view.html("
");else lychee.image_view.html("
");lychee.animate(image_view,"fadeIn");lychee.image_view.show();if(!visible.controls())lychee.hideControls();lychee.infobox.html(build.infobox(n)).show();$.timer(300,function(){lychee.content.show()})})},isSmall:function(e){size=[["width",false],["height",false]];if(e.width<$(window).width()-60)size["width"]=true;if(e.height<$(window).height()-100)size["height"]=true;if(size["width"]&&size["height"])return true;else return false},showView:function(){$("#tools_albums, #tools_album").hide();$("#tools_photo").show();$("body").css("overflow","hidden")},hideView:function(){$("#tools_photo, #tools_albums").hide();$("#tools_album").show();$("body").css("overflow","scroll");albums.loadInfo(lychee.content.attr("data-id"));lychee.animate(image_view,"fadeOut");$.timer(300,function(){lychee.image_view.hide()})},showInfobox:function(){if(!visible.infobox())$("body").append("
");lychee.infobox.css("right","0px")},hideInfobox:function(){$("#infobox_overlay").remove();lychee.infobox.css("right","-320px")},hide:function(e){$(".photo[data-id='"+e+"']").css("opacity",0).animate({width:0,marginLeft:0},300,function(){$(this).remove();if(!visible.imageview()){imgNum=parseInt($("#title span").html().replace("- ","").replace(" photos",""))-1;$("#title span").html(" - "+imgNum+" photos")}})},"delete":function(e){params="deletePhoto&photoID="+e;lychee.api(params,"text",function(t){if(t){photos.hide(e);lychee.goto("a"+lychee.content.attr("data-id"))}else loadingBar.show("error")})},deleteDialog:function(e){if(!e)e=lychee.image_view.attr("data-id");if(visible.imageview())photoTitle=lychee.title();else photoTitle=$(".photo[data-id='"+e+"'] .overlay h1").html();if(photoTitle=="")photoTitle="Untitled";f1="photos.delete("+e+");";f2="";modal=build.modal("Delete Photo","Are you sure you want to delete the photo '"+photoTitle+"'?
This action can't be undone!",["Delete Photo","Keep Photo"],[f1,f2]);$("body").append(modal)},setTitle:function(e){if(!e)oldTitle=lychee.title();else oldTitle="";if(!e)e=lychee.image_view.attr("data-id");newTitle=prompt("Please enter a new title for this photo:",oldTitle);if(e!=null&&e&&newTitle.length<31){if(newTitle=="")newTitle="Untitled";params="setPhotoTitle&photoID="+e+"&title="+encodeURI(newTitle);lychee.api(params,"text",function(t){if(t){if(visible.imageview()){$("#infobox .attr_name").html($("#infobox .attr_name").html().replace(lychee.title(),newTitle));lychee.headerTitle.html(newTitle);document.title="Lychee - "+newTitle}$(".photo[data-id='"+e+"'] .overlay h1").html(newTitle)}else loadingBar.show("error")})}else if(newTitle.length>0)loadingBar.show("error","Error","New title to short or too long. Please try another one!")},setAlbum:function(e,t){if(t>=0){params="setAlbum&photoID="+e+"&albumID="+t;lychee.api(params,"text",function(t){if(t){photos.hide(e);lychee.goto("a"+lychee.content.attr("data-id"))}else loadingBar.show("error")})}},setStar:function(){photoID=lychee.image_view.attr("data-id");params="setPhotoStar&photoID="+photoID;lychee.api(params,"text",function(e){if(e){if($("#button_star a.icon-star-empty").length){$("#button_star a").removeClass("icon-star-empty icon-star").addClass("icon-star");$("#button_star").attr("title","Unstar Photo")}else{$("#button_star a").removeClass("icon-star-empty icon-star").addClass("icon-star-empty");$("#button_star").attr("title","Star Photo")}photos.load(lychee.content.attr("data-id"),true)}else loadingBar.show("error")})},setPublic:function(e){photoID=lychee.image_view.attr("data-id");params="setPhotoPublic&photoID="+photoID+"&url="+photos.getViewLink(photoID);lychee.api(params,"text",function(t){if(t){if($("#button_share a.active").length){$("#button_share a").removeClass("active");$("#button_share").attr("title","Make Public");$("#infobox .attr_visibility").html("Private")}else{$("#button_share a").addClass("active");$("#button_share").attr("title","Share Photo");$("#infobox .attr_visibility").html("Public");contextMenu.share(photoID,e.pageX,e.pageY)}photos.load(lychee.content.attr("data-id"),true)}else loadingBar.show("error")})},setDescription:function(){description=prompt("Please enter a description for this photo:","");photoID=lychee.image_view.attr("data-id");if(description.length>0&&description.length<160){params="setPhotoDescription&photoID="+photoID+"&description="+escape(description);lychee.api(params,"text",function(e){if(e){$("#infobox .attr_description").html(description+"
")}else loadingBar.show("error")})}else if(description.length>0)loadingBar.show("error","Error","Description to short or too long. Please try another one!")},share:function(e,t){link="";url=photos.getViewLink(t);switch(e){case 0:link="https://twitter.com/share?url="+encodeURI(url);break;case 1:link="http://www.facebook.com/sharer.php?u="+encodeURI(url)+"&t="+encodeURI(lychee.title());break;case 2:link="mailto:?subject="+encodeURI(lychee.title())+"&body="+encodeURI("Hi! Check this out: "+url);break;case 3:modal=build.modal("Copy Link","Everyone can view your public photos, but only you can edit them. Use this link to share your photo with others: ",["Close"],[""]);$("body").append(modal);$(".copylink").focus();break;case 4:params="getShortlink&photoID="+t;lychee.api(params,"text",function(e){if(e=="")e="Something went wrong!";modal=build.modal("Copy Shortlink","Everyone can view your public photos, but only you can edit them. Use this link to share your photo with others: ",["Close"],[""]);$("body").append(modal);$(".copylink").focus()});break;default:link="";break}if(link.length>5)location.href=link},getViewLink:function(e){if(location.href.indexOf("index.html")>0)return location.href.replace("index.html"+location.hash,"view.php?p="+e);else return location.href.replace(location.hash,"view.php?p="+e)},previous:function(){albumID=lychee.content.attr("data-id");photoID=lychee.image_view.attr("data-id");params="previousPhoto&photoID="+photoID+"&albumID="+albumID;lychee.api(params,"json",function(e){if(e!=false)lychee.goto("a"+albumID+"p"+e.id)})},next:function(){albumID=lychee.content.attr("data-id");photoID=lychee.image_view.attr("data-id");params="nextPhoto&photoID="+photoID+"&albumID="+albumID;lychee.api(params,"json",function(e){if(e)lychee.goto("a"+albumID+"p"+e.id)})}};search={find:function(e){clearTimeout($(window).data("timeout"));$(window).data("timeout",setTimeout(function(){if($("#search").val().length!=0){params="search&term="+e;lychee.api(params,"json",function(e){albumsData="";if(e&&e.albums)$.each(e.albums,function(){albumsData+=build.album(this)});photosData="";if(e&&e.photos)$.each(e.photos,function(){photosData+=build.photo(this)});if(albumsData==""&&photosData=="")code="error";else if(albumsData=="")code=build.divider("Photos")+photosData;else if(photosData=="")code=build.divider("Albums")+albumsData;else code=build.divider("Photos")+photosData+build.divider("Albums")+albumsData;if(lychee.content.attr("data-search")!=code){$(".no_content").remove();lychee.animate(".album, .photo","contentZoomOut");lychee.animate(".divider","fadeOut");$.timer(300,function(){lychee.content.attr("data-search",code);if(code=="error")$("body").append(build.no_content("search"));else{lychee.content.html(code);lychee.animate(".album, .photo","contentZoomIn")}})}})}else search.reset()},250))},reset:function(){$("#search").val("");$(".no_content").remove();if(lychee.content.attr("data-search")!=""){lychee.content.attr("data-search","");lychee.animate(".divider","fadeOut");albums.load()}}};visible={albums:function(){if($("#tools_albums").css("display")=="block")return true;else return false},imageview:function(){if($("#image_view.fadeIn").length>0)return true;else return false},infobox:function(){if(parseInt(lychee.infobox.css("right").replace("px",""))==-320)return false;else return true},controls:function(){if(lychee.loadingBar.css("opacity")>0)return true;else return false}} \ No newline at end of file diff --git a/js/main.js b/js/main.js index f132a60..86560b9 100755 --- a/js/main.js +++ b/js/main.js @@ -15,10 +15,7 @@ $(document).ready(function(){ else event_name = "click"; /* Toolbar */ - $("#button_signout").on(event_name, function() { - modal = build.modal("Sign Out", "Are you sure you want to leave and log out?", ["Sign out", "Stay here"], ["lychee.logout();", ""]); - $("body").append(modal); - }); + $("#button_signout").on(event_name, lychee.logout); $("#button_download").on(event_name, function() { link = $("#image_view #image").css("background-image").replace(/"/g,"").replace(/url\(|\)$/ig, ""); window.open(link,"_newtab"); @@ -27,11 +24,15 @@ $(document).ready(function(){ if ($("#button_share a.active").length) contextMenu.share(lychee.image_view.attr("data-id"), e.pageX, e.pageY); else photos.setPublic(e); }); + $("#button_share_album").on(event_name, function(e) { + if ($("#button_share_album a.active").length) contextMenu.share_album(lychee.content.attr("data-id"), e.pageX, e.pageY); + else albums.setPublic(e); + }); $("#button_trash_album").on(event_name, function() { albums.deleteDialog(lychee.content.attr("data-id")) }); $("#button_move").on(event_name, function(e) { contextMenu.move(lychee.image_view.attr("data-id"), e.pageX, e.pageY) }); $("#button_trash").on(event_name, function() { photos.deleteDialog() }); - $("#button_edit_album").on(event_name, function() { albums.rename() }); - $("#button_edit").on(event_name, function() { photos.rename() }); + $("#button_edit_album").on(event_name, function() { albums.setTitle() }); + $("#button_edit").on(event_name, function() { photos.setTitle() }); $("#button_info").on(event_name, function() { photos.showInfobox() }); $("#button_archive").on(event_name, function() { albums.getArchive() }); $("#button_star").on(event_name, function() { photos.setStar() }); @@ -52,7 +53,7 @@ $(document).ready(function(){ /* Infobox */ $("#infobox") .on(event_name, ".header a", function() { photos.hideInfobox() }) - .on(event_name, "#edit_title", function() { photos.rename() }) + .on(event_name, "#edit_title", function() { photos.setTitle() }) .on(event_name, "#edit_description", function() { photos.setDescription() }); /* Keyboard */ @@ -72,7 +73,7 @@ $(document).ready(function(){ Mousetrap.bindGlobal('esc', function(e) { e.preventDefault(); - if ($(".message").length&&$(".sign_in").length==0) lychee.closeModal(); + if ($(".message").length) lychee.closeModal(); else if (visible.infobox()) photos.hideInfobox(); else if (visible.imageview()) lychee.goto("a" + lychee.content.attr("data-id")); else if (visible.albums()&&$("#search").val().length!=0) search.reset(); @@ -82,10 +83,11 @@ $(document).ready(function(){ $(document) /* Login */ + .on(event_name, "#button_signin", function() { lychee.showLogin() }) .on("keyup", "#password", function() { if ($(this).val().length>0) $(this).removeClass("error") }) /* Toolbar */ - .on(event_name, "#title.editable", function() { if (visible.imageview()) photos.rename(); else albums.rename(); }) + .on(event_name, "#title.editable", function() { if (visible.imageview()) photos.setTitle(); else albums.setTitle(); }) /* Navigation */ .on("click", ".album", function() { lychee.goto("a" + $(this).attr("data-id")) }) @@ -100,6 +102,7 @@ $(document).ready(function(){ /* Add Dialog */ .on(event_name, ".button_add", function() { $("body").append(build.addModal) }) .on(event_name, "#add_album", albums.add) + .on(event_name, "#add_link", lychee.importUrl) .on(event_name, "#add_photo", function() { $("#auswahl").html(""); $("#upload_files").click() }) /* Upload */ @@ -115,14 +118,18 @@ $(document).ready(function(){ /* Controls */ .bind("mouseenter", lychee.showControls) - .bind("mouseleave", lychee.hideControls); + .bind("mouseleave", lychee.hideControls) - /* Upload */ - $(document.documentElement) - .on("dragover", function(e) { e.preventDefault();}, false) - .on("drop", function (e) { e.stopPropagation(); e.preventDefault(); lychee.upload(e.originalEvent.dataTransfer.files); return true; }); + /* Upload */ + .on("dragover", function(e) { e.preventDefault(); }, false) + .on("drop", function(e) { + e.stopPropagation(); + e.preventDefault(); + lychee.upload(e.originalEvent.dataTransfer.files); + return true; + }); /* Init */ lychee.ready(); -}); +}); \ No newline at end of file diff --git a/js/modules/albums.js b/js/modules/albums.js old mode 100644 new mode 100755 index 7c4b134..758c55e --- a/js/modules/albums.js +++ b/js/modules/albums.js @@ -12,7 +12,6 @@ albums = { load: function() { - loadingBar.show(); lychee.animate(".album, .photo", "contentZoomOut"); /* Search */ @@ -59,7 +58,8 @@ albums = { if (data.publicThumb1) publicAlbum.thumb1 = lychee.upload_path + data.publicThumb1; else publicAlbum.thumb1 = ""; if (data.publicThumb2) publicAlbum.thumb2 = lychee.upload_path + data.publicThumb2; else publicAlbum.thumb2 = ""; - smartData = build.divider("Smart Albums") + build.album(unsortedAlbum) + build.album(starredAlbum) + build.album(publicAlbum); + if (lychee.publicMode) smartData = ""; + else smartData = build.divider("Smart Albums") + build.album(unsortedAlbum) + build.album(starredAlbum) + build.album(publicAlbum); /* Albums */ if (data.albums) { @@ -69,66 +69,80 @@ albums = { } else albumsData = ""; - lychee.content.html(smartData + albumsData); - lychee.animate(".album, .photo", "contentZoomIn"); + if (smartData==""&&albumsData=="") $("body").append(build.no_content("picture")); + else { + 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(albumID) { + loadInfo: function(albumID, password) { if (albumID=="f"||albumID=="s"||albumID==0) { lychee.headerTitle.removeClass("editable"); + $("#button_edit_album, #button_trash_album, #button_share_album").hide(); + lychee.api("getSmartInfo", "json", function(data) { switch (albumID) { case "f": document.title = "Lychee - Starred"; lychee.headerTitle.html("Starred - " + data.starredNum + " photos"); - $("#button_edit_album, #button_trash_album, .button_divider").hide(); break; case "s": document.title = "Lychee - Public"; lychee.headerTitle.html("Public - " + data.publicNum + " photos"); - $("#button_edit_album, #button_trash_album, .button_divider").hide(); break; case "0": document.title = "Lychee - Unsorted"; lychee.headerTitle.html("Unsorted - " + data.unsortNum + " photos"); - $("#button_edit_album").hide(); - $("#button_trash_album, .button_divider").show(); + $("#button_trash_album").show(); break; } - loadingBar.hide(); - }); } else { - params = "getAlbumInfo&albumID=" + albumID; - lychee.api(params, "json", function(data) { + /*if (lychee.publicMode&&password==undefined) { + password = localStorage.getItem("album" + albumID); + if (password==null) { + if (lychee.publicMode) password = prompt("Please enter a password for this album:", ""); else password = ""; + if (password!="") password = hex_md5(password); + localStorage.setItem("album" + albumID, password); + } + }*/ - $("#button_edit_album, #button_trash_album, .button_divider").show(); + password = ""; + + $("#button_edit_album, #button_trash_album, #button_share_album, .button_divider").show(); + + params = "getAlbumInfo&albumID=" + albumID + "&password=" + password; + lychee.api(params, "json", function(data) { if (!data.title) data.title = "Untitled"; document.title = "Lychee - " + data.title; lychee.headerTitle.html(data.title + " - " + data.num + " photos").addClass("editable"); - loadingBar.hide(); + if (data.public=="1") { + $("#button_share_album a").addClass("active"); + $("#button_share_album").attr("title", "Share Album"); + } else { + $("#button_share_album a").removeClass("active"); + $("#button_share_album").attr("title", "Make Public"); + } }); @@ -141,9 +155,7 @@ albums = { title = prompt("Please enter a title for this album:", "Untitled"); lychee.closeModal(); - if (title.length>2&&title.length<31) { - - loadingBar.show(); + if (title.length>0&&title.length<31) { params = "addAlbum&title=" + escape(title); lychee.api(params, "text", function(data) { @@ -170,19 +182,13 @@ albums = { delete: function(albumID, delAll) { - loadingBar.show(); - params = "deleteAlbum&albumID=" + albumID + "&delAll=" + delAll; lychee.api(params, "text", function(data) { if (data) { - if (visible.albums()) { - - albums.hide(albumID); - loadingBar.hide(); - - } else lychee.goto(""); + if (visible.albums()) albums.hide(albumID); + else lychee.goto(""); } else loadingBar.show("error"); @@ -213,16 +219,14 @@ albums = { }, - rename: function(albumID) { + setTitle: function(albumID) { if (!albumID) oldTitle = lychee.title(); else oldTitle = ""; if (!albumID) albumID = lychee.content.attr("data-id"); newTitle = prompt("Please enter a new title for this album:", oldTitle); - if (albumID!=""&&albumID!=null&&albumID&&newTitle.length>2&&newTitle.length<31) { - - loadingBar.show(); + if (albumID!=""&&albumID!=null&&albumID&&newTitle.length>0&&newTitle.length<31) { params = "setAlbumTitle&albumID=" + albumID + "&title=" + encodeURI(newTitle); lychee.api(params, "text", function(data) { @@ -233,7 +237,6 @@ albums = { lychee.headerTitle.html(newTitle + "" + $("#title span").html() + ""); document.title = "Lychee - " + newTitle; } - loadingBar.hide(); } else loadingBar.show("error"); }); @@ -242,6 +245,87 @@ albums = { }, + setPublic: function(e) { + + albumID = lychee.content.attr("data-id"); + + params = "setAlbumPublic&albumID=" + albumID; + lychee.api(params, "text", function(data) { + + if (data) { + + if ($("#button_share_album a.active").length) { + $("#button_share_album a").removeClass("active"); + $("#button_share_album").attr("title", "Make Public"); + } else { + $("#button_share_album a").addClass("active"); + $("#button_share_album").attr("title", "Share Album"); + contextMenu.share_album(albumID, e.pageX, e.pageY); + } + + } else loadingBar.show("error"); + + }); + + }, + + setPassword: function(albumID, password) { + + if (!albumID) albumID = lychee.content.attr("data-id"); + if (!password) password = prompt("Please enter a password for this album:", ""); + if (password!="") password = hex_md5(password); + + params = "setAlbumPassword&albumID=" + albumID + "&password=" + password; + lychee.api(params, "text", function(data) { + + if (!data) loadingBar.show("error"); + + }); + + }, + + /*checkAlbumPassword: function(albumID, password) { + + params = "checkAlbumPassword&albumID=" + albumID + "&password=" + hex_md5(password); + lychee.api(params, "text", function(data) { + if (data) { + if (password!="") password = hex_md5(password); + localStorage.setItem("album" + albumID, password); + return true; + } else return false; + }); + + },*/ + + share: function(service, albumID) { + + link = ""; + url = location.href; + + switch (service) { + case 0: + link = "https://twitter.com/share?url=" + encodeURI(url); + break; + case 1: + link = "http://www.facebook.com/sharer.php?u=" + encodeURI(url) + "&t=" + encodeURI(lychee.title()); + break; + case 2: + link = "mailto:?subject=" + encodeURI(lychee.title()) + "&body=" + encodeURI("Hi! Check this out: " + url); + break; + case 3: + modal = build.modal("Copy Link", "Everyone can view your public albums, but only you can edit them. Use this link to share your album with others: ", ["Close"], [""]); + $("body").append(modal); + $(".copylink").focus(); + break; + default: + link = ""; + break; + } + + if (link.length>5) location.href = link; + + }, + getArchive: function() { albumID = lychee.content.attr("data-id"); diff --git a/js/modules/build.js b/js/modules/build.js index 8342e94..012aa3f 100755 --- a/js/modules/build.js +++ b/js/modules/build.js @@ -18,26 +18,38 @@ build = { album: function(albumJSON) { + var album = ""; + if(!albumJSON) return ""; - if(!albumJSON.thumb0) albumJSON.thumb0 = "img/no_images.png"; - if(!albumJSON.thumb1) albumJSON.thumb1 = "img/no_images.png"; - if(!albumJSON.thumb2) albumJSON.thumb2 = "img/no_images.png"; + + if (albumJSON.password&&lychee.publicMode) { + albumJSON.thumb0 = "img/password.png"; + albumJSON.thumb1 = "img/password.png"; + albumJSON.thumb2 = "img/password.png"; + } else { + if(!albumJSON.thumb0) albumJSON.thumb0 = "img/no_images.png"; + if(!albumJSON.thumb1) albumJSON.thumb1 = "img/no_images.png"; + if(!albumJSON.thumb2) albumJSON.thumb2 = "img/no_images.png"; + } + if(!albumJSON.title) albumJSON.title = "Untitled"; if(albumJSON.title.length>18) albumJSON.title = albumJSON.title.substr(0, 18) + "..."; - var album = ""; - album += "
"; + album += "
"; album += "thumb"; album += "thumb"; album += "thumb"; album += "
"; - album += "

" + albumJSON.title + "

"; + + if (albumJSON.password&&!lychee.publicMode) album += "

" + albumJSON.title + "

"; + else album += "

" + albumJSON.title + "

"; + album += "" + albumJSON.sysdate + ""; album += "
"; - if(albumJSON.star=="1") album += ""; - if(albumJSON.public=="1") album += ""; - if(albumJSON.unsorted=="1") album += ""; + if(!lychee.publicMode&&albumJSON.star=="1") album += ""; + if(!lychee.publicMode&&albumJSON.public=="1") album += ""; + if(!lychee.publicMode&&albumJSON.unsorted=="1") album += ""; album += "
"; @@ -47,12 +59,13 @@ build = { photo: function(photoJSON) { + var photo = ""; + if(photoJSON=="") return ""; if(!photoJSON.title) photoJSON.title = ""; if(!photoJSON.thumbUrl) photoJSON.thumbUrl = "img/no_image.png"; if(photoJSON.title.length>18) photoJSON.title = photoJSON.title.substr(0, 18) + "..."; - var photo = ""; photo += "
"; photo += "thumb"; photo += "
"; @@ -61,7 +74,7 @@ build = { photo += "
"; if(photoJSON.star=="1") photo += ""; - if(photoJSON.public=="1") photo += ""; + if(!lychee.publicMode&&photoJSON.public=="1") photo += ""; photo += "
"; @@ -69,9 +82,26 @@ build = { }, + no_content: function(typ) { + + var no_content = ""; + + no_content += "
"; + no_content += ""; + + if (typ=="search") no_content += "

No results

"; + else if (typ=="picture") no_content += "

No public albums

"; + + no_content += "
"; + + return no_content; + + }, + modal: function(title, text, button, func) { var modal = ""; + modal += "
"; modal += "
"; modal += "

" + title + "

"; @@ -117,11 +147,15 @@ build = { modal += ""; modal += "
"; modal += "
"; - modal += "Add new Album"; + modal += "New Album"; + modal += "
"; + modal += ""; modal += "
"; modal += "
"; - modal += "Upload new Photo"; + modal += "Upload Photo"; modal += "
"; modal += "
"; modal += "
"; @@ -135,13 +169,13 @@ build = { var modal = ""; modal += "
"; modal += "
"; - modal += "

Sign in

"; + modal += "

Sign In

"; modal += ""; - modal += "
Version " + lychee.version + "
"; - modal += "Sign in"; + modal += "
Version " + lychee.version + "Update available!
"; + modal += "Sign in"; modal += "
"; modal += "
"; @@ -173,9 +207,8 @@ build = { $.each(items, function(index) { - if (items[index][1].length!=0) { - menu += "" + items[index][0] + ""; - } + if (items[index][0]=="separator"&&items[index][1].length==0) menu += ""; + else if (items[index][1].length!=0) menu += "" + items[index][0] + ""; }); @@ -194,8 +227,8 @@ build = { infobox += "
"; if (photo.public==1) photo.public = "Public"; else photo.public = "Private"; - if (forView==true) editTitleHTML = ""; else editTitleHTML = "
"; - if (forView==true) editDescriptionHTML = ""; else editDescriptionHTML = "
"; + if (forView==true||lychee.publicMode) editTitleHTML = ""; else editTitleHTML = "
"; + if (forView==true||lychee.publicMode) editDescriptionHTML = ""; else editDescriptionHTML = "
"; infos = [ ["", "Basics"], @@ -215,7 +248,7 @@ build = { ["Focal Length", photo.focal], ["ISO", photo.iso], ["", "Share"], - ["Privacy", photo.public], + ["Visibility", photo.public], ["Short Link", photo.shortlink] ]; diff --git a/js/modules/contextMenu.js b/js/modules/contextMenu.js old mode 100644 new mode 100755 index 6f9abbe..bd4de18 --- a/js/modules/contextMenu.js +++ b/js/modules/contextMenu.js @@ -22,7 +22,7 @@ contextMenu = { mouse_y -= $(document).scrollTop(); items = [ - ["Rename", "albums.rename(" + albumID + ")"], + ["Rename", "albums.setTitle(" + albumID + ")"], ["Delete", "albums.deleteDialog(" + albumID + ")"] ]; @@ -47,7 +47,7 @@ contextMenu = { mouse_y -= $(document).scrollTop(); items = [ - ["Rename", "photos.rename(" + photoID + ")"], + ["Rename", "photos.setTitle(" + photoID + ")"], ["Move to Album", "contextMenu.move(" + photoID + ", " + (mouse_x+150) + ", " + (mouse_y+$(document).scrollTop()) + ")"], ["Delete", "photos.deleteDialog(" + photoID + ")"] ]; @@ -67,25 +67,30 @@ contextMenu = { mouse_y -= $(document).scrollTop(); + if (!mouse_x||!mouse_y) { + mouse_x = "10px"; + mouse_y = "10px"; + } + lychee.api("getAlbums", "json", function(data) { if (lychee.content.attr("data-id")==0) { items = []; } else { items = [ - ["Unsorted", "photos.move(" + photoID + ", 0)"] + ["Unsorted", "photos.setAlbum(" + photoID + ", 0)"] ]; } if (!data.albums) { items = [ - ["Create new Album", "albums.add()"] + ["New Album", "albums.add()"] ]; } else { $.each(data.album, function(index) { if (this.id!=lychee.content.attr("data-id")) { if(!this.title) this.title = "Untitled"; - items[items.length] = new Array(this.title, "photos.move(" + photoID + ", " + this.id + ")"); + items[items.length] = new Array(this.title, "photos.setAlbum(" + photoID + ", " + this.id + ")"); } else { items[items.length] = new Array("", ""); } @@ -98,7 +103,7 @@ contextMenu = { $("body").append(build.contextMenu(items)); $(".contextmenu").css({ "top": mouse_y, - "left": mouse_x-150 + "left": mouse_x-$(".contextmenu").width() }); }); @@ -109,19 +114,57 @@ contextMenu = { mouse_y -= $(document).scrollTop(); + if (!mouse_x||!mouse_y) { + mouse_x = "10px"; + mouse_y = "10px"; + } + items = [ [" Make Private", "photos.setPublic()"], + ["separator", ""], [" Twitter", "photos.share(0, " + photoID + ")"], [" Facebook", "photos.share(1, " + photoID + ")"], [" Mail", "photos.share(2, " + photoID + ")"], - [" Copy Link", "photos.share(3, " + photoID + ")"], - [" Copy Shortlink", "photos.share(4, " + photoID + ")"] + [" Copy Link", "photos.share(3, " + photoID + ")"] + ]; + + if (lychee.bitlyUsername!="") items.push([" Copy Shortlink", "photos.share(4, " + photoID + ")"]); + + contextMenu.close(); + $("body") + .css("overflow", "hidden") + .append(build.contextMenu(items)); + $(".photo[data-id='" + photoID + "']").addClass("active"); + $(".contextmenu").css({ + "top": mouse_y, + "left": mouse_x + }); + + }, + + share_album: function(albumID, mouse_x, mouse_y) { + + mouse_y -= $(document).scrollTop(); + + if (!mouse_x||!mouse_y) { + mouse_x = "10px"; + mouse_y = "10px"; + } + + items = [ + [" Make Private", "albums.setPublic()"], + //[" Set Password", "albums.setPassword()"], + ["separator", ""], + [" Twitter", "albums.share(0, " + albumID + ")"], + [" Facebook", "albums.share(1, " + albumID + ")"], + [" Mail", "albums.share(2, " + albumID + ")"], + [" Copy Link", "albums.share(3, " + albumID + ")"] ]; contextMenu.close(); - $("body").css("overflow", "hidden"); - $(".photo[data-id='" + photoID + "']").addClass("active"); - $("body").append(build.contextMenu(items)); + $("body") + .css("overflow", "hidden") + .append(build.contextMenu(items)); $(".contextmenu").css({ "top": mouse_y, "left": mouse_x diff --git a/js/modules/loadingBar.js b/js/modules/loadingBar.js old mode 100644 new mode 100755 index 7ae4278..87a06d5 --- a/js/modules/loadingBar.js +++ b/js/modules/loadingBar.js @@ -10,48 +10,56 @@ loadingBar = { + status: null, + show: function(status, errorTitle, errorText) { - if (!status) status = "loading"; + clearTimeout(lychee.loadingBar.data("timeout")); - switch (status) { + if (status=="error"&&loadingBar.status!="error") { - case "error": - if (!errorTitle||!errorText) { - errorTitle = "Error"; - errorText = "Whoops, it looks like something went wrong. Please reload the site and try again!" - } + loadingBar.status = "error"; + + if (!errorTitle) errorTitle = "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("

" + errorTitle + ": " + errorText + "

") + .show() + .css("height", "40px"); + if (visible.controls()) lychee.header.css("margin-Top", "40px"); + + lychee.loadingBar.data("timeout", setTimeout(function () { loadingBar.hide(true) }, 3000)); + + } else if (loadingBar.status==null) { + + loadingBar.status = "loading"; + + lychee.loadingBar.data("timeout", setTimeout(function () { lychee.loadingBar - .removeClass("loading uploading error") - .addClass(status) - .html("

" + errorTitle + ": " + errorText + "

") .show() - .css("height", "40px"); - lychee.header.css("margin-Top", "40px"); - $.timer(3000,function(){ loadingBar.hide() }); - break; - - case "loading": - clearTimeout(lychee.loadingBar.data("timeout")); - lychee.loadingBar.data("timeout", setTimeout(function () { - lychee.loadingBar - .show() - .removeClass("loading uploading error") - .addClass(status); - if (visible.controls()) lychee.header.css("margin-Top", "3px"); - }, 1000)); - break; + .removeClass("loading uploading error") + .addClass("loading"); + if (visible.controls()) lychee.header.css("margin-Top", "3px"); + }, 1000)); } }, - hide: function() { + hide: function(force_hide) { - clearTimeout(lychee.loadingBar.data("timeout")); - lychee.loadingBar.html("").css("height", "3px"); - if (visible.controls()) lychee.header.css("marginTop", "0px"); - $.timer(300,function(){ lychee.loadingBar.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.css("marginTop", "0px"); + $.timer(300,function(){ lychee.loadingBar.hide(); }); + + } } diff --git a/js/modules/lychee.js b/js/modules/lychee.js old mode 100644 new mode 100755 index c7d604b..5bfb808 --- a/js/modules/lychee.js +++ b/js/modules/lychee.js @@ -12,9 +12,15 @@ lychee = { init: function(api_path, upload_path) { - this.version = "1.1"; + this.version = "1.2"; this.api_path = api_path; this.upload_path = upload_path; + this.update_path = "http://lychee.electerious.com/version/index.php"; + this.updateURL = "https://github.com/electerious/Lychee"; + this.publicMode = false; + + this.checkForUpdates = false; + this.bitlyUsername = ""; this.loadingBar = $("#loading"); this.header = $("header"); @@ -27,41 +33,70 @@ lychee = { ready: function() { - $("#tools_albums").show(); if (!mobileBrowser()) $(".tools").tipsy({gravity: 'n'}); - if (window.webkitNotifications) { window.webkitNotifications.requestPermission() }; + if (window.webkitNotifications) window.webkitNotifications.requestPermission(); - lychee.api("loggedIn", "text", function(data) { - if (data!=1) { - $("body").append(build.signInModal()); - $("#username").focus(); - if (localStorage) { - local_username = localStorage.getItem("username"); - if (local_username==null) return false; - if (local_username.length>1) $("#username").val(local_username); - $("#password").focus(); - } - } else if (data) { - $(window).bind("popstate", lychee.load); - lychee.load(); - } + lychee.api("init", "json", function(data) { + lychee.checkForUpdates = data.config.checkForUpdates; + lychee.bitlyUsername = data.config.bitlyUsername; + if (!data.loggedIn) lychee.setPublicMode(); + $(window).bind("popstate", lychee.load); + lychee.load(); }); }, - api: function(params, type, callback) { + setPublicMode: function() { + + this.publicMode = true; + + $("#button_signout, #search, #button_trash_album, #button_share_album, #button_edit_album, .button_add, #button_archive, .button_divider").remove(); + $("#button_trash, #button_move, #button_edit, #button_share, #button_star").remove(); + + $(document) + .on("mouseenter", "#title.editable", function() { $(this).removeClass("editable") }) + .off(event_name, "#title.editable") + .off("contextmenu", ".photo") + .off("contextmenu", ".album") + .off("drop"); + + $("#button_signin").show(); + + }, + + api: function(params, type, callback, loading) { + + if (loading==undefined) loadingBar.show(); $.ajax({ type: "POST", url: lychee.api_path, data: "function=" + params, dataType: type, - success: callback, + success: + function(data) { + $.timer(100, function(){ loadingBar.hide() }); + callback(data); + }, error: lychee.error }); }, + showLogin: function() { + + $("body").append(build.signInModal()); + $("#username").focus(); + if (localStorage) { + local_username = localStorage.getItem("username"); + if (local_username==null) return false; + if (local_username.length>0) $("#username").val(local_username); + $("#password").focus(); + } + if (lychee.checkForUpdates) lychee.update(); + + }, + login: function() { user = $("input#username").val(); @@ -70,10 +105,8 @@ lychee = { params = "login&user=" + user + "&password=" + password; lychee.api(params, "text", function(data) { if (data) { - if (localStorage) { localStorage.setItem("username", user); } - $(window).bind("popstate", lychee.load); - lychee.load(); - lychee.closeModal(); + localStorage.setItem("username", user); + window.location.reload(); } else { $("#password").val("").addClass("error"); $(".message .button.active").removeClass("pressed"); @@ -90,6 +123,15 @@ lychee = { }, + update: function() { + + $.ajax({ + url: lychee.update_path, + success: function(data) { if (data!=lychee.version) $("#version span").show(); } + }); + + }, + upload: function(files) { pre_progress = 0; @@ -151,6 +193,30 @@ lychee = { }, + importUrl: function() { + + link = prompt("Please enter the direct link to a photo to import it:", ""); + if (lychee.content.attr("data-id")=="") albumID = 0; + else albumID = lychee.content.attr("data-id"); + + lychee.closeModal(); + + if (link.length>3) { + + params = "importUrl&url=" + escape(link) + "&albumID=" + albumID; + lychee.api(params, "text", function(data) { + + if (data) { + if (lychee.content.attr("data-id")=="") lychee.goto("a0"); + else photos.load(lychee.content.attr("data-id")); + } else loadingBar.show("error"); + + }); + + } else if (link.length>0) loadingBar.show("error", "Error", "Link to short or too long. Please try another one!"); + + }, + load: function() { contextMenu.close(); @@ -168,11 +234,11 @@ lychee = { if (albumID&&photoID) { // Show ImageView - if (lychee.content.html()==""||$("#search").val().length!=0) { + if (lychee.content.html()==""||($("#search").length&&$("#search").val().length!=0)) { lychee.content.hide(); photos.load(albumID, true); } - photos.loadInfo(photoID); + photos.loadInfo(photoID, albumID); } else if (albumID) { @@ -232,7 +298,7 @@ lychee = { hideControls: function() { - if (visible.imageview()) { + if (visible.imageview()&&!visible.infobox()) { clearTimeout($(window).data("timeout")); $(window).data("timeout", setTimeout(function() { lychee.image_view.addClass("full"); diff --git a/js/modules/photos.js b/js/modules/photos.js old mode 100644 new mode 100755 index d25c10a..473744f --- a/js/modules/photos.js +++ b/js/modules/photos.js @@ -14,6 +14,15 @@ photos = { // If refresh is true the function will only refresh the content and not change the toolbar buttons either the title + /*password = localStorage.getItem("album" + albumID); + if (password==null) { + if (lychee.publicMode) password = prompt("Please enter a password for this album:", ""); else password = ""; + if (password!="") password = hex_md5(password); + localStorage.setItem("album" + albumID, password); + }*/ + + password = ""; + if (!refresh) { loadingBar.show(); if (visible.imageview()) photos.hideView(); @@ -23,9 +32,15 @@ photos = { startTime = new Date().getTime(); - params = "getPhotos&albumID=" + albumID; + params = "getPhotos&albumID=" + albumID + "&password=" + password; lychee.api(params, "json", function(data) { + if (data=="HTTP/1.1 403 Wrong password!") { + localStorage.removeItem("album" + albumID); + photos.load(albumID, refresh); + return false; + } + durationTime = (new Date().getTime() - startTime); if (durationTime>300) waitTime = 0; else if (refresh) waitTime = 0; else waitTime = 300 - durationTime; @@ -42,25 +57,38 @@ photos = { $("#tools_album").show(); $("img").retina(); - albums.loadInfo(albumID); + albums.loadInfo(albumID, password); } - }); + }, false); }); }, - loadInfo: function(photoID) { + loadInfo: function(photoID, albumID) { + + /*password = localStorage.getItem("album" + albumID); + if (password==null) { + if (lychee.publicMode) password = prompt("Please enter a password for this album:", ""); else password = ""; + if (password!="") password = hex_md5(password); + localStorage.setItem("album" + albumID, password); + }*/ + + password = ""; photos.showView(); - loadingBar.show(); - - params = "getPhotoInfo&photoID=" + photoID; + params = "getPhotoInfo&photoID=" + photoID + "&password=" + password; lychee.api(params, "json", function(data) { + if (data=="HTTP/1.1 403 Wrong password!") { + localStorage.removeItem("album" + albumID); + photos.loadInfo(photoID, albumID); + return false; + } + if (!data.title) data.title = "Untitled"; document.title = "Lychee - " + data.title; @@ -77,10 +105,10 @@ photos = { if (data.public=="1") { $("#button_share a").addClass("active"); - $("#button_share").attr("title", "Make Photo Private"); + $("#button_share").attr("title", "Share Photo"); } else { $("#button_share a").removeClass("active"); - $("#button_share").attr("title", "Share Photo"); + $("#button_share").attr("title", "Make Public"); } data.url = lychee.upload_path + data.url; @@ -99,8 +127,6 @@ photos = { $.timer(300,function(){ lychee.content.show(); }); - loadingBar.hide(); - }); }, @@ -180,8 +206,6 @@ photos = { delete: function(photoID) { - loadingBar.show(); - params = "deletePhoto&photoID=" + photoID; lychee.api(params, "text", function(data) { @@ -189,7 +213,6 @@ photos = { photos.hide(photoID); lychee.goto("a" + lychee.content.attr("data-id")); - loadingBar.hide(); } else loadingBar.show("error"); @@ -212,7 +235,7 @@ photos = { }, - rename: function(photoID) { + setTitle: function(photoID) { if (!photoID) oldTitle = lychee.title(); else oldTitle = ""; if (!photoID) photoID = lychee.image_view.attr("data-id"); @@ -221,8 +244,6 @@ photos = { if (photoID!=null&&photoID&&newTitle.length<31) { - loadingBar.show(); - if (newTitle=="") newTitle = "Untitled"; params = "setPhotoTitle&photoID=" + photoID + "&title=" + encodeURI(newTitle); @@ -235,7 +256,6 @@ photos = { document.title = "Lychee - " + newTitle; } $(".photo[data-id='" + photoID + "'] .overlay h1").html(newTitle); - loadingBar.hide(); } else loadingBar.show("error"); }); @@ -244,19 +264,16 @@ photos = { }, - move: function(photoID, albumID) { + setAlbum: function(photoID, albumID) { if (albumID>=0) { - loadingBar.show(); - - params = "movePhoto&photoID=" + photoID + "&albumID=" + albumID; + params = "setAlbum&photoID=" + photoID + "&albumID=" + albumID; lychee.api(params, "text", function(data) { if (data) { photos.hide(photoID); lychee.goto("a" + lychee.content.attr("data-id")); - loadingBar.hide(); } else loadingBar.show("error"); }); @@ -267,8 +284,6 @@ photos = { setStar: function() { - loadingBar.show(); - photoID = lychee.image_view.attr("data-id"); params = "setPhotoStar&photoID=" + photoID; @@ -285,7 +300,6 @@ photos = { } photos.load(lychee.content.attr("data-id"), true); - loadingBar.hide(); } else loadingBar.show("error"); @@ -295,8 +309,6 @@ photos = { setPublic: function(e) { - loadingBar.show(); - photoID = lychee.image_view.attr("data-id"); params = "setPhotoPublic&photoID=" + photoID + "&url=" + photos.getViewLink(photoID); @@ -306,15 +318,16 @@ photos = { if ($("#button_share a.active").length) { $("#button_share a").removeClass("active"); - $("#button_share").attr("title", "Make Private"); + $("#button_share").attr("title", "Make Public"); + $("#infobox .attr_visibility").html("Private"); } else { $("#button_share a").addClass("active"); $("#button_share").attr("title", "Share Photo"); + $("#infobox .attr_visibility").html("Public"); contextMenu.share(photoID, e.pageX, e.pageY); } photos.load(lychee.content.attr("data-id"), true); - loadingBar.hide(); } else loadingBar.show("error"); @@ -329,13 +342,12 @@ photos = { if (description.length>0&&description.length<160) { - loadingBar.show(); - params = "setPhotoDescription&photoID=" + photoID + "&description=" + escape(description); lychee.api(params, "text", function(data) { - if (data) photos.loadInfo(photoID); - else loadingBar.show("error"); + if (data) { + $("#infobox .attr_description").html(description + "
"); + } else loadingBar.show("error"); }); @@ -345,45 +357,39 @@ photos = { share: function(service, photoID) { - loadingBar.show(); + link = ""; + url = photos.getViewLink(photoID); - params = "sharePhoto&photoID=" + photoID + "&url=" + photos.getViewLink(photoID); - lychee.api(params, "json", function(data) { - - switch (service) { - case 0: - link = data.twitter; - break; - case 1: - link = data.facebook; - break; - case 2: - link = data.mail; - break; - case 3: - link = "copy"; - modal = build.modal("Copy Link", "You can use this link to share your image with other people: ", ["Close"], [""]); + switch (service) { + case 0: + link = "https://twitter.com/share?url=" + encodeURI(url); + break; + case 1: + link = "http://www.facebook.com/sharer.php?u=" + encodeURI(url) + "&t=" + encodeURI(lychee.title()); + break; + case 2: + link = "mailto:?subject=" + encodeURI(lychee.title()) + "&body=" + encodeURI("Hi! Check this out: " + url); + break; + case 3: + modal = build.modal("Copy Link", "Everyone can view your public photos, but only you can edit them. Use this link to share your photo with others: ", ["Close"], [""]); + $("body").append(modal); + $(".copylink").focus(); + break; + case 4: + params = "getShortlink&photoID=" + photoID; + lychee.api(params, "text", function(data) { + if (data=="") data = "Something went wrong!"; + modal = build.modal("Copy Shortlink", "Everyone can view your public photos, but only you can edit them. Use this link to share your photo with others: ", ["Close"], [""]); $("body").append(modal); $(".copylink").focus(); - break; - case 4: - link = "copy"; - modal = build.modal("Copy Shortlink", "You can use this link to share your image with other people: ", ["Close"], [""]); - $("body").append(modal); - $(".copylink").focus(); - break; - default: - link = ""; - break; - } + }); + break; + default: + link = ""; + break; + } - if (link=="copy") loadingBar.hide(); - else if (link.length>5) { - location.href = link; - loadingBar.hide(); - } else loadingBar.show("error"); - - }); + if (link.length>5) location.href = link; }, diff --git a/js/modules/search.js b/js/modules/search.js old mode 100644 new mode 100755 index 92b68e9..19c026c --- a/js/modules/search.js +++ b/js/modules/search.js @@ -26,21 +26,27 @@ search = { photosData = ""; if (data&&data.photos) $.each(data.photos, function() { photosData += build.photo(this); }); - if (albumsData==""&&photosData=="") code = ""; + if (albumsData==""&&photosData=="") code = "error"; else if (albumsData=="") code = build.divider("Photos")+photosData; else if (photosData=="") code = build.divider("Albums")+albumsData; else code = build.divider("Photos")+photosData+build.divider("Albums")+albumsData; if (lychee.content.attr("data-search")!=code) { + $(".no_content").remove(); + lychee.animate(".album, .photo", "contentZoomOut"); lychee.animate(".divider", "fadeOut"); $.timer(300,function(){ lychee.content.attr("data-search", code); - lychee.content.html(code); - lychee.animate(".album, .photo", "contentZoomIn"); + + if (code=="error") $("body").append(build.no_content("search")); + else { + lychee.content.html(code); + lychee.animate(".album, .photo", "contentZoomIn"); + } }); @@ -57,6 +63,7 @@ search = { reset: function() { $("#search").val(""); + $(".no_content").remove(); if (lychee.content.attr("data-search")!="") { diff --git a/js/modules/visible.js b/js/modules/visible.js old mode 100644 new mode 100755 diff --git a/js/view.js b/js/view.js index f0d9a43..5a9632d 100755 --- a/js/view.js +++ b/js/view.js @@ -80,7 +80,7 @@ function hideInfobox() { function loadPhotoInfo(photoID) { - params = "function=getPhotoInfo&photoID=" + photoID; + params = "function=getPhotoInfo&photoID=" + photoID + "&password=''"; $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { if (!data.title) data.title = "Untitled"; diff --git a/lychee.sql b/lychee.sql old mode 100644 new mode 100755 index e1dbaa8..7e5e6b0 --- a/lychee.sql +++ b/lychee.sql @@ -10,6 +10,8 @@ CREATE TABLE IF NOT EXISTS `lychee_albums` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(50) NOT NULL, `sysdate` varchar(10) NOT NULL, + `public` TINYINT(1) DEFAULT '0', + `password` VARCHAR(100), PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; diff --git a/php/api.php b/php/api.php old mode 100644 new mode 100755 index 1bd4377..325e001 --- a/php/api.php +++ b/php/api.php @@ -7,79 +7,101 @@ * @copyright 2013 by Philipp Maurer, Tobias Reich */ -if(floatval(phpversion())<5.2) die("Please upgrade to PHP 5.2 or higher!"); +if (floatval(phpversion())<5.2) die('Please upgrade to PHP 5.2 or higher!'); -if((isset($_POST["function"])&&$_POST["function"]!="")||(isset($_GET["function"])&&$_GET["function"]!="")) { +if (!empty($_POST['function'])||!empty($_GET['function'])) { - session_start(); - define("LYCHEE", true); + session_start(); + define('LYCHEE', true); - include("array2json.php"); - include("config.php"); - include("functions.php"); + require('config.php'); + require('functions.php'); - // Security - if(isset($_POST["albumID"])&&($_POST["albumID"]==""||$_POST["albumID"]<0)) exit("Wrong parameter type for 'albumID'!"); - if(isset($_POST["photoID"])&&$_POST["photoID"]=="") exit("Wrong parameter type for 'photoID'!"); + // Security + if (isset($_POST['albumID'])&&($_POST['albumID']==''||$_POST['albumID']<0)) exit('Wrong parameter type for albumID!'); + if (isset($_POST['photoID'])&&$_POST['photoID']=='') exit('Wrong parameter type for photoID!'); - if($_SESSION["login"]==true) { + //Connect to DB + $database = dbConnect(); - //Connect to DB - $database = dbConnect(); + if (isset($_SESSION['login'])&&$_SESSION['login']==true) { + + /** + * Admin Mode + * Full access to Lychee. Only with correct password. + */ // Album Functions - if($_POST["function"]=="getAlbums") echo array2json(getAlbums()); - if($_POST["function"]=="getSmartInfo") echo array2json(getSmartInfo()); - if($_POST["function"]=="addAlbum"&&isset($_POST["title"])) echo addAlbum($_POST["title"]); - if($_POST["function"]=="getAlbumInfo"&&isset($_POST["albumID"])) echo array2json(getAlbumInfo($_POST["albumID"])); - if($_POST["function"]=="setAlbumTitle"&&isset($_POST["albumID"])&&isset($_POST["title"])) echo setAlbumTitle($_POST["albumID"], $_POST["title"]); - if($_POST["function"]=="deleteAlbum"&&isset($_POST["albumID"])&&isset($_POST["delAll"])) echo deleteAlbum($_POST["albumID"], $_POST["delAll"]); - if($_GET["function"]=="getAlbumArchive"&&isset($_GET["albumID"])) getAlbumArchive($_GET["albumID"]); + if ($_POST['function']=='getAlbums') echo json_encode(getAlbums(false)); + if ($_POST['function']=='getSmartInfo') echo json_encode(getSmartInfo()); + if ($_POST['function']=='addAlbum'&&isset($_POST['title'])) echo addAlbum($_POST['title']); + if ($_POST['function']=='getAlbumInfo'&&isset($_POST['albumID'])) echo json_encode(getAlbumInfo($_POST['albumID'])); + if ($_POST['function']=='setAlbumTitle'&&isset($_POST['albumID'])&&isset($_POST['title'])) echo setAlbumTitle($_POST['albumID'], $_POST['title']); + if ($_POST['function']=='setAlbumPublic'&&isset($_POST['albumID'])) echo setAlbumPublic($_POST['albumID']); + if ($_POST['function']=='setAlbumPassword'&&isset($_POST['albumID'])&&isset($_POST['password'])) echo setAlbumPassword($_POST['albumID'], $_POST['password']); + if ($_POST['function']=='deleteAlbum'&&isset($_POST['albumID'])&&isset($_POST['delAll'])) echo deleteAlbum($_POST['albumID'], $_POST['delAll']); + if (isset($_GET['function'])&&$_GET['function']=='getAlbumArchive'&&isset($_GET['albumID'])) getAlbumArchive($_GET['albumID']); // Photo Functions - if($_POST["function"]=="getPhotos"&&isset($_POST["albumID"])) echo array2json(getPhotos($_POST["albumID"])); - if($_POST["function"]=="getPhotoInfo"&&isset($_POST["photoID"])) echo array2json(getPhotoInfo($_POST["photoID"])); - if($_POST["function"]=="movePhoto"&&isset($_POST["photoID"])&&isset($_POST["albumID"])) echo movePhoto($_POST["photoID"], $_POST["albumID"]); - if($_POST["function"]=="deletePhoto"&&isset($_POST["photoID"])) echo deletePhoto($_POST["photoID"]); - if($_POST["function"]=="setPhotoTitle"&&isset($_POST["photoID"])&&isset($_POST["title"])) echo setPhotoTitle($_POST["photoID"], $_POST["title"]); - if($_POST["function"]=="setPhotoStar"&&isset($_POST["photoID"])) echo setPhotoStar($_POST["photoID"]); - if($_POST["function"]=="setPhotoPublic"&&isset($_POST["photoID"])&&isset($_POST["url"])) echo setPhotoPublic($_POST["photoID"], $_POST["url"]); - if($_POST["function"]=="setPhotoDescription"&&isset($_POST["photoID"])&&isset($_POST["description"])) echo setPhotoDescription($_POST["photoID"], $_POST["description"]); - if($_POST["function"]=="sharePhoto"&&isset($_POST["photoID"])&&isset($_POST["url"])) echo array2json(sharePhoto($_POST["photoID"], $_POST["url"])); - if($_POST["function"]=="previousPhoto"&&isset($_POST["photoID"])&&isset($_POST["albumID"])) echo array2json(previousPhoto($_POST["photoID"], $_POST["albumID"])); - if($_POST["function"]=="nextPhoto"&&isset($_POST["photoID"])&&isset($_POST["albumID"])) echo array2json(nextPhoto($_POST["photoID"], $_POST["albumID"])); + if ($_POST['function']=='getPhotos'&&isset($_POST['albumID'])) echo json_encode(getPhotos($_POST['albumID'])); + if ($_POST['function']=='getPhotoInfo'&&isset($_POST['photoID'])) echo json_encode(getPhotoInfo($_POST['photoID'])); + if ($_POST['function']=='getShortlink'&&isset($_POST['photoID'])) echo getShortlink($_POST['photoID']); + if ($_POST['function']=='setAlbum'&&isset($_POST['photoID'])&&isset($_POST['albumID'])) echo setAlbum($_POST['photoID'], $_POST['albumID']); + if ($_POST['function']=='deletePhoto'&&isset($_POST['photoID'])) echo deletePhoto($_POST['photoID']); + if ($_POST['function']=='setPhotoTitle'&&isset($_POST['photoID'])&&isset($_POST['title'])) echo setPhotoTitle($_POST['photoID'], $_POST['title']); + if ($_POST['function']=='setPhotoStar'&&isset($_POST['photoID'])) echo setPhotoStar($_POST['photoID']); + if ($_POST['function']=='setPhotoPublic'&&isset($_POST['photoID'])&&isset($_POST['url'])) echo setPhotoPublic($_POST['photoID'], $_POST['url']); + if ($_POST['function']=='setPhotoDescription'&&isset($_POST['photoID'])&&isset($_POST['description'])) echo setPhotoDescription($_POST['photoID'], $_POST['description']); + if ($_POST['function']=='previousPhoto'&&isset($_POST['photoID'])&&isset($_POST['albumID'])) echo json_encode(previousPhoto($_POST['photoID'], $_POST['albumID'], false)); + if ($_POST['function']=='nextPhoto'&&isset($_POST['photoID'])&&isset($_POST['albumID'])) echo json_encode(nextPhoto($_POST['photoID'], $_POST['albumID'], false)); - // Upload Function - if($_POST["function"]=="upload"&&isset($_FILES)&&isset($_POST["albumID"])) echo upload($_FILES, $_POST["albumID"]); + // Add Function + if ($_POST['function']=='upload'&&isset($_FILES)&&isset($_POST['albumID'])) echo upload($_FILES, $_POST['albumID']); + if ($_POST['function']=='importUrl'&&isset($_POST['url'])&&isset($_POST['albumID'])) echo importUrl($_POST['url'], $_POST['albumID']); // Search Function - if($_POST["function"]=="search"&&isset($_POST["term"])) echo array2json(search($_POST["term"])); - - // Sync Function - if($_POST["function"]=="syncFolder") echo syncFolder(); + if ($_POST['function']=='search'&&isset($_POST['term'])) echo json_encode(search($_POST['term'])); // Session Functions - if($_POST["function"]=="login") echo login($_POST['user'], $_POST['password']); - if($_POST["function"]=="logout") logout(); - if($_POST["function"]=="loggedIn") echo true; + if ($_POST['function']=='init') echo json_encode(init('admin')); + if ($_POST['function']=='login') echo login($_POST['user'], $_POST['password']); + if ($_POST['function']=='logout') logout(); - } else { + } else { - $database = dbConnect(); + /** + * Public Mode + * Access to view all public folders and photos in Lychee. + */ + + // Album Functions + if ($_POST['function']=='getAlbums') echo json_encode(getAlbums(true)); + if ($_POST['function']=='getAlbumInfo'&&isset($_POST['albumID'])&&isset($_POST['password'])&&isAlbumPublic($_POST['albumID'], $_POST['password'])) echo json_encode(getAlbumInfo($_POST['albumID'])); // Photo Functions - if($_POST["function"]=="getPhotoInfo"&&isset($_POST["photoID"])&&isPhotoPublic($_POST["photoID"])) echo array2json(getPhotoInfo($_POST["photoID"])); + if ($_POST['function']=='getPhotos') { + if (isset($_POST['albumID'])&&isset($_POST['password'])&&isAlbumPublic($_POST['albumID'], $_POST['password'])) echo json_encode(getPhotos($_POST['albumID'])); + else echo json_encode('HTTP/1.1 403 Wrong password!'); + } - // Session Functions - if($_POST["function"]=="login") echo login($_POST['user'], $_POST['password']); - if($_POST["function"]=="loggedIn") echo false; + if ($_POST['function']=='getPhotoInfo') { + if (isset($_POST['photoID'])&&isset($_POST['password'])&&isPhotoPublic($_POST['photoID'], $_POST['password'])) echo json_encode(getPhotoInfo($_POST['photoID'])); + else echo json_encode('HTTP/1.1 403 Wrong password!'); + } - } + if ($_POST['function']=='previousPhoto'&&isset($_POST['photoID'])&&isset($_POST['albumID'])) echo json_encode(previousPhoto($_POST['photoID'], $_POST['albumID'], false)); + if ($_POST['function']=='nextPhoto'&&isset($_POST['photoID'])&&isset($_POST['albumID'])) echo json_encode(nextPhoto($_POST['photoID'], $_POST['albumID'], false)); + + // Session Functions + if ($_POST['function']=='init') echo json_encode(init('public')); + if ($_POST['function']=='login') echo login($_POST['user'], $_POST['password']); + + } } else { header('HTTP/1.1 401 Unauthorized'); - die("Error: No permission!"); + die('Error: No permission!'); } diff --git a/php/array2json.php b/php/array2json.php deleted file mode 100755 index b67d8c1..0000000 --- a/php/array2json.php +++ /dev/null @@ -1,43 +0,0 @@ -$value) { - if(is_array($value)) { //Custom handling for arrays - if($is_list) $parts[] = array2json($value); /* :RECURSION: */ - else $parts[] = '"' . $key . '":' . array2json($value); /* :RECURSION: */ - } else { - $str = ''; - if(!$is_list) $str = '"' . $key . '":'; - - //Custom handling for multiple data types - if(is_numeric($value)) $str .= $value; //Numbers - elseif($value === false) $str .= 'false'; //The booleans - elseif($value === true) $str .= 'true'; - else $str .= '"' . addslashes($value) . '"'; //All other things - // :TODO: Is there any more datatype we should be in the lookout for? (Object?) - - $parts[] = $str; - } - } - $json = implode(',',$parts); - - if($is_list) return '[' . $json . ']';//Return numerical JSON - return '{' . $json . '}';//Return associative JSON -} -?> \ No newline at end of file diff --git a/php/check.php b/php/check.php index 7c276a7..bf06453 100644 --- a/php/check.php +++ b/php/check.php @@ -1,39 +1,45 @@ \n"); + if (floatval(phpversion())<5.2) $error .= ('Error 100: Please upgrade to PHP 5.2 or higher!
\n'); // Extensions - if (!extension_loaded("exif")) $error .= ("Error 200: PHP exif extension not activated.
\n"); - if (!extension_loaded("mbstring")) $error .= ("Error 201: PHP mbstring extension not activated.
\n"); - if (!extension_loaded("gd")) $error .= ("Error 202: PHP gd extension not activated.
\n"); - if (!extension_loaded("mysqli")) $error .= ("Error 203: PHP mysqli extension not activated.
\n"); + if (!extension_loaded('exif')) $error .= ('Error 200: PHP exif extension not activated.
\n'); + if (!extension_loaded('mbstring')) $error .= ('Error 201: PHP mbstring extension not activated.
\n'); + if (!extension_loaded('gd')) $error .= ('Error 202: PHP gd extension not activated.
\n'); + if (!extension_loaded('mysqli')) $error .= ('Error 203: PHP mysqli extension not activated.
\n'); // Config - if (!$db||$db=="") $error .= ("Error 300: No property for \$db in config.php.
\n"); - if (!$dbUser||$dbUser=="") $error .= ("Error 301: No property for \$dbUser in config.php.
\n"); - if (!$dbPassword||$dbPassword=="") $error .= ("Error 302: No property for \$dbPassword in config.php.
\n"); - if (!$dbHost||$dbHost=="") $error .= ("Error 303: No property for \$dbHost in config.php.
\n"); - if (!$user||$user=="") $error .= ("Error 304: No property for \$user in config.php.
\n"); - if (!$password||$password=="") $error .= ("Error 305: No property for \$password in config.php.
\n"); + if (!$db||$db=='') $error .= ('Error 300: No property for \$db in config.php.
\n'); + if (!$dbUser||$dbUser=='') $error .= ('Error 301: No property for \$dbUser in config.php.
\n'); + if (!$dbPassword||$dbPassword=='') $error .= ('Error 302: No property for \$dbPassword in config.php.
\n'); + if (!$dbHost||$dbHost=='') $error .= ('Error 303: No property for \$dbHost in config.php.
\n'); + if (!$user||$user=='') $error .= ('Error 304: No property for \$user in config.php.
\n'); + if (!$password||$password=='') $error .= ('Error 305: No property for \$password in config.php.
\n'); + + // Additional Config + //if ($checkForUpdates!=true&&heckForUpdates!=false) $error .= ('Error 306: No property for \$checkForUpdates in config.php.
\n'); + if (!is_numeric($thumbQuality)||$thumbQuality<=0||$thumbQuality>=100) $error .= ('Error 307: Wrong property for \$thumbQuality in config.php.
\n'); + if ($sorting!='ASC'&&$sorting!='DESC') $error .= ('Error 308: Wrong property for \$sorting in config.php.
\n'); // Database $database = new mysqli($dbHost, $dbUser, $dbPassword, $db); - if (mysqli_connect_errno()!=0) $error .= ("Error 400: " . mysqli_connect_errno() . ": " . mysqli_connect_error() . "
\n"); + if (mysqli_connect_errno()!=0) $error .= ('Error 400: ' . mysqli_connect_errno() . ': ' . mysqli_connect_error() . '
\n'); // Permissions - if (substr(sprintf('%o', fileperms("../uploads/big/")), -4) != "0777") $error .= ("Error 500: Wrong permissions for \"/uploads/big\" (777 required).
\n"); - if (substr(sprintf('%o', fileperms("../uploads/thumb/")), -4) != "0777") $error .= ("Error 501: Wrong permissions for \"/uploads/thumb\" (777 required).
\n"); - if (substr(sprintf('%o', fileperms("../uploads/import/")), -4) != "0777") $error .= ("Error 502: Wrong permissions for \"/uploads/import\" (777 required).
\n"); + if (substr(sprintf('%o', fileperms('../uploads/big/')), -4)!='0777') $error .= ('Error 500: Wrong permissions for \'/uploads/big\' (777 required).
\n'); + if (substr(sprintf('%o', fileperms('../uploads/thumb/')), -4)!='0777') $error .= ('Error 501: Wrong permissions for \'/uploads/thumb\' (777 required).
\n'); + if (substr(sprintf('%o', fileperms('../uploads/import/')), -4)!='0777') $error .= ('Error 502: Wrong permissions for \'/uploads/import\' (777 required).
\n'); + if (substr(sprintf('%o', fileperms('../uploads/')), -4)!='0777') $error .= ('Error 503: Wrong permissions for \'/uploads\' (777 required).
\n'); - if ($error == "") echo("Lychee is ready!"); else echo $error; + if ($error=='') echo('Lychee is ready!'); else echo $error; ?> \ No newline at end of file diff --git a/php/config.php b/php/config.php index 17cf615..e6ba8c6 100755 --- a/php/config.php +++ b/php/config.php @@ -7,21 +7,23 @@ * @copyright 2013 by Philipp Maurer, Tobias Reich */ -if(!defined('LYCHEE')) die("Direct access is not allowed!"); +if(!defined('LYCHEE')) die('Direct access is not allowed!'); -//Database configurations -$db = "lychee"; //Database name -$dbUser = "lychee"; //Username of the database -$dbPassword = "lychee_passwd"; //Password of the Database -$dbHost = "localhost"; //Host of the Database +// Database configurations +$db = 'lychee'; //Database name +$dbUser = 'lychee'; //Username of the database +$dbPassword = 'lychee_passwd'; //Password of the Database +$dbHost = 'localhost'; //Host of the Database -//Lychee user configuration -$user = "lychee"; //lychee username -$password = "1234"; //lychee password +// Admin Login +$user = 'lychee'; //Admin Username +$password = '1234'; //Admin Password -//Additional settings +// Additional settings +$checkForUpdates = true; $thumbQuality = 95; //Quality of the Thumbs (0-100). Default: 95 -$bitlyUsername = ""; //Your Bit.ly Username -$bitlyApi = ""; //Your Bit.ly API Key +$sorting = 'DESC'; //ASC or DESC sorting of albums and photos +$bitlyUsername = ''; //Your Bit.ly Username +$bitlyApi = ''; //Your Bit.ly API Key ?> \ No newline at end of file diff --git a/php/functions.php b/php/functions.php index 7963142..020791e 100644 --- a/php/functions.php +++ b/php/functions.php @@ -7,7 +7,7 @@ * @copyright 2013 by Philipp Maurer, Tobias Reich */ -if(!defined('LYCHEE')) die("Direct access is not allowed!"); +if(!defined('LYCHEE')) die('Direct access is not allowed!'); // Database Functions function dbConnect() { @@ -26,16 +26,14 @@ function dbConnect() { } function dbClose() { global $database; - $close = $database->close(); - if(!$close) { + if(!$database->close()) { echo "Closing the connection failed!"; return false; } return true; } function createDatabase($db, $database) { - $query = "CREATE DATABASE IF NOT EXISTS $db;"; - $result = $database->query($query); + $result = $database->query("CREATE DATABASE IF NOT EXISTS $db;"); $database->select_db($db); if(!$result) return false; return true; @@ -45,6 +43,8 @@ function createTables($database) { `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(50) NOT NULL, `sysdate` varchar(10) NOT NULL, + `public` TINYINT(1) DEFAULT '0', + `password` VARCHAR(100), PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;"; $result = $database->query($query); @@ -147,7 +147,6 @@ function upload($files, $albumID) { } function getCamera($photoID) { global $database; - $return = array(); $url = "../uploads/big/$photoID"; $type = getimagesize($url); $type = $type['mime']; @@ -236,17 +235,22 @@ function createThumb($photoName, $width = 200, $width2x = 400, $height = 200, $h } // Session Functions +function init($mode) { + global $checkForUpdates, $bitlyUsername; + $return["config"]["checkForUpdates"] = $checkForUpdates; + $return["config"]["bitlyUsername"] = $bitlyUsername; + if ($mode=="admin") $return["loggedIn"] = true; + else $return["loggedIn"] = false; + return $return; +} function login($loginUser, $loginPassword) { global $database, $user, $password; - if(($loginUser == $user) && ($loginPassword == md5($password))){ + if ($loginUser==$user&&$loginPassword==md5($password)) { + // Admin Login $_SESSION['login'] = true; - ini_set("session.cookie_lifetime","86400"); - ini_set("session.gc_maxlifetime", 86400); - ini_set("session.gc_probability",1); - ini_set("session.gc_divisor",1); return true; } else { - return false; + return false; } } function logout() { @@ -258,38 +262,46 @@ function logout() { function addAlbum($title) { global $database; $title = mysqli_real_escape_string($database, $title); + if(strlen($title)<1||strlen($title)>30) return false; $sysdate = date("d.m.Y"); $query = "INSERT INTO lychee_albums (title, sysdate) VALUES ('$title', '$sysdate');"; $result = $database->query($query); if(!$result) return false; return $database->insert_id; } -function getAlbums() { - global $database; - $return = array(array(array())); +function getAlbums($public) { + global $database, $sorting; // Smart Albums - $return = getSmartInfo(); + if (!$public) $return = getSmartInfo(); // Albums - $query = "SELECT id, title, sysdate FROM lychee_albums ORDER BY id DESC;"; + if ($public) $query = "SELECT * FROM lychee_albums WHERE public = 1 ORDER BY id $sorting;"; + else $query = "SELECT * FROM lychee_albums ORDER BY id $sorting;"; $result = $database->query($query) OR die("Error: $result
".$database->error); $i=0; while($row = $result->fetch_object()) { $return["album"][$i]['id'] = $row->id; $return["album"][$i]['title'] = $row->title; + $return["album"][$i]['public'] = $row->public; $return["album"][$i]['sysdate'] = $row->sysdate; - $albumID = $row->id; - $query = "SELECT thumbUrl FROM lychee_photos WHERE album = '$albumID' ORDER BY id DESC LIMIT 0, 3;"; - $result2 = $database->query($query); - $k = 0; - while($row2 = $result2->fetch_object()){ - $return["album"][$i]["thumb$k"] = $row2->thumbUrl; - $k++; + if ($row->password=="") $return["album"][$i]['password'] = false; + else $return["album"][$i]['password'] = true; + + // Thumbs + if (($public&&$row->password=="")||(!$public)) { + $albumID = $row->id; + $query = "SELECT thumbUrl FROM lychee_photos WHERE album = '$albumID' ORDER BY id $sorting LIMIT 0, 3;"; + $result2 = $database->query($query); + $k = 0; + while($row2 = $result2->fetch_object()){ + $return["album"][$i]["thumb$k"] = $row2->thumbUrl; + $k++; + } + if(!isset($return["album"][$i]["thumb0"]))$return["album"][$i]["thumb0"]=""; + if(!isset($return["album"][$i]["thumb1"]))$return["album"][$i]["thumb1"]=""; + if(!isset($return["album"][$i]["thumb2"]))$return["album"][$i]["thumb2"]=""; } - if(!isset($return["album"][$i]["thumb0"]))$return[$i]["thumb0"]=""; - if(!isset($return["album"][$i]["thumb1"]))$return[$i]["thumb1"]=""; - if(!isset($return["album"][$i]["thumb2"]))$return[$i]["thumb2"]=""; $i++; } if($i==0) $return["albums"] = false; @@ -297,9 +309,8 @@ function getAlbums() { return $return; } function getSmartInfo() { - global $database; - $return = array(array()); - $query = "SELECT * FROM lychee_photos WHERE album = 0 ORDER BY id DESC;"; + global $database, $sorting; + $query = "SELECT * FROM lychee_photos WHERE album = 0 ORDER BY id $sorting;"; $result = $database->query($query); $i = 0; while($row = $result->fetch_object()) { @@ -308,7 +319,7 @@ function getSmartInfo() { } $return['unsortNum'] = $i; - $query2 = "SELECT * FROM lychee_photos WHERE public = 1 ORDER BY id DESC;"; + $query2 = "SELECT * FROM lychee_photos WHERE public = 1 ORDER BY id $sorting;"; $result2 = $database->query($query2); $i = 0; while($row2 = $result2->fetch_object()) { @@ -317,7 +328,7 @@ function getSmartInfo() { } $return['publicNum'] = $i; - $query3 = "SELECT * FROM lychee_photos WHERE star = 1 ORDER BY id DESC;"; + $query3 = "SELECT * FROM lychee_photos WHERE star = 1 ORDER BY id $sorting;"; $result3 = $database->query($query3); $i = 0; while($row3 = $result3->fetch_object()) { @@ -329,13 +340,11 @@ function getSmartInfo() { } function getAlbumInfo($albumID) { global $database; - $return = array(); $query = "SELECT * FROM lychee_albums WHERE id = '$albumID';"; $result = $database->query($query); $row = $result->fetch_object(); $return['title'] = $row->title; $return['date'] = $row->sysdate; - $return['star'] = $row->star; $return['public'] = $row->public; $query = "SELECT COUNT(*) AS num FROM lychee_photos WHERE album = '$albumID';"; $result = $database->query($query); @@ -346,7 +355,7 @@ function getAlbumInfo($albumID) { function setAlbumTitle($albumID, $title) { global $database; $title = mysqli_real_escape_string($database, urldecode($title)); - if(strlen($title)<3||strlen($title)>30) return false; + if(strlen($title)<1||strlen($title)>30) return false; $query = "UPDATE lychee_albums SET title = '$title' WHERE id = '$albumID';"; $result = $database->query($query); if(!$result) return false; @@ -400,7 +409,7 @@ function getAlbumArchive($albumID) { $result = $database->query($query); $row = $result->fetch_object(); if($albumID!=0&&is_numeric($albumID))$zipTitle = $row->title; - $filename = "./".$zipTitle.".zip"; + $filename = "../uploads/".$zipTitle.".zip"; $zip = new ZipArchive(); @@ -418,24 +427,57 @@ function getAlbumArchive($albumID) { header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=\"$zipTitle.zip\""); + header("Content-Length: ".filesize($filename)); readfile($filename); unlink($filename); return true; } +function setAlbumPublic($albumID) { + global $database; + $query = "SELECT public FROM lychee_albums WHERE id = '$albumID';"; + $result = $database->query($query); + $row = $result->fetch_object(); + if($row->public == 0){ + $public = 1; + }else{ + $public = 0; + } + $query = "UPDATE lychee_albums SET public = '$public', password = NULL WHERE id = '$albumID';"; + $result = $database->query($query); + if(!$result) return false; + return true; +} +function setAlbumPassword($albumID, $password) { + global $database; + $query = "UPDATE lychee_albums SET password = '$password' WHERE id = '$albumID';"; + $result = $database->query($query); + if(!$result) return false; + return true; +} +function isAlbumPublic($albumID, $password) { + global $database; + $query = "SELECT public, password FROM lychee_albums WHERE id = '$albumID';"; + $result = $database->query($query); + $row = $result->fetch_object(); + if(($row->public == 1) && ($row->password == $password)){ + return true; + }else{ + return false; + } +} // Photo Functions function getPhotos($albumID) { - global $database; + global $database, $sorting; switch($albumID) { - case "f": $query = "SELECT * FROM lychee_photos WHERE star = 1 ORDER BY id DESC;"; + case "f": $query = "SELECT id, title, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE star = 1 ORDER BY id $sorting;"; break; - case "s": $query = "SELECT * FROM lychee_photos WHERE public = 1 ORDER BY id DESC;"; + case "s": $query = "SELECT id, title, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE public = 1 ORDER BY id $sorting;"; break; - default: $query = "SELECT * FROM lychee_photos WHERE album = '$albumID' ORDER BY id DESC;"; + default: $query = "SELECT id, title, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE album = '$albumID' ORDER BY id $sorting;"; } $result = $database->query($query); - $return = array(array()); $i = 0; while($row = $result->fetch_array()) { $return[$i] = $row; @@ -451,10 +493,10 @@ function getPhotoInfo($photoID) { $result = $database->query($query); $row = $result->fetch_object(); if($row->quantity == 0) { - importPhoto($photoID); + importPhoto($photoID, 's'); } if(is_file("../uploads/import/$photoID")) { - importPhoto($photoID); + importPhoto($photoID, 's'); } $query = "SELECT * FROM lychee_photos WHERE import_name = '../uploads/import/$photoID' ORDER BY ID DESC;"; } else { @@ -488,13 +530,6 @@ function downloadPhoto($photoID) { unlink($filename); return true; } -function countPhotos() { - global $database; - $query = "SELECT COUNT(*) AS num FROM lychee_photos;"; - $result = $database->query($query); - $row = $result->fetch_object(); - return $row->num; -} function setPhotoPublic($photoID, $url) { global $database; $query = "SELECT public, shortlink FROM lychee_photos WHERE id = '$photoID';"; @@ -533,8 +568,9 @@ function setPhotoStar($photoID) { $result = $database->query($query); return true; } -function nextPhoto($photoID, $albumID) { - global $database; +function nextPhoto($photoID, $albumID, $innerCall) { + global $database, $sorting; + if (!$innerCall&&$sorting=="ASC") return previousPhoto($photoID, $albumID, true); switch($albumID) { case 'f': $query = "SELECT * FROM lychee_photos WHERE id < '$photoID' AND star = '1' ORDER BY id DESC LIMIT 0, 1;"; break; @@ -557,14 +593,15 @@ function nextPhoto($photoID, $albumID) { } return $return; } -function previousPhoto($photoID, $albumID) { - global $database; +function previousPhoto($photoID, $albumID, $innerCall) { + global $database, $sorting; + if (!$innerCall&&$sorting=="ASC") return nextPhoto($photoID, $albumID, true); switch($albumID) { - case 'f': $query = "SELECT * FROM lychee_photos WHERE id > '$photoID' AND star = '1' LIMIT 0, 1;"; + case 'f': $query = "SELECT * FROM lychee_photos WHERE id > '$photoID' AND star = '1' ORDER BY id LIMIT 0, 1;"; break; - case 's': $query = "SELECT * FROM lychee_photos WHERE id > '$photoID' AND public = '1' LIMIT 0, 1;"; + case 's': $query = "SELECT * FROM lychee_photos WHERE id > '$photoID' AND public = '1' ORDER BY id LIMIT 0, 1;"; break; - default: $query = "SELECT * FROM lychee_photos WHERE id > '$photoID' AND album = '$albumID' LIMIT 0, 1;"; + default: $query = "SELECT * FROM lychee_photos WHERE id > '$photoID' AND album = '$albumID' ORDER BY id LIMIT 0, 1;"; } $result = $database->query($query); $return = $result->fetch_array(); @@ -581,7 +618,7 @@ function previousPhoto($photoID, $albumID) { } return $return; } -function movePhoto($photoID, $newAlbum) { +function setAlbum($photoID, $newAlbum) { global $database; $query = "UPDATE lychee_photos SET album = '$newAlbum' WHERE id = '$photoID';"; $result = $database->query($query); @@ -622,8 +659,7 @@ function deletePhoto($photoID) { if(!$result) return false; return true; } -function importPhoto($name) { - global $database; +function importPhoto($name, $albumID) { $tmp_name = "../uploads/import/$name"; $details = getimagesize($tmp_name); $size = filesize($tmp_name); @@ -633,9 +669,20 @@ function importPhoto($name) { $nameFile[0]['tmp_name'] = $tmp_name; $nameFile[0]['error'] = 0; $nameFile[0]['size'] = $size; - if(!upload($nameFile, 's')) return false; + if(!upload($nameFile, $albumID)) return false; else return true; } +function importUrl($url, $albumID) { + if (@getimagesize($url)) { + $pathinfo = pathinfo($url); + $filename = $pathinfo['filename'].".".$pathinfo['extension']; + $tmp_name = "../uploads/import/$filename"; + copy($url, $tmp_name); + return importPhoto($filename, $albumID); + } else { + return false; + } +} // Share Functions function urlShortner($url) { @@ -650,30 +697,12 @@ function urlShortner($url) { $shortlink = $xml->results->nodeKeyVal->shortUrl; return $shortlink; } -function sharePhoto($photoID, $url) { +function getShortlink($photoID) { global $database; $query = "SELECT * FROM lychee_photos WHERE id = '$photoID';"; $result = $database->query($query); $row = $result->fetch_object(); - - $thumb = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."/../../".$row->thumbUrl; - $title = $row->title; - $description = $row->description; - $shortlink = $row->shortlink; - - $twitterUrl = "https://twitter.com/share?url=".urlencode("$url"); - $facebookUrl = "http://www.facebook.com/sharer.php?u=".urlencode("$url")."&t=".urlencode($title); - $mailUrl = "mailto:?subject=".rawurlencode($title)."&body=".rawurlencode("Hey guy! Check this out: $url"); - - $share = array(); - $share['twitter'] = $twitterUrl; - $share['facebook'] = $facebookUrl; - $share['tumblr'] = $tumblrUrl; - $share['pinterest'] = $pinterestUrl; - $share['mail'] = $mailUrl; - $share['shortlink'] = $shortlink; - - return $share; + return $row->shortlink; } function facebookHeader($photoID) { $database = dbConnect(); @@ -691,7 +720,7 @@ function facebookHeader($photoID) { return $return; } -function isPhotoPublic($photoID) { +function isPhotoPublic($photoID, $password) { global $database; $photoID = mysqli_real_escape_string($database, $photoID); if(is_numeric($photoID)) { @@ -702,16 +731,13 @@ function isPhotoPublic($photoID) { $result = $database->query($query); $row = $result->fetch_object(); if (!is_numeric($photoID)&&!$row) return true; - if($row->public == 1) { - return true; - } else { - return false; - } + if($row->public == 1) return true; + else return isAlbumPublic($row->album, $password); } // Search Function function search($term) { - global $database; + global $database, $sorting; $term = mysqli_real_escape_string($database, $term); $query = "SELECT * FROM lychee_photos WHERE title like '%$term%' OR description like '%$term%';"; @@ -725,7 +751,7 @@ function search($term) { $i=0; while($row = $result->fetch_array()) { $return['albums'][$i] = $row; - $query2 = "SELECT thumbUrl FROM lychee_photos WHERE album = '".$row['id']."' ORDER BY id DESC LIMIT 0, 3;"; + $query2 = "SELECT thumbUrl FROM lychee_photos WHERE album = '".$row['id']."' ORDER BY id $sorting LIMIT 0, 3;"; $result2 = $database->query($query2); $k = 0; while($row2 = $result2->fetch_object()){ diff --git a/php/update.php b/php/update.php new file mode 100644 index 0000000..f815419 --- /dev/null +++ b/php/update.php @@ -0,0 +1,16 @@ +query("SELECT `public` FROM `lychee_albums`;")) $database->query("ALTER TABLE `lychee_albums` ADD `public` TINYINT( 1 ) NOT NULL DEFAULT '0'"); + if(!$database->query("SELECT `password` FROM `lychee_albums`;")) $database->query("ALTER TABLE `lychee_albums` ADD `password` VARCHAR( 100 ) NULL DEFAULT NULL"); + echo "\nUpdate complete!"; +} else { + echo "\nCould not Update!"; +} + +?> \ No newline at end of file diff --git a/readme.md b/readme.md old mode 100644 new mode 100755 index e70e66e..89f5dcf --- a/readme.md +++ b/readme.md @@ -1,58 +1,63 @@ -# Lychee - -#### A great looking and easy-to-use Photo-Management-System. - -![Lychee ImageView](http://l.electerious.com/uploads/big/13582806160093.png) -![Lychee ImageView](http://l.electerious.com/uploads/big/13582805615704.png) - -Lychee is a free, easy to use and great looking photo-management-system you can run on your server to manage and share photos. Just download the source and follow the instructions to install Lychee wherever you want. - -## Installation - -To run Lychee, everything you need is a web-server with PHP 5.3 or later and a MySQL-Database. Follow the instructions to install Lychee on your server. [Installation »](https://github.com/electerious/Lychee/wiki/Installation) - -## Settings - -Settings are located inside the `php/config.php`. All settings are optional and doesn't need to be changed. [Settings »](https://github.com/electerious/Lychee/wiki/Settings) - -## How to use - -After the configuration, navigate your browser to the place where Lychee is located. Everything should work now. - -#### FTP Upload - -You can upload photos directly with every FTP client into Lychee. This feature helps you to share single images quickly with others. [FTP Upload »](https://github.com/electerious/Lychee/wiki/FTP-Upload) - -#### Keyboard Shortcuts - -This shortcuts will help you to use Lychee even faster. [Keyboard Shortcuts »](https://github.com/electerious/Lychee/wiki/Keyboard-Shortcuts) - -## Browser Support - -Lychee supports the latest versions of Google Chrome, Apple Safari and Mozilla Firefox. Photos you share with others can be viewed from every browser. For the best experience we are recommending to use Google Chrome or Apple Safari. - -## Update - -To update Lychee, simply replace all files, excluding the following ones: -`uploads/`, `php/config.php` - -## Troubleshooting - -If Lychee is not working properly, try to open `php/check.php`. This file will take a look at your configuration and displays all errors it can find. Everything should work if you can see the message "Lychee is ready!". - -## About - -Lychee is made by [Tobias Reich](http://electerious.com) (HTML, CSS, JS, Design, Website Design and Development) with the help of [Philipp Maurer](http://phinal.net) (PHP, MySQL). - -##License - -(MIT License) - -Copyright (C) 2013 [Tobias Reich](http://electerious.com) -Copyright (C) 2013 [Philipp Maurer](http://phinal.net) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# Lychee + +#### A great looking and easy-to-use Photo-Management-System. + +![Lychee ImageView](http://l.electerious.com/uploads/big/13582806160093.png) +![Lychee ImageView](http://l.electerious.com/uploads/big/13582805615704.png) + +Lychee is a free, easy to use and great looking photo-management-system you can run on your server to manage and share photos. Just download the source and follow the instructions to install Lychee wherever you want. + +## Installation + +To run Lychee, everything you need is a web-server with PHP 5.3 or later and a MySQL-Database. Follow the instructions to install Lychee on your server. [Installation »](https://github.com/electerious/Lychee/wiki/Installation) + +## Settings + +Settings are located inside the `php/config.php`. All settings are optional and doesn't need to be changed. [Settings »](https://github.com/electerious/Lychee/wiki/Settings) + +## How to use + +After the configuration, navigate your browser to the place where Lychee is located. Everything should work now. + +#### FTP Upload + +You can upload photos directly with every FTP client into Lychee. This feature helps you to share single images quickly with others. [FTP Upload »](https://github.com/electerious/Lychee/wiki/FTP-Upload) + +#### Keyboard Shortcuts + +This shortcuts will help you to use Lychee even faster. [Keyboard Shortcuts »](https://github.com/electerious/Lychee/wiki/Keyboard-Shortcuts) + +## Browser Support + +Lychee supports the latest versions of Google Chrome, Apple Safari and Mozilla Firefox. Photos you share with others can be viewed from every browser. For the best experience we are recommending to use Google Chrome or Apple Safari. + +## Update + +####From version 1.0/1.1 to 1.2: +1. Replace all files, excluding `uploads/` +2. Open `php/config.php` and reconfigure your installation +3. Open `php/update.php` in your browser + +####From version 1.2 to 1.2.x: +Replace all files, excluding `uploads/` and `php/config.php`. + +## Troubleshooting + +If Lychee is not working properly, try to open `php/check.php`. This file will take a look at your configuration and displays all errors it can find. Everything should work if you can see the message "Lychee is ready!". + +## About + +Lychee is made by [Tobias Reich](http://electerious.com) (HTML, CSS, JS, Design, Website Design and Development) with the help of [Philipp Maurer](http://phinal.net) (PHP, MySQL). + +##License + +(MIT License) + +Copyright (C) 2013 [Tobias Reich](http://electerious.com) +Copyright (C) 2013 [Philipp Maurer](http://phinal.net) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/view.php b/view.php index 51636fc..ea308c7 100755 --- a/view.php +++ b/view.php @@ -19,18 +19,18 @@