- Better mobile experience
- New Login
- jQuery update
- Small fixes and enhancements
This commit is contained in:
Tobias Reich 2013-01-15 21:21:36 +01:00
parent c6c6a2e808
commit b565390419
16 changed files with 373 additions and 310 deletions

42
css/animations.css Normal file → Executable file
View File

@ -118,6 +118,48 @@
} }
} }
/* moveUp ------------------------------------------------*/
@-webkit-keyframes moveUp {
0% {
-webkit-transform: translateY(1000px);
}
100% {
-webkit-transform: translateY(0px);
}
}
@-moz-keyframes moveUp {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@-ms-keyframes moveUp {
0% {
-ms-transform: translateY(1000px);
}
100% {
-ms-transform: translateY(0px);
}
}
@-o-keyframes moveUp {
0% {
-o-transform: translateY(1000px);
}
100% {
-o-transform: translateY(0px);
}
}
@keyframes moveUp {
0% {
transform: translateY(1000px);
}
100% {
transform: translateY(0px);
}
}
/* moveDown ------------------------------------------------*/ /* moveDown ------------------------------------------------*/
@-webkit-keyframes moveDown { @-webkit-keyframes moveDown {
0% { 0% {

0
css/font-awesome.css vendored Normal file → Executable file
View File

View File

@ -9,10 +9,39 @@ table { border-collapse:collapse; border-spacing:0; }
/* Screen behavior -------------------------------------------------*/ /* Screen behavior -------------------------------------------------*/
@media only screen and (max-width: 900px) { @media only screen and (max-width: 900px) {
#title span { display: none; } #title span { display: none; }
} }
@media only screen and (max-width: 600px) { @media only screen and (max-width: 640px) {
#title { display: none; } #title { display: none; }
#button_move { display: none; }
.center {
top: 0px !important;
left: 0px !important;
}
.message {
position: fixed !important;
width: 100% !important;
height: 100% !important;
margin: 1px 0px 0px 0px !important;
border-radius: 0px !important;
/* Animation */
-webkit-animation-name: moveUp !important;
-webkit-animation-duration: .3s !important;
-moz-animation-name: moveUp !important;
-moz-animation-duration: .3s !important;
-o-animation-name: moveUp !important;
-o-animation-duration: .3s !important;
animation-name: moveUp !important;
animation-duration: .3s !important;
}
} }
/* Basics -------------------------------------------------*/ /* Basics -------------------------------------------------*/
@ -60,7 +89,7 @@ body { background-color: #222; background-image: url(../img/background.jpg); fon
text-align: center; text-align: center;
text-shadow: 0 -1px 0 #000; text-shadow: 0 -1px 0 #000;
background: #000; background: #000;
box-shadow: 0 1px 2px hsla(0, 0%, 0%, .29); box-shadow: 0 1px 2px hsla(0, 0%, 0%, .25);
border-radius: 3px; border-radius: 3px;
} }
.tipsy-arrow { position: absolute; width: 0; height: 0; line-height: 0; border: 5px dashed #000; } .tipsy-arrow { position: absolute; width: 0; height: 0; line-height: 0; border: 5px dashed #000; }
@ -349,7 +378,7 @@ header {
#tools_albums, #tools_album, #tools_photo { #tools_albums, #tools_album, #tools_photo {
display: none; display: none;
} }
/* Button Custom ------------------------------------------------*/ /* Button Custom ------------------------------------------------*/
header .button.icon-refresh { header .button.icon-refresh {
padding: 7px 10px 4px 10px; padding: 7px 10px 4px 10px;
@ -399,7 +428,7 @@ header {
#search:focus { #search:focus {
box-shadow: 0px 1px 0px #555, inset 0px 0px 2px #333; box-shadow: 0px 1px 0px #555, inset 0px 0px 2px #333;
opacity: 1; opacity: 1;
width: 180px; width: 150px;
} }
/* Tools ------------------------------------------------*/ /* Tools ------------------------------------------------*/
@ -690,14 +719,11 @@ header {
float: left; float: left;
width: 100%; width: 100%;
padding: 12px 0px; padding: 12px 0px;
background-color: rgba(0, 0, 0, .2);
color: #fff; color: #fff;
font-size: 16px; font-size: 16px;
font-weight: bold; font-weight: bold;
text-shadow: 0px -1px 0px #000; text-shadow: 0px -1px 0px #000;
text-align: center; text-align: center;
border-bottom: 1px solid #111;
box-shadow: 0px 1px 0px rgba(255,255,255,.2);
} }
.message .close { .message .close {
position: absolute; position: absolute;
@ -710,16 +736,13 @@ header {
} }
.message p { .message p {
float: left; float: left;
width: 470px; width: 90%;
margin-top: 1px; margin-top: 1px;
padding: 12px 15px 15px 15px; padding: 12px 5% 15px 5%;
color: #eee; color: #eee;
font-size: 14px; font-size: 14px;
background-color: #555;
text-shadow: 0px -1px 0px #222; text-shadow: 0px -1px 0px #222;
line-height: 20px; line-height: 20px;
border-bottom: 1px solid #111;
box-shadow: 0px 1px 0px rgba(255,255,255,.1);
} }
.message .button { .message .button {
float: right; float: right;
@ -743,6 +766,9 @@ header {
box-shadow: inset 0px 1px 0px rgba(255,255,255,.2), 0px 1px 0px rgba(255,255,255,.1); box-shadow: inset 0px 1px 0px rgba(255,255,255,.2), 0px 1px 0px rgba(255,255,255,.1);
cursor: pointer; cursor: pointer;
} }
.message .button:first-of-type {
margin: 15px 5% 18px 0px !important;
}
.message .button.active { .message .button.active {
color: #fff; color: #fff;
box-shadow: inset 0px 1px 0px rgba(255,255,255,.2), 0px 1px 0px rgba(255,255,255,.1), 0px 0px 5px #005ecc; box-shadow: inset 0px 1px 0px rgba(255,255,255,.2), 0px 1px 0px rgba(255,255,255,.1), 0px 0px 5px #005ecc;
@ -818,35 +844,25 @@ header {
/* Sign in ------------------------------------------------*/ /* Sign in ------------------------------------------------*/
.sign_in { .sign_in {
float: left; float: left;
width: 500px; width: 100%;
margin-top: 1px; margin-top: 1px;
padding: 20px 0px; padding: 5px 0px;
color: #eee; color: #eee;
font-size: 14px; font-size: 14px;
background-color: #555;
text-shadow: 0px -1px 0px #222; text-shadow: 0px -1px 0px #222;
line-height: 20px; line-height: 20px;
border-bottom: 1px solid #111;
box-shadow: 0px 1px 0px rgba(255,255,255,.1);
}
.sign_in label {
float: left;
width: 20%;
margin: 6px 0px 0px 10%;
}
.sign_in label:first-of-type {
margin-bottom: 10px;
} }
.sign_in input { .sign_in input {
float: left; float: left;
width: 55%; width: 86%;
padding: 7px 10px 9px 10px; padding: 7px 2% 9px 2%;
margin: 0px 5%;
background-color: #444; background-color: #444;
color: #fff; color: #fff;
text-shadow: 0px 1px 0px #222; text-shadow: 0px 1px 0px #222;
border: none; border: none;
border: 1px solid #111; border: 1px solid #111;
box-shadow: 0px 1px 0px #777; box-shadow: 0px 1px 0px #555;
outline: none; outline: none;
border-radius: 5px; border-radius: 5px;
} }
@ -854,19 +870,19 @@ header {
margin-bottom: 10px; margin-bottom: 10px;
} }
.sign_in input:focus { .sign_in input:focus {
box-shadow: 0px 1px 0px #777, inset 0px 0px 3px #333, 0px 0px 5px #005ecc; box-shadow: 0px 1px 0px #666, inset 0px 0px 3px #333, 0px 0px 5px #005ecc;
} }
.sign_in input.error:focus { .sign_in input.error:focus {
box-shadow: 0px 1px 0px #777, inset 0px 0px 3px #333, 0px 0px 5px #cc0007; box-shadow: 0px 1px 0px #666, inset 0px 0px 3px #333, 0px 0px 5px #cc0007;
} }
.message #version { .message #version {
display: inline-block; display: inline-block;
margin-top: 23px; margin-top: 23px;
margin-left: 19px; margin-left: 5%;
color: #888; color: #888;
text-shadow: 0px -1px 0px #111; text-shadow: 0px -1px 0px #111;
} }
/* Sign in ------------------------------------------------*/ /* Sign in ------------------------------------------------*/
.copylink { .copylink {
float: left; float: left;
@ -904,7 +920,7 @@ header {
background-position: 50% 50%; background-position: 50% 50%;
background-size: contain; background-size: contain;
-webkit-transition: top .3s, bottom .3s, margin-top .3s; -webkit-transition: top .3s, bottom .3s, margin-top .3s;
-webkit-animation-name: zoomIn; -webkit-animation-name: zoomIn;
-webkit-animation-duration: .3s; -webkit-animation-duration: .3s;
-webkit-animation-fill-mode: forwards; -webkit-animation-fill-mode: forwards;
@ -924,7 +940,7 @@ header {
bottom: auto; bottom: auto;
left: 50%; left: 50%;
} }
/* Previous/Next Buttons ------------------------------------------------*/ /* Previous/Next Buttons ------------------------------------------------*/
#image_view a { #image_view a {
position: fixed; position: fixed;
@ -948,7 +964,7 @@ header {
right: 20px; right: 20px;
-webkit-transition: right .3s -webkit-transition: right .3s
} }
/* InfoBox ------------------------------------------------*/ /* InfoBox ------------------------------------------------*/
#infobox_overlay { #infobox_overlay {
z-index: 2; z-index: 2;
@ -978,12 +994,12 @@ header {
background-color: rgba(20,20,20,0.98); background-color: rgba(20,20,20,0.98);
box-shadow: -1px 0px 2px #000; box-shadow: -1px 0px 2px #000;
display: none; display: none;
-webkit-user-select: text; -webkit-user-select: text;
-moz-user-select: text; -moz-user-select: text;
-o-user-select: text; -o-user-select: text;
user-select: text; user-select: text;
-webkit-transition: right .5s ease-out; -webkit-transition: right .5s ease-out;
-moz-transition: right .5s; -moz-transition: right .5s;
-o-transition: right .5s; -o-transition: right .5s;
@ -998,7 +1014,7 @@ header {
float: left; float: left;
height: 41px; height: 41px;
width: 100%; width: 100%;
background-color: #1d1d1d; background-color: #1d1d1d;
background-image: -webkit-gradient(linear, left top, left bottom, from(#1d1d1d), to(#050505)); background-image: -webkit-gradient(linear, left top, left bottom, from(#1d1d1d), to(#050505));
background-image: -webkit-linear-gradient(top, #1d1d1d, #050505); background-image: -webkit-linear-gradient(top, #1d1d1d, #050505);
@ -1006,7 +1022,7 @@ header {
background-image: -o-linear-gradient(top, #1d1d1d, #050505); background-image: -o-linear-gradient(top, #1d1d1d, #050505);
background-image: -ms-linear-gradient(top, #1d1d1d, #050505); background-image: -ms-linear-gradient(top, #1d1d1d, #050505);
background-image: linear-gradient(top, #1d1d1d, #050505); background-image: linear-gradient(top, #1d1d1d, #050505);
box-shadow: inset 0px 1px 0px #111, inset 0px -1px 0px #000; box-shadow: inset 0px 1px 0px #111, inset 0px -1px 0px #000;
border-top: 1px solid #000; border-top: 1px solid #000;
} }
@ -1207,7 +1223,7 @@ header {
font-size: 80px; font-size: 80px;
text-shadow: 0px 1px 2px #000; text-shadow: 0px 1px 2px #000;
z-index: 2; z-index: 2;
/* Animation */ /* Animation */
-webkit-animation-name: pulse; -webkit-animation-name: pulse;
-webkit-animation-duration: 2s; -webkit-animation-duration: 2s;
@ -1249,7 +1265,7 @@ header {
border: 1px solid #000; border: 1px solid #000;
box-shadow: 0 1px 0 rgba(255,255,255,.2), inset 0px 0px 2px #111; box-shadow: 0 1px 0 rgba(255,255,255,.2), inset 0px 0px 2px #111;
border-radius: 5px; border-radius: 5px;
/* Animation */ /* Animation */
-webkit-animation-name: moveBackground; -webkit-animation-name: moveBackground;
-webkit-animation-duration: .6s; -webkit-animation-duration: .6s;
@ -1281,7 +1297,7 @@ header {
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* IE10+ */ background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* IE10+ */
background: linear-gradient(top, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* W3C */ background: linear-gradient(top, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* W3C */
border-radius: 5px; border-radius: 5px;
-webkit-transition: width .2s; -webkit-transition: width .2s;
-moz-transition: width .2s; -moz-transition: width .2s;
-o-transition: width .2s; -o-transition: width .2s;

View File

@ -3,7 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title></title> <title>Lychee</title>
<meta name="author" content="Tobias Reich, Philipp Maurer"> <meta name="author" content="Tobias Reich, Philipp Maurer">
<meta name="keywords" content=""> <meta name="keywords" content="">
@ -16,7 +16,7 @@
<link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon.png"> <link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon.png">
<meta name="apple-mobile-web-app-status-bar-style" content="black" > <meta name="apple-mobile-web-app-status-bar-style" content="black" >
<meta name="viewport" content="width=device-width, user-scalable=no"> <meta name="viewport" content="user-scalable=no, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
</head> </head>
@ -24,7 +24,7 @@
<!-- Loading --> <!-- Loading -->
<div id="loading"></div> <div id="loading"></div>
<!-- Header --> <!-- Header -->
<header> <header>
@ -66,17 +66,17 @@
<!-- ImageView --> <!-- ImageView -->
<div id="image_view"></div> <div id="image_view"></div>
<!-- Infobox --> <!-- Infobox -->
<div id="infobox"></div> <div id="infobox"></div>
<!-- Upload --> <!-- Upload -->
<div id="upload"> <div id="upload">
<input id="upload_files" type="file" name="fileElem[]" multiple="true" accept="image/*"> <input id="upload_files" type="file" name="fileElem[]" multiple="true" accept="image/*">
<div id="auswahl"></div> <div id="auswahl"></div>
<input id="upload_button" type="button" onclick="sendFiles();" value="Upload"> <input id="upload_button" type="button" onclick="sendFiles();" value="Upload">
</div> </div>
<!-- JS --> <!-- JS -->
<script type="text/javascript" src="js/frameworks.js"></script> <script type="text/javascript" src="js/frameworks.js"></script>
<script type="text/javascript" src="js/upload.js"></script> <script type="text/javascript" src="js/upload.js"></script>

82
js/build.js Normal file → Executable file
View File

@ -6,7 +6,7 @@
*/ */
/* /*
Build Functions Build Functions
This functions are used to generate HTML-Code. This functions are used to generate HTML-Code.
*/ */
@ -34,13 +34,13 @@ function buildAlbum(albumJSON) {
album += "<h1>" + albumJSON.title + "</h1>"; album += "<h1>" + albumJSON.title + "</h1>";
album += "<a>" + albumJSON.sysdate + "</a>"; album += "<a>" + albumJSON.sysdate + "</a>";
album += "</div>"; album += "</div>";
if(albumJSON.star=="1") album += "<a class='badge red icon-star'></a>"; if(albumJSON.star=="1") album += "<a class='badge red icon-star'></a>";
if(albumJSON.public=="1") album += "<a class='badge red icon-rss'></a>"; if(albumJSON.public=="1") album += "<a class='badge red icon-rss'></a>";
if(albumJSON.unsorted=="1") album += "<a class='badge red icon-reorder'></a>"; if(albumJSON.unsorted=="1") album += "<a class='badge red icon-reorder'></a>";
album += "</div>"; album += "</div>";
return album; return album;
} }
@ -59,12 +59,12 @@ function buildPhoto(photoJSON) {
photo += "<h1>" + photoJSON.title + "</h1>"; photo += "<h1>" + photoJSON.title + "</h1>";
photo += "<a>" + photoJSON.sysdate + "</a>"; photo += "<a>" + photoJSON.sysdate + "</a>";
photo += "</div>"; photo += "</div>";
if(photoJSON.star=="1") photo += "<a class='badge red icon-star'></a>"; if(photoJSON.star=="1") photo += "<a class='badge red icon-star'></a>";
if(photoJSON.public=="1") photo += "<a class='badge red icon-rss'></a>"; if(photoJSON.public=="1") photo += "<a class='badge red icon-rss'></a>";
photo += "</div>"; photo += "</div>";
return photo; return photo;
} }
@ -77,33 +77,33 @@ function buildModal(title, text, button, func) {
modal += "<h1>" + title + "</h1>"; modal += "<h1>" + title + "</h1>";
modal += "<a class='close icon-remove-sign'></a>"; modal += "<a class='close icon-remove-sign'></a>";
modal += "<p>" + text + "</p>"; modal += "<p>" + text + "</p>";
$.each(button, function(index) { $.each(button, function(index) {
if (index==0) modal += "<a onclick='message_click(" + index + ")' class='button active'>" + this + "</a>"; if (index==0) modal += "<a onclick='message_click(" + index + ")' class='button active'>" + this + "</a>";
else modal += "<a onclick='message_click(" + index + ")' class='button'>" + this + "</a>"; else modal += "<a onclick='message_click(" + index + ")' class='button'>" + this + "</a>";
}); });
modal += "</div>"; modal += "</div>";
modal += "<script>"; modal += "<script>";
modal += "function message_click(action) {"; modal += "function message_click(action) {";
modal += "switch (action) {"; modal += "switch (action) {";
$.each(func, function(index) { $.each(func, function(index) {
modal += "case " + index + ":"; modal += "case " + index + ":";
modal += this.toString(); modal += this.toString();
modal += "break;"; modal += "break;";
}); });
modal += "} closeModal(); }"; modal += "} closeModal(); }";
modal += "</script>"; modal += "</script>";
modal += "</div>"; modal += "</div>";
return modal; return modal;
} }
@ -123,9 +123,9 @@ function buildAddModal() {
modal += "<div class='icon icon-picture'></div>"; modal += "<div class='icon icon-picture'></div>";
modal += "<a>Upload new Photo</a>"; modal += "<a>Upload new Photo</a>";
modal += "</div>"; modal += "</div>";
modal += "</div>"; modal += "</div>";
modal += "</div>"; modal += "</div>";
return modal; return modal;
} }
@ -137,14 +137,14 @@ function buildSignInModal() {
modal += "<div class='message center'>"; modal += "<div class='message center'>";
modal += "<h1><a class='icon-lock'></a> Sign in</h1>"; modal += "<h1><a class='icon-lock'></a> Sign in</h1>";
modal += "<div class='sign_in'>"; modal += "<div class='sign_in'>";
modal += "<label>Username:</label><input id='username' type='text' name='' value=''>"; modal += "<input id='username' type='text' name='' value='' placeholder='username'>";
modal += "<label>Password:</label><input id='password' type='password' name='' value=''>"; modal += "<input id='password' type='password' name='' value='' placeholder='password'>";
modal += "</div>"; modal += "</div>";
modal += "<div id='version'>Version " + version + "</div>"; modal += "<div id='version'>Version " + version + "</div>";
modal += "<a onclick='login()' class='button active'>Sign in</a>"; modal += "<a onclick='login()' class='button active'>Sign in</a>";
modal += "</div>"; modal += "</div>";
modal += "</div>"; modal += "</div>";
return modal; return modal;
} }
@ -158,33 +158,33 @@ function buildUploadModal() {
modal += "<div class='progressbar'><div></div></div>"; modal += "<div class='progressbar'><div></div></div>";
modal += "</div>"; modal += "</div>";
modal += "</div>"; modal += "</div>";
return modal; return modal;
} }
function buildContextMenu(items) { function buildContextMenu(items) {
var menu = ""; var menu = "";
menu += "<div class='contextmenu_bg'></div>"; menu += "<div class='contextmenu_bg'></div>";
menu += "<div class='contextmenu'>"; menu += "<div class='contextmenu'>";
menu += "<table>"; menu += "<table>";
menu += "<tbody>"; menu += "<tbody>";
$.each(items, function(index) { $.each(items, function(index) {
if (items[index][1].length!=0) { if (items[index][1].length!=0) {
menu += "<tr><td onclick='" + items[index][1] + "; closeContextMenu();'>" + items[index][0] + "</td></tr>"; menu += "<tr><td onclick='" + items[index][1] + "; closeContextMenu();'>" + items[index][0] + "</td></tr>";
} }
}); });
menu += "</tbody>"; menu += "</tbody>";
menu += "</table>"; menu += "</table>";
menu += "</div>"; menu += "</div>";
return menu; return menu;
} }
function buildInfobox(photo) { function buildInfobox(photo) {
@ -192,9 +192,9 @@ function buildInfobox(photo) {
var infobox = ""; var infobox = "";
infobox += "<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>"; infobox += "<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>";
infobox += "<div class='wrapper'>"; infobox += "<div class='wrapper'>";
if (photo.public==1) photo.public = "Public"; else photo.public = "Private"; if (photo.public==1) photo.public = "Public"; else photo.public = "Private";
infos = [ infos = [
["", "Basics"], ["", "Basics"],
["Name", photo.title], ["Name", photo.title],
@ -216,32 +216,32 @@ function buildInfobox(photo) {
["Privacy", photo.public], ["Privacy", photo.public],
["Short Link", photo.shortlink] ["Short Link", photo.shortlink]
]; ];
$.each(infos, function(index) { $.each(infos, function(index) {
if (infos[index][1]==""||infos[index][1]==undefined||infos[index][1]==null) infos[index][1] = "-"; if (infos[index][1]==""||infos[index][1]==undefined||infos[index][1]==null) infos[index][1] = "-";
if (infos[index][0]=="") { if (infos[index][0]=="") {
infobox += "</table>"; infobox += "</table>";
infobox += "<div class='separater'><h1>" + infos[index][1] + "</h1></div>"; infobox += "<div class='separater'><h1>" + infos[index][1] + "</h1></div>";
infobox += "<table id='infos'>"; infobox += "<table id='infos'>";
} else { } else {
infobox += "<tr>"; infobox += "<tr>";
infobox += "<td>" + infos[index][0] + "</td>"; infobox += "<td>" + infos[index][0] + "</td>";
infobox += "<td>" + infos[index][1] + "</td>"; infobox += "<td>" + infos[index][1] + "</td>";
infobox += "</tr>"; infobox += "</tr>";
} }
}); });
infobox += "</table>"; infobox += "</table>";
infobox += "<div class='bumper'></div>"; infobox += "<div class='bumper'></div>";
infobox += "</div>"; infobox += "</div>";
return infobox; return infobox;
} }

File diff suppressed because one or more lines are too long

178
js/functions.js Normal file → Executable file
View File

@ -13,7 +13,7 @@
function init() { function init() {
$("#tools_albums").show(); $("#tools_albums").show();
$(".tools").tipsy({gravity: 'n'}); if (!mobileBrowser()) $(".tools").tipsy({gravity: 'n'});
params = "function=loggedIn"; params = "function=loggedIn";
$.ajax({type: "POST", url: api_path, data: params, success: function(data) { $.ajax({type: "POST", url: api_path, data: params, success: function(data) {
if (data!=1) { if (data!=1) {
@ -23,7 +23,7 @@ function init() {
if (headerTitle.html().length<1&&BrowserDetect.browser=="Firefox") getURL(); if (headerTitle.html().length<1&&BrowserDetect.browser=="Firefox") getURL();
} }
}}); }});
} }
/* /*
@ -71,36 +71,38 @@ function getURL() {
closeContextMenu(); closeContextMenu();
hash = document.location.hash.replace("#", ""); hash = document.location.hash.replace("#", "");
albumID = ""; albumID = "";
photoID = ""; photoID = "";
if (hash.indexOf("a")!=-1) albumID = hash.split("p")[0].replace("a", ""); if (hash.indexOf("a")!=-1) albumID = hash.split("p")[0].replace("a", "");
if (hash.indexOf("p")!=-1) photoID = hash.split("p")[1]; if (hash.indexOf("p")!=-1) photoID = hash.split("p")[1];
if (hash=="upload") { if (hash=="upload") {
loadAlbums(); loadAlbums();
$("body").append(buildAddModal); $("body").append(buildAddModal);
} else if (albumID&&photoID) { } else if (albumID&&photoID) {
content.hide(); if (content.html()=="") {
content.hide();
loadPhotos(albumID, true);
}
showImageview(photoID); showImageview(photoID);
if (content.html()=="") loadPhotos(albumID, true);
} else if (albumID) { } else if (albumID) {
if (!visibleControls()) showControls(); if (!visibleControls()) showControls();
if (visibleImageview()) hideImageview(); if (visibleImageview()) hideImageview();
else loadPhotos(albumID, false); else loadPhotos(albumID, false);
} else { } else {
loadAlbums(); loadAlbums();
} }
} }
/* /*
@ -260,7 +262,7 @@ function showContextMenuPhoto(photoID, mouse_x, mouse_y) {
["Move to Album", "showContextMenuMove(" + photoID + ", " + (mouse_x+150) + ", " + (mouse_y+$(document).scrollTop()) + ")"], ["Move to Album", "showContextMenuMove(" + photoID + ", " + (mouse_x+150) + ", " + (mouse_y+$(document).scrollTop()) + ")"],
["Delete", "deletePhoto(" + photoID + ")"] ["Delete", "deletePhoto(" + photoID + ")"]
]; ];
closeContextMenu(); closeContextMenu();
$("body").css("overflow", "hidden"); $("body").css("overflow", "hidden");
$(".photo[data-id='" + photoID + "']").addClass("active"); $(".photo[data-id='" + photoID + "']").addClass("active");
@ -269,15 +271,15 @@ function showContextMenuPhoto(photoID, mouse_x, mouse_y) {
"top": mouse_y, "top": mouse_y,
"left": mouse_x "left": mouse_x
}); });
} }
function showContextMenuMove(photoID, mouse_x, mouse_y) { function showContextMenuMove(photoID, mouse_x, mouse_y) {
mouse_y -= $(document).scrollTop(); mouse_y -= $(document).scrollTop();
params = "function=getAlbums"; params = "function=getAlbums";
$.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) {
if (content.attr("data-id")==0) { if (content.attr("data-id")==0) {
items = new Array(); items = new Array();
} else { } else {
@ -285,7 +287,7 @@ function showContextMenuMove(photoID, mouse_x, mouse_y) {
["Unsorted", "loadMovePhoto(" + photoID + ", 0)"] ["Unsorted", "loadMovePhoto(" + photoID + ", 0)"]
]; ];
} }
$.each(data, function(index) { $.each(data, function(index) {
if (this.id!=content.attr("data-id")) { if (this.id!=content.attr("data-id")) {
if(!this.title) this.title = "Untitled"; if(!this.title) this.title = "Untitled";
@ -294,13 +296,13 @@ function showContextMenuMove(photoID, mouse_x, mouse_y) {
items[items.length] = new Array("", ""); items[items.length] = new Array("", "");
} }
}); });
if (items.length==0) { if (items.length==0) {
items = [ items = [
["Create new Album", "addAlbum()"] ["Create new Album", "addAlbum()"]
]; ];
} }
closeContextMenu(); closeContextMenu();
$("body").css("overflow", "hidden"); $("body").css("overflow", "hidden");
$(".photo[data-id='" + photoID + "']").addClass("active"); $(".photo[data-id='" + photoID + "']").addClass("active");
@ -309,14 +311,14 @@ function showContextMenuMove(photoID, mouse_x, mouse_y) {
"top": mouse_y, "top": mouse_y,
"left": mouse_x-150 "left": mouse_x-150
}); });
}, error: ajaxError }); }, error: ajaxError });
} }
function showContextMenuShare(photoID, mouse_x, mouse_y) { function showContextMenuShare(photoID, mouse_x, mouse_y) {
mouse_y -= $(document).scrollTop(); mouse_y -= $(document).scrollTop();
items = [ items = [
["<a class='icon-eye-close'></a> Make Private", "setPhotoPublic()"], ["<a class='icon-eye-close'></a> Make Private", "setPhotoPublic()"],
["<a class='icon-twitter'></a> Twitter", "loadSharePhoto(0, " + photoID + ")"], ["<a class='icon-twitter'></a> Twitter", "loadSharePhoto(0, " + photoID + ")"],
@ -327,7 +329,7 @@ function showContextMenuShare(photoID, mouse_x, mouse_y) {
["<a class='icon-link'></a> Copy Link", "loadSharePhoto(5, " + photoID + ")"], ["<a class='icon-link'></a> Copy Link", "loadSharePhoto(5, " + photoID + ")"],
["<a class='icon-link'></a> Copy Shortlink", "loadSharePhoto(6, " + photoID + ")"] ["<a class='icon-link'></a> Copy Shortlink", "loadSharePhoto(6, " + photoID + ")"]
]; ];
closeContextMenu(); closeContextMenu();
$("body").css("overflow", "hidden"); $("body").css("overflow", "hidden");
$(".photo[data-id='" + photoID + "']").addClass("active"); $(".photo[data-id='" + photoID + "']").addClass("active");
@ -336,7 +338,7 @@ function showContextMenuShare(photoID, mouse_x, mouse_y) {
"top": mouse_y, "top": mouse_y,
"left": mouse_x "left": mouse_x
}); });
} }
function closeContextMenu() { function closeContextMenu() {
$(".contextmenu_bg, .contextmenu").remove(); $(".contextmenu_bg, .contextmenu").remove();
@ -393,7 +395,7 @@ function isPhotoSmall(photo) {
if (photo.width<$(window).width()-60) size["width"] = true; if (photo.width<$(window).width()-60) size["width"] = true;
if (photo.height<$(window).height()-100) size["height"] = true; if (photo.height<$(window).height()-100) size["height"] = true;
if (size["width"]&&size["height"]) return true; if (size["width"]&&size["height"]) return true;
else return false; else return false;
@ -407,9 +409,9 @@ function isPhotoSmall(photo) {
function key(e) { function key(e) {
code = (e.keyCode ? e.keyCode : e.which); code = (e.keyCode ? e.keyCode : e.which);
if (code==13||code==37||code==39||code==32||code==27) e.preventDefault(); if (code==13||code==37||code==39||code==32||code==27) e.preventDefault();
if (code==13&&$(".message .button.active").length) $(".message .button.active").addClass("pressed").click(); if (code==13&&$(".message .button.active").length) $(".message .button.active").addClass("pressed").click();
if (code==37&&visibleImageview()) loadPreviousPhoto(); if (code==37&&visibleImageview()) loadPreviousPhoto();
if (code==39&&visibleImageview()) loadNextPhoto(); if (code==39&&visibleImageview()) loadNextPhoto();
@ -483,13 +485,13 @@ function renameAlbum() {
function renamePhoto(photoID) { function renamePhoto(photoID) {
if (photoID==undefined) { if (photoID==undefined) {
// Function called from ImageViewer // Function called from ImageViewer
oldTitle = headerTitle.html(); oldTitle = headerTitle.html();
photoID = image_view.attr("data-id"); photoID = image_view.attr("data-id");
} else oldTitle = ""; } else oldTitle = "";
newTitle = prompt("Please enter a new title for this photo:", oldTitle); newTitle = prompt("Please enter a new title for this photo:", oldTitle);
if (photoID!=null&&photoID!=undefined&&newTitle.length<31) { if (photoID!=null&&photoID!=undefined&&newTitle.length<31) {
@ -518,15 +520,15 @@ function loadAlbums() {
loadingFadeIn("loading"); loadingFadeIn("loading");
$(".album, .photo").removeClass("contentZoomIn").addClass("contentZoomOut"); $(".album, .photo").removeClass("contentZoomIn").addClass("contentZoomOut");
startTime = new Date().getTime(); startTime = new Date().getTime();
params = "function=getAlbums"; params = "function=getAlbums";
$.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) {
durationTime = (new Date().getTime() - startTime); durationTime = (new Date().getTime() - startTime);
if (durationTime>300) waitTime = 0; else waitTime = 300 - durationTime; if (durationTime>300) waitTime = 0; else waitTime = 300 - durationTime;
$.timer(waitTime,function(){ $.timer(waitTime,function(){
$("#tools_album, #tools_photo").hide(); $("#tools_album, #tools_photo").hide();
@ -561,16 +563,16 @@ function loadAlbums() {
albums = ""; albums = "";
$.each(data, function() { albums += buildAlbum(this); }); $.each(data, function() { albums += buildAlbum(this); });
content.append(buildDivider("Albums") + albums); content.append(buildDivider("Albums") + albums);
$(".album, .photo").removeClass("contentZoomOut").addClass("contentZoomIn"); $(".album, .photo").removeClass("contentZoomOut").addClass("contentZoomIn");
} }
document.title = "Lychee"; document.title = "Lychee";
headerTitle.html("Albums").removeClass("editable"); headerTitle.html("Albums").removeClass("editable");
loadSmartAlbums(); loadSmartAlbums();
}); });
}, error: ajaxError }); }, error: ajaxError });
@ -581,24 +583,24 @@ function loadSmartAlbums() {
params = "function=getSmartInfo"; params = "function=getSmartInfo";
$.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) {
$(".album[data-id='0'] img:nth-child(1)").attr("src", data.unsortThumb2); $(".album[data-id='0'] img:nth-child(1)").attr("src", data.unsortThumb2);
$(".album[data-id='0'] img:nth-child(2)").attr("src", data.unsortThumb1); $(".album[data-id='0'] img:nth-child(2)").attr("src", data.unsortThumb1);
$(".album[data-id='0'] img:nth-child(3)").attr("src", data.unsortThumb0); $(".album[data-id='0'] img:nth-child(3)").attr("src", data.unsortThumb0);
$(".album[data-id='0'] .overlay a").html(data.unsortNum + " photos"); $(".album[data-id='0'] .overlay a").html(data.unsortNum + " photos");
$(".album[data-id='s'] img:nth-child(1)").attr("src", data.publicThumb2); $(".album[data-id='s'] img:nth-child(1)").attr("src", data.publicThumb2);
$(".album[data-id='s'] img:nth-child(2)").attr("src", data.publicThumb1); $(".album[data-id='s'] img:nth-child(2)").attr("src", data.publicThumb1);
$(".album[data-id='s'] img:nth-child(3)").attr("src", data.publicThumb0); $(".album[data-id='s'] img:nth-child(3)").attr("src", data.publicThumb0);
$(".album[data-id='s'] .overlay a").html(data.publicNum + " photos"); $(".album[data-id='s'] .overlay a").html(data.publicNum + " photos");
$(".album[data-id='f'] img:nth-child(1)").attr("src", data.starredThumb2); $(".album[data-id='f'] img:nth-child(1)").attr("src", data.starredThumb2);
$(".album[data-id='f'] img:nth-child(2)").attr("src", data.starredThumb1); $(".album[data-id='f'] img:nth-child(2)").attr("src", data.starredThumb1);
$(".album[data-id='f'] img:nth-child(3)").attr("src", data.starredThumb0); $(".album[data-id='f'] img:nth-child(3)").attr("src", data.starredThumb0);
$(".album[data-id='f'] .overlay a").html(data.starredNum + " photos"); $(".album[data-id='f'] .overlay a").html(data.starredNum + " photos");
loadingFadeOut(); loadingFadeOut();
}, error: ajaxError }); }, error: ajaxError });
} }
@ -613,15 +615,15 @@ function loadPhotos(albumID, refresh) {
$(".album, .photo").removeClass("contentZoomIn").addClass("contentZoomOut"); $(".album, .photo").removeClass("contentZoomIn").addClass("contentZoomOut");
$(".divider").removeClass("fadeIn").addClass("fadeOut"); $(".divider").removeClass("fadeIn").addClass("fadeOut");
} }
startTime = new Date().getTime(); startTime = new Date().getTime();
params = "function=getPhotos&albumID=" + albumID; params = "function=getPhotos&albumID=" + albumID;
$.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) {
durationTime = (new Date().getTime() - startTime); durationTime = (new Date().getTime() - startTime);
if (durationTime>300) waitTime = 0; else if (refresh) waitTime = 0; else waitTime = 300 - durationTime; if (durationTime>300) waitTime = 0; else if (refresh) waitTime = 0; else waitTime = 300 - durationTime;
$.timer(waitTime,function(){ $.timer(waitTime,function(){
content.attr("data-id", albumID); content.attr("data-id", albumID);
@ -639,7 +641,7 @@ function loadPhotos(albumID, refresh) {
loadAlbumInfo(albumID); loadAlbumInfo(albumID);
} }
}); });
}, error: ajaxError }); }, error: ajaxError });
@ -649,10 +651,10 @@ function loadPhotos(albumID, refresh) {
function loadAlbumInfo(albumID) { function loadAlbumInfo(albumID) {
if (albumID=="f"||albumID=="s"||albumID==0) { if (albumID=="f"||albumID=="s"||albumID==0) {
params = "function=getSmartInfo"; params = "function=getSmartInfo";
$.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) {
switch (albumID) { switch (albumID) {
case "f": case "f":
document.title = "Lychee - Starred"; document.title = "Lychee - Starred";
@ -662,7 +664,7 @@ function loadAlbumInfo(albumID) {
case "s": case "s":
document.title = "Lychee - Public"; document.title = "Lychee - Public";
headerTitle.html("Public<span> - " + data.publicNum + " photos</span>"); headerTitle.html("Public<span> - " + data.publicNum + " photos</span>");
$("#button_edit_album, #button_trash_album .button_divider").hide(); $("#button_edit_album, #button_trash_album, .button_divider").hide();
break; break;
case "0": case "0":
document.title = "Lychee - Unsorted"; document.title = "Lychee - Unsorted";
@ -671,27 +673,27 @@ function loadAlbumInfo(albumID) {
$("#button_trash_album, .button_divider").show(); $("#button_trash_album, .button_divider").show();
break; break;
} }
loadingFadeOut(); loadingFadeOut();
}, error: ajaxError }); }, error: ajaxError });
} else { } else {
params = "function=getAlbumInfo&albumID=" + albumID; params = "function=getAlbumInfo&albumID=" + albumID;
$.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) {
$("#button_edit_album, #button_trash_album, .button_divider").show(); $("#button_edit_album, #button_trash_album, .button_divider").show();
if (!data.title) data.title = "Untitled"; if (!data.title) data.title = "Untitled";
document.title = "Lychee - " + data.title; document.title = "Lychee - " + data.title;
headerTitle.html(data.title + "<span> - " + data.num + " photos</span>").addClass("editable"); headerTitle.html(data.title + "<span> - " + data.num + " photos</span>").addClass("editable");
loadingFadeOut(); loadingFadeOut();
}, error: ajaxError }); }, error: ajaxError });
} }
} }
@ -730,13 +732,13 @@ function loadPhotoInfo(photoID) {
else if (isPhotoSmall(data)) image_view.html("").append("<a id='previous' style='left: -50px' class='icon-caret-left'></a><a id='next' style='right: -50px' class='icon-caret-right'></a><div id='image' class='small' style='background-image: url(" + data.url + "); width: " + data.width + "px; height: " + data.height + "px; margin-top: -" + parseInt(data.height/2) + "px; margin-left: -" + data.width/2 + "px;'></div>"); else if (isPhotoSmall(data)) image_view.html("").append("<a id='previous' style='left: -50px' class='icon-caret-left'></a><a id='next' style='right: -50px' class='icon-caret-right'></a><div id='image' class='small' style='background-image: url(" + data.url + "); width: " + data.width + "px; height: " + data.height + "px; margin-top: -" + parseInt(data.height/2) + "px; margin-left: -" + data.width/2 + "px;'></div>");
else image_view.html("").append("<a id='previous' style='left: -50px' class='icon-caret-left'></a><a id='next' style='right: -50px' class='icon-caret-right'></a><div id='image' style='background-image: url(" + data.url + "); top: 0px; right: 0px; bottom: 0px; left: 0px;'></div>"); else image_view.html("").append("<a id='previous' style='left: -50px' class='icon-caret-left'></a><a id='next' style='right: -50px' class='icon-caret-right'></a><div id='image' style='background-image: url(" + data.url + "); top: 0px; right: 0px; bottom: 0px; left: 0px;'></div>");
image_view.removeClass("fadeOut").addClass("fadeIn").show(); image_view.removeClass("fadeOut").addClass("fadeIn").show();
if (!visibleControls()) hideControls(true); if (!visibleControls()) hideControls(true);
infobox.html(buildInfobox(data)).show(); infobox.html(buildInfobox(data)).show();
$.timer(300,function(){ content.show(); }); $.timer(300,function(){ content.show(); });
loadingFadeOut(); loadingFadeOut();
}, error: ajaxError }); }, error: ajaxError });
@ -801,12 +803,12 @@ function setPhotoPublic(e) {
} }
function setPhotoDescription() { function setPhotoDescription() {
description = prompt("Please enter a description for this photo:", ""); description = prompt("Please enter a description for this photo:", "");
photoID = image_view.attr("data-id"); photoID = image_view.attr("data-id");
if (description.length>0&&description.length<160) { if (description.length>0&&description.length<160) {
loadingFadeIn("loading"); loadingFadeIn("loading");
params = "function=setPhotoDescription&photoID=" + photoID + "&description=" + escape(description); params = "function=setPhotoDescription&photoID=" + photoID + "&description=" + escape(description);
@ -859,7 +861,7 @@ function loadSharePhoto(service, photoID) {
params = "function=sharePhoto&photoID=" + photoID + "&url=" + getViewLink(photoID); params = "function=sharePhoto&photoID=" + photoID + "&url=" + getViewLink(photoID);
$.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) {
switch (service) { switch (service) {
case 0: case 0:
link = data.twitter; link = data.twitter;
@ -898,7 +900,7 @@ function loadSharePhoto(service, photoID) {
location.href = link; location.href = link;
loadingFadeOut(); loadingFadeOut();
} else loadingFadeIn("error"); } else loadingFadeIn("error");
}, error: ajaxError }); }, error: ajaxError });
} }
@ -937,12 +939,12 @@ function loadPreviousPhoto() {
albumID = content.attr("data-id"); albumID = content.attr("data-id");
photoID = image_view.attr("data-id"); photoID = image_view.attr("data-id");
params = "function=previousPhoto&photoID=" + photoID + "&albumID=" + albumID; params = "function=previousPhoto&photoID=" + photoID + "&albumID=" + albumID;
$.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) {
if (data!=false) setURL("a" + albumID + "p" + data.id); if (data!=false) setURL("a" + albumID + "p" + data.id);
}, error: ajaxError }); }, error: ajaxError });
} }
@ -951,7 +953,7 @@ function loadNextPhoto() {
albumID = content.attr("data-id"); albumID = content.attr("data-id");
photoID = image_view.attr("data-id"); photoID = image_view.attr("data-id");
params = "function=nextPhoto&photoID=" + photoID + "&albumID=" + albumID; params = "function=nextPhoto&photoID=" + photoID + "&albumID=" + albumID;
$.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) {
@ -977,19 +979,19 @@ function search(term) {
clearTimeout($(window).data("timeout")); clearTimeout($(window).data("timeout"));
$(window).data("timeout", setTimeout(function() { $(window).data("timeout", setTimeout(function() {
if ($("#search").val().length<=2) { if ($("#search").val().length<=2) {
$(".divider").removeClass("fadeIn").addClass("fadeOut"); $(".divider").removeClass("fadeIn").addClass("fadeOut");
loadAlbums(); loadAlbums();
} else { } else {
$(".album, .photo").removeClass("contentZoomIn").addClass("contentZoomOut"); $(".album, .photo").removeClass("contentZoomIn").addClass("contentZoomOut");
$(".divider").removeClass("fadeIn").addClass("fadeOut"); $(".divider").removeClass("fadeIn").addClass("fadeOut");
startTime = new Date().getTime(); startTime = new Date().getTime();
params = "function=search&term=" + term; params = "function=search&term=" + term;
$.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) { $.ajax({type: "POST", url: api_path, data: params, dataType: "json", success: function(data) {
console.log(data); console.log(data);
@ -998,12 +1000,12 @@ function search(term) {
photos = ""; photos = "";
if (data.photos!=undefined&&data.photos!=null) $.each(data.photos, function() { photos += buildPhoto(this); }); if (data.photos!=undefined&&data.photos!=null) $.each(data.photos, function() { photos += buildPhoto(this); });
durationTime = (new Date().getTime() - startTime); durationTime = (new Date().getTime() - startTime);
if (durationTime>300) waitTime = 0; else waitTime = 300 - durationTime; if (durationTime>300) waitTime = 0; else waitTime = 300 - durationTime;
$.timer(waitTime,function(){ $.timer(waitTime,function(){
if (albums==""&&photos=="") code = ""; if (albums==""&&photos=="") code = "";
else if (albums=="") code = buildDivider("Photos")+photos; else if (albums=="") code = buildDivider("Photos")+photos;
else if (photos=="") code = buildDivider("Albums")+albums; else if (photos=="") code = buildDivider("Albums")+albums;
@ -1012,13 +1014,13 @@ function search(term) {
content.html("").append(code); content.html("").append(code);
$(".album, .photo").removeClass("contentZoomOut").addClass("contentZoomIn"); $(".album, .photo").removeClass("contentZoomOut").addClass("contentZoomIn");
}); });
}, error: ajaxError }); }, error: ajaxError });
} }
}, 250)); }, 250));
} }

View File

@ -12,70 +12,74 @@ var header = $("header"),
loading = $("#loading"), loading = $("#loading"),
infobox = $("#infobox"), infobox = $("#infobox"),
api_path = "php/api.php", api_path = "php/api.php",
version = "1.0.1"; version = "1.0.2";
$(document).ready(function(){ $(document).ready(function(){
/* Event Name */
if (mobileBrowser()) event_name = "touchend";
else event_name = "click";
/* Login */ /* Login */
$("#password").live("keyup", function() { $("#password").live("keyup", function() {
if ($(this).val().length>0) $(this).removeClass("error"); if ($(this).val().length>0) $(this).removeClass("error");
}); });
/* Add Dialog */ /* Add Dialog */
$(".button_add").live("click", function() { $("body").append(buildAddModal) }); $(".button_add").live(event_name, function() { $("body").append(buildAddModal) });
$("#add_album").live("click", addAlbum); $("#add_album").live(event_name, addAlbum);
$("#add_photo").live("click", function() { $("#auswahl").html(""); $("#upload_files").click() }); $("#add_photo").live(event_name, function() { $("#auswahl").html(""); $("#upload_files").click() });
/* Toolbar Buttons */ /* Toolbar Buttons */
$("#button_signout").live("click", function() { $("#button_signout").live(event_name, function() {
modal = buildModal("Sign Out", "Are you sure you want to leave and log out?", ["Sign out", "Stay here"], ["logout();", ""]); modal = buildModal("Sign Out", "Are you sure you want to leave and log out?", ["Sign out", "Stay here"], ["logout();", ""]);
$("body").append(modal); $("body").append(modal);
}); });
$("#button_download").live("click", function() { $("#button_download").live(event_name, function() {
link = $("#image_view #image").css("background-image").replace(/"/g,"").replace(/url\(|\)$/ig, ""); link = $("#image_view #image").css("background-image").replace(/"/g,"").replace(/url\(|\)$/ig, "");
window.open(link,"_newtab"); window.open(link,"_newtab");
}); });
$("#button_move").live("click", function(e) { $("#button_move").live(event_name, function(e) {
showContextMenuMove(image_view.attr("data-id"), e.pageX, e.pageY); showContextMenuMove(image_view.attr("data-id"), e.pageX, e.pageY);
}); });
$("#button_trash_album").live("click", function() { $("#button_trash_album").live(event_name, function() {
if (content.attr("data-id")=="0") deleteUnsorted(); if (content.attr("data-id")=="0") deleteUnsorted();
else deleteAlbum(); else deleteAlbum();
}); });
$("#button_trash").live("click", function() { deletePhoto() }); $("#button_trash").live(event_name, function() { deletePhoto() });
$("#button_edit_album").live("click", function() { renameAlbum() }); $("#button_edit_album").live(event_name, function() { renameAlbum() });
$("#button_edit").live("click", function() { renamePhoto() }); $("#button_edit").live(event_name, function() { renamePhoto() });
$("#button_info").live("click", function() { showInfobox() }); $("#button_info").live(event_name, function() { showInfobox() });
$("#button_archive").live("click", function() { getAlbumArchive() }); $("#button_archive").live(event_name, function() { getAlbumArchive() });
$("#button_sync").live("click", function() { syncFolder() }); $("#button_sync").live(event_name, function() { syncFolder() });
/* Rename Album/Photo via Titlebar */ /* Rename Album/Photo via Titlebar */
$("#title.editable").live("click", function() { $("#title.editable").live(event_name, function() {
if (visibleImageview()) renamePhoto(); else renameAlbum(); if (visibleImageview()) renamePhoto(); else renameAlbum();
}); });
/* Context Menu */ /* Context Menu */
$(".photo").live("contextmenu", function(e) { $(".photo").live("contextmenu", function(e) {
e.preventDefault(); e.preventDefault();
showContextMenuPhoto($(this).attr("data-id"), e.pageX, e.pageY); showContextMenuPhoto($(this).attr("data-id"), e.pageX, e.pageY);
}); });
$(".contextmenu_bg").live("click", closeContextMenu); $(".contextmenu_bg").live(event_name, closeContextMenu);
/* Star/Share Photo */ /* Star/Share Photo */
$("#button_star").live("click", setPhotoStar); $("#button_star").live(event_name, setPhotoStar);
$("#button_share").live("click", function(e) { $("#button_share").live(event_name, function(e) {
if ($("#button_share a.active").length) showContextMenuShare(image_view.attr("data-id"), e.pageX, e.pageY); if ($("#button_share a.active").length) showContextMenuShare(image_view.attr("data-id"), e.pageX, e.pageY);
else setPhotoPublic(e); else setPhotoPublic(e);
}); });
$(".copylink").live("click", function() { $(this).select() }); $(".copylink").live(event_name, function() { $(this).select() });
/* Upload */ /* Upload */
$("#upload_files").live("change", function() { $("#upload_files").live("change", function() {
closeModal(); closeModal();
handleFiles(this.files); handleFiles(this.files);
$("#upload_button").click(); $("#upload_button").click();
}); });
/* Search */ /* Search */
$("#search").live("keyup", function() { search($(this).val()) }); $("#search").live("keyup", function() { search($(this).val()) });
@ -84,32 +88,32 @@ $(document).ready(function(){
$(".photo").live("click", function() { setURL("a" + content.attr("data-id") + "p" + $(this).attr("data-id")) }); $(".photo").live("click", function() { setURL("a" + content.attr("data-id") + "p" + $(this).attr("data-id")) });
/* Nav Back */ /* Nav Back */
$("#button_back_home").live("click", function() { setURL("") }); $("#button_back_home").live(event_name, function() { setURL("") });
$("#button_back").live("click", function() { setURL("a" + content.attr("data-id")) }); $("#button_back").live(event_name, function() { setURL("a" + content.attr("data-id")) });
/* Close Modal */ /* Close Modal */
$(".message a.close").live("click", closeModal); $(".message a.close").live(event_name, closeModal);
/* Image View */ /* Image View */
$("#image_view a#previous").live("click", loadPreviousPhoto); $("#image_view a#previous").live(event_name, loadPreviousPhoto);
$("#image_view a#next").live("click", loadNextPhoto); $("#image_view a#next").live(event_name, loadNextPhoto);
/* Infobox */ /* Infobox */
$("#infobox_overlay, #infobox .header a").live("click", function() { hideInfobox() }); $("#infobox_overlay, #infobox .header a").live(event_name, function() { hideInfobox() });
$("#edit_description").live("click", function() { setPhotoDescription() }); $("#edit_description").live(event_name, function() { setPhotoDescription() });
/* Window */ /* Window */
$(window).keydown(key); $(window).keydown(key);
$(window).bind("popstate", getURL); $(window).bind("popstate", getURL);
$(window).bind("mouseleave", hideControls); $(window).bind("mouseleave", hideControls);
$(window).bind("mouseenter", showControls); $(window).bind("mouseenter", showControls);
/* Init */ /* Init */
if ((BrowserDetect.browser=="Explorer")||(BrowserDetect.browser=="Safari"&&BrowserDetect.version<5)||(BrowserDetect.browser=="Chrome"&&BrowserDetect.version<18)||(BrowserDetect.browser=="Firefox"&&BrowserDetect.version<14)) { if ((BrowserDetect.browser=="Explorer")||(BrowserDetect.browser=="Safari"&&BrowserDetect.version<5)||(BrowserDetect.browser=="Chrome"&&BrowserDetect.version<18)||(BrowserDetect.browser=="Firefox"&&BrowserDetect.version<15)) {
modal = buildModal("Browser not supported", "You are currently using an outdated or unsupported Browser. This site might not work properly. Please consider to update your Browser!", ["Leave"], ["location.href = 'http://browsehappy.com';"]); modal = buildModal("Browser not supported", "You are currently using an outdated or unsupported Browser. This site might not work properly. Please consider to update your Browser!", ["Leave"], ["location.href = 'http://browsehappy.com';"]);
$("body").append(modal); $("body").append(modal);
} else init(); } else init();
}); });

38
js/upload.js Normal file → Executable file
View File

@ -16,23 +16,23 @@ function handleFiles(files) {
var fileList = files; var fileList = files;
for(i = 0; i < fileList.length; i++) { for(i = 0; i < fileList.length; i++) {
var img = document.createElement("img"); var img = document.createElement("img");
img.height = 0; img.height = 0;
img.file = fileList[i]; img.file = fileList[i];
img.name = 'pic_'+ i; img.name = 'pic_'+ i;
img.classList.add("obj"); img.classList.add("obj");
auswahl_div.appendChild(img); auswahl_div.appendChild(img);
} }
} }
function sendFiles(){ function sendFiles(){
imgs = document.querySelectorAll(".obj"); imgs = document.querySelectorAll(".obj");
$(".upload_overlay").remove(); $(".upload_overlay").remove();
$("body").append(buildUploadModal()); $("body").append(buildUploadModal());
global_progress = new Array(); global_progress = new Array();
last_final_progress = 0; last_final_progress = 0;
@ -40,38 +40,38 @@ function sendFiles(){
global_progress[i] = 0; global_progress[i] = 0;
new FileUpload(i, imgs[i], imgs[i].file); new FileUpload(i, imgs[i], imgs[i].file);
} }
} }
function changeProgress(i, progress) { function changeProgress(i, progress) {
global_progress[i] = progress; global_progress[i] = progress;
final_progress = 0; final_progress = 0;
for(i = 0; i < global_progress.length; i++) { for(i = 0; i < global_progress.length; i++) {
final_progress += global_progress[i]; final_progress += global_progress[i];
} }
if (Math.round(final_progress/document.querySelectorAll(".obj").length)%2==0&&Math.round(last_final_progress/document.querySelectorAll(".obj").length)<Math.round(final_progress/document.querySelectorAll(".obj").length)) { if (Math.round(final_progress/document.querySelectorAll(".obj").length)%2==0&&Math.round(last_final_progress/document.querySelectorAll(".obj").length)<Math.round(final_progress/document.querySelectorAll(".obj").length)) {
$(".progressbar div").css("width", Math.round(final_progress/document.querySelectorAll(".obj").length) + "%"); $(".progressbar div").css("width", Math.round(final_progress/document.querySelectorAll(".obj").length) + "%");
} }
last_final_progress = final_progress; last_final_progress = final_progress;
if ((final_progress/document.querySelectorAll(".obj").length)>=100) { if ((final_progress/document.querySelectorAll(".obj").length)>=100) {
$(".progressbar div").css("width", "100%"); $(".progressbar div").css("width", "100%");
$.timer(1000,function(){ $.timer(1000,function(){
$(".upload_overlay").removeClass("fadeIn").css("opacity", 0); $(".upload_overlay").removeClass("fadeIn").css("opacity", 0);
$.timer(300,function(){ $(".upload_overlay").remove() }); $.timer(300,function(){ $(".upload_overlay").remove() });
if (content.attr("data-id")=="") setURL("a0"); if (content.attr("data-id")=="") setURL("a0");
else loadPhotos(content.attr("data-id")); else loadPhotos(content.attr("data-id"));
}); });
} }
} }
@ -82,7 +82,7 @@ function FileUpload(i, img, file) {
xhr = new XMLHttpRequest(), xhr = new XMLHttpRequest(),
fd = new FormData, fd = new FormData,
percent = 0; percent = 0;
this.xhr = xhr; this.xhr = xhr;
this.xhr.upload.addEventListener("progress", function(e) { this.xhr.upload.addEventListener("progress", function(e) {
@ -94,9 +94,9 @@ function FileUpload(i, img, file) {
fd.append("function", "upload"); fd.append("function", "upload");
if (content.attr("data-id")=="") fd.append("albumID", 0); if (content.attr("data-id")=="") fd.append("albumID", 0);
else fd.append("albumID", content.attr("data-id")); else fd.append("albumID", content.attr("data-id"));
xhr.open("POST", "php/api.php", true); xhr.open("POST", "php/api.php", true);
xhr.overrideMimeType('text/plain; charset=x-user-defined-binary'); xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
xhr.send(fd); xhr.send(fd);
} }

View File

@ -10,7 +10,7 @@ var header = $("header"),
image_view = $("#image_view"), image_view = $("#image_view"),
api_path = "php/api.php", api_path = "php/api.php",
infobox = $("#infobox"); infobox = $("#infobox");
$(document).ready(function(){ $(document).ready(function(){
/* Window */ /* Window */
@ -25,9 +25,9 @@ $(document).ready(function(){
link = $("#image_view #image").css("background-image").replace(/"/g,"").replace(/url\(|\)$/ig, ""); link = $("#image_view #image").css("background-image").replace(/"/g,"").replace(/url\(|\)$/ig, "");
window.open(link,"_newtab"); window.open(link,"_newtab");
}); });
loadPhotoInfo(gup("p")); loadPhotoInfo(gup("p"));
}); });
function key(e) { function key(e) {
@ -41,7 +41,7 @@ function visibleInfobox() {
if (parseInt(infobox.css("right").replace("px", ""))<0) return false; if (parseInt(infobox.css("right").replace("px", ""))<0) return false;
else return true; else return true;
} }
function isPhotoSmall(photo) { function isPhotoSmall(photo) {
@ -53,7 +53,7 @@ function isPhotoSmall(photo) {
if (photo.width<$(window).width()-60) size["width"] = true; if (photo.width<$(window).width()-60) size["width"] = true;
if (photo.height<$(window).height()-100) size["height"] = true; if (photo.height<$(window).height()-100) size["height"] = true;
if (size["width"]&&size["height"]) return true; if (size["width"]&&size["height"]) return true;
else return false; else return false;
@ -63,14 +63,14 @@ function showInfobox() {
$("body").append("<div id='infobox_overlay'></div>"); $("body").append("<div id='infobox_overlay'></div>");
infobox.css("right", "0px"); infobox.css("right", "0px");
} }
function hideInfobox() { function hideInfobox() {
$("#infobox_overlay").remove(); $("#infobox_overlay").remove();
infobox.css("right", "-320px"); infobox.css("right", "-320px");
} }
function loadPhotoInfo(photoID) { function loadPhotoInfo(photoID) {
@ -86,7 +86,7 @@ function loadPhotoInfo(photoID) {
if (isPhotoSmall(data)) image_view.html("").append("<div id='image' class='small' style='background-image: url(" + data.url + "); width: " + data.width + "px; height: " + data.height + "px; margin-top: -" + parseInt((data.height/2)-20) + "px; margin-left: -" + data.width/2 + "px;'></div>"); if (isPhotoSmall(data)) image_view.html("").append("<div id='image' class='small' style='background-image: url(" + data.url + "); width: " + data.width + "px; height: " + data.height + "px; margin-top: -" + parseInt((data.height/2)-20) + "px; margin-left: -" + data.width/2 + "px;'></div>");
else image_view.html("").append("<div id='image' style='background-image: url(" + data.url + "); top: 70px; right: 30px; bottom: 30px; left: 30px;'></div>"); else image_view.html("").append("<div id='image' style='background-image: url(" + data.url + "); top: 70px; right: 30px; bottom: 30px; left: 30px;'></div>");
image_view.removeClass("fadeOut").addClass("fadeIn").show(); image_view.removeClass("fadeOut").addClass("fadeIn").show();
infobox.html(buildInfobox(data)).show(); infobox.html(buildInfobox(data)).show();
}, error: ajaxError }); }, error: ajaxError });
@ -98,5 +98,5 @@ function ajaxError(jqXHR, textStatus, errorThrown) {
console.log(jqXHR); console.log(jqXHR);
console.log(textStatus); console.log(textStatus);
console.log(errorThrown); console.log(errorThrown);
} }

52
php/api.php Normal file → Executable file
View File

@ -1,10 +1,10 @@
<?php <?php
/** /**
* @name api.php * @name api.php
* @author Philipp Maurer * @author Philipp Maurer
* @author Tobias Reich * @author Tobias Reich
* @copyright 2012 by Philipp Maurer, Tobias Reich * @copyright 2012 by Philipp Maurer, Tobias Reich
*/ */
if((isset($_POST["function"])&&$_POST["function"]!="")||(isset($_GET["function"])&&$_GET["function"]!="")) { if((isset($_POST["function"])&&$_POST["function"]!="")||(isset($_GET["function"])&&$_GET["function"]!="")) {
@ -29,8 +29,8 @@ if((isset($_POST["function"])&&$_POST["function"]!="")||(isset($_GET["function"]
if($_POST["function"]=="getAlbumInfo"&&isset($_POST["albumID"])) echo array2json(getAlbumInfo($_POST["albumID"])); 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"]=="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($_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($_GET["function"]=="getAlbumArchive"&&isset($_GET["albumID"])) getAlbumArchive($_GET["albumID"]);
// Photo Functions // Photo Functions
if($_POST["function"]=="getPhotos"&&isset($_POST["albumID"])) echo array2json(getPhotos($_POST["albumID"])); 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"]=="getPhotoInfo"&&isset($_POST["photoID"])) echo array2json(getPhotoInfo($_POST["photoID"]));
@ -39,35 +39,35 @@ if((isset($_POST["function"])&&$_POST["function"]!="")||(isset($_GET["function"]
if($_POST["function"]=="setPhotoTitle"&&isset($_POST["photoID"])&&isset($_POST["title"])) echo setPhotoTitle($_POST["photoID"], $_POST["title"]); 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"]=="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"]=="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"]=="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"]=="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"]=="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"]=="nextPhoto"&&isset($_POST["photoID"])&&isset($_POST["albumID"])) echo array2json(nextPhoto($_POST["photoID"], $_POST["albumID"]));
// Upload Function // Upload Function
if($_POST["function"]=="upload"&&isset($_FILES)&&isset($_POST["albumID"])) echo upload($_FILES, $_POST["albumID"]); if($_POST["function"]=="upload"&&isset($_FILES)&&isset($_POST["albumID"])) echo upload($_FILES, $_POST["albumID"]);
// Search Function // Search Function
if($_POST["function"]=="search"&&isset($_POST["term"])) echo array2json(search($_POST["term"])); if($_POST["function"]=="search"&&isset($_POST["term"])) echo array2json(search($_POST["term"]));
// Sync Function // Sync Function
if($_POST["function"]=="syncFolder") echo syncFolder(); if($_POST["function"]=="syncFolder") echo syncFolder();
// Session Functions // Session Functions
if($_POST["function"]=="logout") logout(); if($_POST["function"]=="logout") logout();
if($_POST["function"]=="loggedIn") echo true; if($_POST["function"]=="loggedIn") echo true;
} else { } else {
dbConnect(); dbConnect();
// Photo Functions // Photo Functions
if($_POST["function"]=="getPhotoInfo"&&isset($_POST["photoID"])&&isPhotoPublic($_POST["photoID"])) echo array2json(getPhotoInfo($_POST["photoID"])); if($_POST["function"]=="getPhotoInfo"&&isset($_POST["photoID"])&&isPhotoPublic($_POST["photoID"])) echo array2json(getPhotoInfo($_POST["photoID"]));
// Session Functions // Session Functions
if($_POST["function"]=="login") echo login($_POST['user'], $_POST['password']); if($_POST["function"]=="login") echo login($_POST['user'], $_POST['password']);
if($_POST["function"]=="loggedIn") echo false; if($_POST["function"]=="loggedIn") echo false;
} }
} else echo "Error: No permission!"; } else echo "Error: No permission!";

62
php/functions.php Normal file → Executable file
View File

@ -6,7 +6,7 @@
* @author Tobias Reich * @author Tobias Reich
* @copyright 2012 by Philipp Maurer, Tobias Reich * @copyright 2012 by Philipp Maurer, Tobias Reich
*/ */
include("config.php"); include("config.php");
// Database Functions // Database Functions
@ -49,7 +49,7 @@ function createTables() {
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;"; ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
$result = mysql_query($query); $result = mysql_query($query);
if(!$result) return false; if(!$result) return false;
$query = "CREATE TABLE IF NOT EXISTS `photos` ( $query = "CREATE TABLE IF NOT EXISTS `photos` (
`id` bigint(14) NOT NULL, `id` bigint(14) NOT NULL,
`title` varchar(50) NOT NULL, `title` varchar(50) NOT NULL,
@ -151,9 +151,9 @@ function getCamera($photoID) {
$return['size'] = $size; $return['size'] = $size;
$return['date'] = date("d.m.Y",filectime($url)); $return['date'] = date("d.m.Y",filectime($url));
$return['time'] = date("H:i:s",filectime($url)); $return['time'] = date("H:i:s",filectime($url));
echo $exif['FileDateTime']."<br/>".$exif['DateTimeOriginal']; echo $exif['FileDateTime']."<br/>".$exif['DateTimeOriginal'];
// Camera Information // Camera Information
if(isset($exif['ISOSpeedRatings'])){$return['iso']="ISO-".$exif['ISOSpeedRatings'];} if(isset($exif['ISOSpeedRatings'])){$return['iso']="ISO-".$exif['ISOSpeedRatings'];}
if(isset($exif['COMPUTED']['ApertureFNumber'])){$return['aperture']=$exif['COMPUTED']['ApertureFNumber'];} if(isset($exif['COMPUTED']['ApertureFNumber'])){$return['aperture']=$exif['COMPUTED']['ApertureFNumber'];}
@ -274,7 +274,7 @@ function getSmartInfo() {
$i++; $i++;
} }
$return['unsortNum'] = $i; $return['unsortNum'] = $i;
$query2 = "SELECT * FROM photos WHERE public = 1 ORDER BY id DESC;"; $query2 = "SELECT * FROM photos WHERE public = 1 ORDER BY id DESC;";
$result2 = mysql_query($query2); $result2 = mysql_query($query2);
$i = 0; $i = 0;
@ -283,7 +283,7 @@ function getSmartInfo() {
$i++; $i++;
} }
$return['publicNum'] = $i; $return['publicNum'] = $i;
$query3 = "SELECT * FROM photos WHERE star = 1 ORDER BY id DESC;"; $query3 = "SELECT * FROM photos WHERE star = 1 ORDER BY id DESC;";
$result3 = mysql_query($query3); $result3 = mysql_query($query3);
$i = 0; $i = 0;
@ -293,7 +293,7 @@ function getSmartInfo() {
} }
$return['starredNum'] = $i; $return['starredNum'] = $i;
return $return; return $return;
} }
function getAlbumInfo($albumID) { function getAlbumInfo($albumID) {
$return = array(); $return = array();
@ -365,26 +365,26 @@ function getAlbumArchive($albumID) {
$row = mysql_fetch_object($result); $row = mysql_fetch_object($result);
if($albumID!=0&&is_numeric($albumID))$zipTitle = $row->title; if($albumID!=0&&is_numeric($albumID))$zipTitle = $row->title;
$filename = "./".$zipTitle.".zip"; $filename = "./".$zipTitle.".zip";
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
return false; return false;
} }
foreach($files AS $zipFile) { foreach($files AS $zipFile) {
$newFile = explode("/",$zipFile); $newFile = explode("/",$zipFile);
$newFile = array_reverse($newFile); $newFile = array_reverse($newFile);
$zip->addFile($zipFile, $zipTitle."/".$newFile[0]); $zip->addFile($zipFile, $zipTitle."/".$newFile[0]);
} }
$zip->close(); $zip->close();
header("Content-Type: application/zip"); header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"$zipTitle.zip\""); header("Content-Disposition: attachment; filename=\"$zipTitle.zip\"");
readfile($filename); readfile($filename);
unlink($filename); unlink($filename);
return true; return true;
} }
@ -417,15 +417,15 @@ function downloadPhoto($photoID) {
$query = "SELECT * FROM photos WHERE id = '$photoID';"; $query = "SELECT * FROM photos WHERE id = '$photoID';";
$result = mysql_query($query); $result = mysql_query($query);
$row = mysql_fetch_object($result); $row = mysql_fetch_object($result);
$photo = "../".$row->url; $photo = "../".$row->url;
$title = $row->title; $title = $row->title;
$type = "appcication/zip"; $type = "appcication/zip";
$filename = "./imageDownload.zip"; $filename = "./imageDownload.zip";
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) return false; if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) return false;
$newFile = explode("/",$photo); $newFile = explode("/",$photo);
$newFile = array_reverse($newFile); $newFile = array_reverse($newFile);
$zip->addFile($photo, $title.$newFile[0]); $zip->addFile($photo, $title.$newFile[0]);
@ -454,7 +454,7 @@ function setPhotoPublic($photoID, $url) {
$shortlink = ""; $shortlink = "";
}else{ }else{
if($row->shortlink==""){ if($row->shortlink==""){
$shortlink = urlShortner($url); $shortlink = urlShortner($url);
}else{ }else{
$shortlink = $row->shortlink; $shortlink = $row->shortlink;
} }
@ -497,7 +497,7 @@ function nextPhoto($photoID, $albumID) {
$result = mysql_query($query); $result = mysql_query($query);
$return = mysql_fetch_array($result); $return = mysql_fetch_array($result);
} }
return $return; return $return;
} }
function previousPhoto($photoID, $albumID) { function previousPhoto($photoID, $albumID) {
switch($albumID) { switch($albumID) {
@ -564,9 +564,9 @@ function urlShortner($url) {
if($bitlyUsername==""||$bitlyApi=="") return false; if($bitlyUsername==""||$bitlyApi=="") return false;
$url = urlencode($url); $url = urlencode($url);
$bitlyAPI = "http://api.bit.ly/shorten?version=2.0.1&format=xml&longUrl=$url&login=$bitlyUsername&apiKey=$bitlyApi"; $bitlyAPI = "http://api.bit.ly/shorten?version=2.0.1&format=xml&longUrl=$url&login=$bitlyUsername&apiKey=$bitlyApi";
$data = file_get_contents($bitlyAPI); $data = file_get_contents($bitlyAPI);
$xml = simplexml_load_string($data); $xml = simplexml_load_string($data);
$shortlink = $xml->results->nodeKeyVal->shortUrl; $shortlink = $xml->results->nodeKeyVal->shortUrl;
return $shortlink; return $shortlink;
@ -575,18 +575,18 @@ function sharePhoto($photoID, $url) {
$query = "SELECT * FROM photos WHERE id = '$photoID'"; $query = "SELECT * FROM photos WHERE id = '$photoID'";
$result = mysql_query($query); $result = mysql_query($query);
$row = mysql_fetch_object($result); $row = mysql_fetch_object($result);
$thumb = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."/../../".$row->thumbUrl; $thumb = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."/../../".$row->thumbUrl;
$title = $row->title; $title = $row->title;
$description = $row->description; $description = $row->description;
$shortlink = $row->shortlink; $shortlink = $row->shortlink;
$twitterUrl = "https://twitter.com/share?url=".urlencode("$url"); $twitterUrl = "https://twitter.com/share?url=".urlencode("$url");
$facebookUrl = "http://www.facebook.com/sharer.php?u=".urlencode("$url")."&t=".urlencode($title); $facebookUrl = "http://www.facebook.com/sharer.php?u=".urlencode("$url")."&t=".urlencode($title);
$tumblrUrl = "http://www.tumblr.com/share/link?url=".urlencode("$url")."&name=". urlencode($title)."&description=".urlencode($description); $tumblrUrl = "http://www.tumblr.com/share/link?url=".urlencode("$url")."&name=". urlencode($title)."&description=".urlencode($description);
$pinterestUrl = "http://pinterest.com/pin/create/button/?url=".urlencode("$url")."&media=".urlencode($thumb); $pinterestUrl = "http://pinterest.com/pin/create/button/?url=".urlencode("$url")."&media=".urlencode($thumb);
$mailUrl = "mailto:?subject=".rawurlencode($title)."&body=".rawurlencode("Hey guy! Check this out: $url"); $mailUrl = "mailto:?subject=".rawurlencode($title)."&body=".rawurlencode("Hey guy! Check this out: $url");
$share = array(); $share = array();
$share['twitter'] = $twitterUrl; $share['twitter'] = $twitterUrl;
$share['facebook'] = $facebookUrl; $share['facebook'] = $facebookUrl;
@ -594,7 +594,7 @@ function sharePhoto($photoID, $url) {
$share['pinterest'] = $pinterestUrl; $share['pinterest'] = $pinterestUrl;
$share['mail'] = $mailUrl; $share['mail'] = $mailUrl;
$share['shortlink'] = $shortlink; $share['shortlink'] = $shortlink;
return $share; return $share;
} }
function facebookHeader($photoID) { function facebookHeader($photoID) {
@ -603,14 +603,14 @@ function facebookHeader($photoID) {
$query = "SELECT * FROM photos WHERE id = '$photoID';"; $query = "SELECT * FROM photos WHERE id = '$photoID';";
$result = mysql_query($query); $result = mysql_query($query);
$row = mysql_fetch_object($result); $row = mysql_fetch_object($result);
$parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); $parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$thumb = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../".$row->thumbUrl; $thumb = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../".$row->thumbUrl;
$return = '<meta name="title" content="'.$row->title.'" />'; $return = '<meta name="title" content="'.$row->title.'" />';
$return .= '<meta name="description" content="'.$row->description.' - via Lychee" />'; $return .= '<meta name="description" content="'.$row->description.' - via Lychee" />';
$return .= '<link rel="image_src" type="image/jpeg" href="'. $thumb .'" />'; $return .= '<link rel="image_src" type="image/jpeg" href="'. $thumb .'" />';
return $return; return $return;
} }
function isPhotoPublic($photoID) { function isPhotoPublic($photoID) {
@ -624,19 +624,19 @@ function isPhotoPublic($photoID) {
// Search Function // Search Function
function search($term) { function search($term) {
$term = mysql_real_escape_string($term); $term = mysql_real_escape_string($term);
$query = "SELECT * FROM photos WHERE title like '%$term%' OR description like '%$term%';"; $query = "SELECT * FROM photos WHERE title like '%$term%' OR description like '%$term%';";
$result = mysql_query($query); $result = mysql_query($query);
while($row = mysql_fetch_array($result)) { while($row = mysql_fetch_array($result)) {
$return['photos'][] = $row; $return['photos'][] = $row;
} }
$query = "SELECT * FROM albums WHERE title like '%$term%';"; $query = "SELECT * FROM albums WHERE title like '%$term%';";
$result = mysql_query($query); $result = mysql_query($query);
$i=0; $i=0;
while($row = mysql_fetch_array($result)) { while($row = mysql_fetch_array($result)) {
$return['albums'][$i] = $row; $return['albums'][$i] = $row;
$query = "SELECT thumbUrl FROM photos WHERE album = '".$row['id']."' ORDER BY id DESC LIMIT 0, 3;"; $query = "SELECT thumbUrl FROM photos WHERE album = '".$row['id']."' ORDER BY id DESC LIMIT 0, 3;";
$result2 = mysql_query($query); $result2 = mysql_query($query);
$k = 0; $k = 0;
@ -644,7 +644,7 @@ function search($term) {
$return['albums'][$i]["thumb$k"] = $row2->thumbUrl; $return['albums'][$i]["thumb$k"] = $row2->thumbUrl;
$k++; $k++;
} }
} }
return $return; return $return;
} }

View File

@ -2,8 +2,8 @@
#### A great looking and easy-to-use Photo-Management-System. #### A great looking and easy-to-use Photo-Management-System.
![Lychee ImageView](http://lychee.electerious.com/uploads/big/13511584079432.png) ![Lychee ImageView](http://lychee.electerious.com/uploads/big/13582806160093.png)
![Lychee ImageView](http://lychee.electerious.com/uploads/big/13497110451270.png) ![Lychee ImageView](http://lychee.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. 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.

0
uploads/big/empty.md Executable file
View File

0
uploads/thumb/empty.md Executable file
View File

12
view.php Normal file → Executable file
View File

@ -16,17 +16,17 @@
<link rel="shortcut icon" href="img/favicon.png"> <link rel="shortcut icon" href="img/favicon.png">
<meta name="apple-mobile-web-app-status-bar-style" content="black" > <meta name="apple-mobile-web-app-status-bar-style" content="black" >
<meta name="viewport" content="width=device-width, user-scalable=no"> <meta name="viewport" content="user-scalable=no, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<?php if(isset($_GET['p'])) echo facebookHeader($_GET['p']); ?> <?php if(isset($_GET['p'])) echo facebookHeader($_GET['p']); ?>
</head> </head>
<body> <body>
<!-- Loading --> <!-- Loading -->
<div id="loading"></div> <div id="loading"></div>
<!-- Header --> <!-- Header -->
<header> <header>
@ -37,10 +37,10 @@
<a id="title"></a> <a id="title"></a>
</header> </header>
<!-- ImageView --> <!-- ImageView -->
<div id="image_view"></div> <div id="image_view"></div>
<!-- Infobox --> <!-- Infobox -->
<div id="infobox"></div> <div id="infobox"></div>