- FTP Sharing - New Upload & New Search - Performance and stuff under the hood - Desktop Notifications - Right-Click on photos and albums - Retina Thumbs - Improved Interfacepull/4/head 1.1
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 127 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 184 B After Width: | Height: | Size: 184 B |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 113 B |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 4.0 KiB |
@ -1,247 +0,0 @@
|
||||
/**
|
||||
* @name build.js
|
||||
* @author Philipp Maurer
|
||||
* @author Tobias Reich
|
||||
* @copyright 2012 by Philipp Maurer, Tobias Reich
|
||||
*/
|
||||
|
||||
/*
|
||||
Build Functions
|
||||
This functions are used to generate HTML-Code.
|
||||
*/
|
||||
|
||||
function buildDivider(title) {
|
||||
|
||||
return "<div class='divider fadeIn'><h1>" + title + "</h1></div>";
|
||||
|
||||
}
|
||||
|
||||
function buildAlbum(albumJSON) {
|
||||
|
||||
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.title) albumJSON.title = "Untitled";
|
||||
if(albumJSON.title.length>18) albumJSON.title = albumJSON.title.substr(0, 18) + "...";
|
||||
|
||||
var album = "";
|
||||
album += "<div class='album' data-id='" + albumJSON.id + "'>";
|
||||
album += "<img src='" + albumJSON.thumb2 + "' width='200' height='200' alt='thumb'>";
|
||||
album += "<img src='" + albumJSON.thumb1 + "' width='200' height='200' alt='thumb'>";
|
||||
album += "<img src='" + albumJSON.thumb0 + "' width='200' height='200' alt='thumb'>";
|
||||
album += "<div class='overlay'>";
|
||||
album += "<h1>" + albumJSON.title + "</h1>";
|
||||
album += "<a>" + albumJSON.sysdate + "</a>";
|
||||
album += "</div>";
|
||||
|
||||
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.unsorted=="1") album += "<a class='badge red icon-reorder'></a>";
|
||||
|
||||
album += "</div>";
|
||||
|
||||
return album;
|
||||
|
||||
}
|
||||
|
||||
function buildPhoto(photoJSON) {
|
||||
|
||||
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 += "<div class='photo' data-id='" + photoJSON.id + "'>";
|
||||
photo += "<img src='" + photoJSON.thumbUrl + "' width='200' height='200' alt='thumb'>";
|
||||
photo += "<div class='overlay'>";
|
||||
photo += "<h1>" + photoJSON.title + "</h1>";
|
||||
photo += "<a>" + photoJSON.sysdate + "</a>";
|
||||
photo += "</div>";
|
||||
|
||||
if(photoJSON.star=="1") photo += "<a class='badge red icon-star'></a>";
|
||||
if(photoJSON.public=="1") photo += "<a class='badge red icon-rss'></a>";
|
||||
|
||||
photo += "</div>";
|
||||
|
||||
return photo;
|
||||
|
||||
}
|
||||
|
||||
function buildModal(title, text, button, func) {
|
||||
|
||||
var modal = "";
|
||||
modal += "<div class='message_overlay fadeIn'>";
|
||||
modal += "<div class='message center'>";
|
||||
modal += "<h1>" + title + "</h1>";
|
||||
modal += "<a class='close icon-remove-sign'></a>";
|
||||
modal += "<p>" + text + "</p>";
|
||||
|
||||
$.each(button, function(index) {
|
||||
|
||||
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>";
|
||||
|
||||
});
|
||||
|
||||
modal += "</div>";
|
||||
|
||||
modal += "<script>";
|
||||
modal += "function message_click(action) {";
|
||||
modal += "switch (action) {";
|
||||
|
||||
$.each(func, function(index) {
|
||||
|
||||
modal += "case " + index + ":";
|
||||
modal += this.toString();
|
||||
modal += "break;";
|
||||
|
||||
});
|
||||
|
||||
modal += "} closeModal(); }";
|
||||
modal += "</script>";
|
||||
|
||||
modal += "</div>";
|
||||
|
||||
return modal;
|
||||
|
||||
}
|
||||
|
||||
function buildAddModal() {
|
||||
|
||||
var modal = "";
|
||||
modal += "<div class='message_overlay fadeIn'>";
|
||||
modal += "<div class='message center add'>";
|
||||
modal += "<h1>Add Album or Photo</h1>";
|
||||
modal += "<a class='close icon-remove-sign'></a>";
|
||||
modal += "<div id='add_album' class='add_album'>";
|
||||
modal += "<div class='icon icon-folder-close'></div>";
|
||||
modal += "<a>Add new Album</a>";
|
||||
modal += "</div>";
|
||||
modal += "<div id='add_photo' class='add_album'>";
|
||||
modal += "<div class='icon icon-picture'></div>";
|
||||
modal += "<a>Upload new Photo</a>";
|
||||
modal += "</div>";
|
||||
modal += "</div>";
|
||||
modal += "</div>";
|
||||
|
||||
return modal;
|
||||
|
||||
}
|
||||
|
||||
function buildSignInModal() {
|
||||
|
||||
var modal = "";
|
||||
modal += "<div class='message_overlay'>";
|
||||
modal += "<div class='message center'>";
|
||||
modal += "<h1><a class='icon-lock'></a> Sign in</h1>";
|
||||
modal += "<div class='sign_in'>";
|
||||
modal += "<input id='username' type='text' name='' value='' placeholder='username'>";
|
||||
modal += "<input id='password' type='password' name='' value='' placeholder='password'>";
|
||||
modal += "</div>";
|
||||
modal += "<div id='version'>Version " + version + "</div>";
|
||||
modal += "<a onclick='login()' class='button active'>Sign in</a>";
|
||||
modal += "</div>";
|
||||
modal += "</div>";
|
||||
|
||||
return modal;
|
||||
|
||||
}
|
||||
|
||||
function buildUploadModal() {
|
||||
|
||||
var modal = "";
|
||||
modal += "<div class='upload_overlay fadeIn'>";
|
||||
modal += "<div class='upload_message center'>";
|
||||
modal += "<a class='icon-upload'></a>";
|
||||
modal += "<div class='progressbar'><div></div></div>";
|
||||
modal += "</div>";
|
||||
modal += "</div>";
|
||||
|
||||
return modal;
|
||||
|
||||
}
|
||||
|
||||
function buildContextMenu(items) {
|
||||
|
||||
var menu = "";
|
||||
menu += "<div class='contextmenu_bg'></div>";
|
||||
menu += "<div class='contextmenu'>";
|
||||
menu += "<table>";
|
||||
menu += "<tbody>";
|
||||
|
||||
$.each(items, function(index) {
|
||||
|
||||
if (items[index][1].length!=0) {
|
||||
menu += "<tr><td onclick='" + items[index][1] + "; closeContextMenu();'>" + items[index][0] + "</td></tr>";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
menu += "</tbody>";
|
||||
menu += "</table>";
|
||||
menu += "</div>";
|
||||
|
||||
return menu;
|
||||
|
||||
}
|
||||
|
||||
function buildInfobox(photo) {
|
||||
|
||||
var infobox = "";
|
||||
infobox += "<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>";
|
||||
infobox += "<div class='wrapper'>";
|
||||
|
||||
if (photo.public==1) photo.public = "Public"; else photo.public = "Private";
|
||||
|
||||
infos = [
|
||||
["", "Basics"],
|
||||
["Name", photo.title],
|
||||
["Uploaded", photo.sysdate],
|
||||
["Description", photo.description + " <div id='edit_description'><a class='icon-pencil'></a></div>"],
|
||||
["", "Image"],
|
||||
["Size", photo.size],
|
||||
["Format", photo.type],
|
||||
["Resolution", photo.width + " x " + photo.height],
|
||||
["", "Camera"],
|
||||
["Captured", photo.takedate],
|
||||
["Make", photo.make],
|
||||
["Type/Model", photo.model],
|
||||
["Shutter Speed", photo.shutter],
|
||||
["Aperture", photo.aperture],
|
||||
["Focal Length", photo.focal],
|
||||
["ISO", photo.iso],
|
||||
["", "Share"],
|
||||
["Privacy", photo.public],
|
||||
["Short Link", photo.shortlink]
|
||||
];
|
||||
|
||||
$.each(infos, function(index) {
|
||||
|
||||
if (infos[index][1]==""||infos[index][1]==undefined||infos[index][1]==null) infos[index][1] = "-";
|
||||
|
||||
if (infos[index][0]=="") {
|
||||
|
||||
infobox += "</table>";
|
||||
infobox += "<div class='separater'><h1>" + infos[index][1] + "</h1></div>";
|
||||
infobox += "<table id='infos'>";
|
||||
|
||||
} else {
|
||||
|
||||
infobox += "<tr>";
|
||||
infobox += "<td>" + infos[index][0] + "</td>";
|
||||
infobox += "<td>" + infos[index][1] + "</td>";
|
||||
infobox += "</tr>";
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
infobox += "</table>";
|
||||
infobox += "<div class='bumper'></div>";
|
||||
infobox += "</div>";
|
||||
|
||||
return infobox;
|
||||
|
||||
}
|
@ -0,0 +1,254 @@
|
||||
/**
|
||||
* @name albums.js
|
||||
* @author Philipp Maurer
|
||||
* @author Tobias Reich
|
||||
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
||||
*
|
||||
* Albums Module
|
||||
* Takes care of every action albums can handle and execute.
|
||||
*/
|
||||
|
||||
albums = {
|
||||
|
||||
load: function() {
|
||||
|
||||
loadingBar.show();
|
||||
lychee.animate(".album, .photo", "contentZoomOut");
|
||||
|
||||
/* Search */
|
||||
lychee.content.attr("data-search", "");
|
||||
lychee.animate(".divider", "fadeOut");
|
||||
|
||||
startTime = new Date().getTime();
|
||||
|
||||
lychee.api("getAlbums", "json", function(data) {
|
||||
|
||||
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();
|
||||
|
||||
/* Smart Albums */
|
||||
unsortedAlbum = new Object();
|
||||
unsortedAlbum.id = 0;
|
||||
unsortedAlbum.title = "Unsorted";
|
||||
unsortedAlbum.sysdate = data.unsortNum + " photos";
|
||||
unsortedAlbum.unsorted = 1;
|
||||
if (data.unsortThumb0) unsortedAlbum.thumb0 = lychee.upload_path + data.unsortThumb0; else unsortedAlbum.thumb0 = "";
|
||||
if (data.unsortThumb1) unsortedAlbum.thumb1 = lychee.upload_path + data.unsortThumb1; else unsortedAlbum.thumb1 = "";
|
||||
if (data.unsortThumb2) unsortedAlbum.thumb2 = lychee.upload_path + data.unsortThumb2; else unsortedAlbum.thumb2 = "";
|
||||
|
||||
starredAlbum = new Object();
|
||||
starredAlbum.id = "f";
|
||||
starredAlbum.title = "Starred";
|
||||
starredAlbum.sysdate = data.starredNum + " photos";
|
||||
starredAlbum.star = 1;
|
||||
if (data.starredThumb0) starredAlbum.thumb0 = lychee.upload_path + data.starredThumb0; else starredAlbum.thumb0 = "";
|
||||
if (data.starredThumb1) starredAlbum.thumb1 = lychee.upload_path + data.starredThumb1; else starredAlbum.thumb1 = "";
|
||||
if (data.starredThumb2) starredAlbum.thumb2 = lychee.upload_path + data.starredThumb2; else starredAlbum.thumb2 = "";
|
||||
|
||||
publicAlbum = new Object();
|
||||
publicAlbum.id = "s";
|
||||
publicAlbum.title = "Public";
|
||||
publicAlbum.sysdate = data.publicNum + " photos";
|
||||
publicAlbum.public = 1;
|
||||
if (data.publicThumb0) publicAlbum.thumb0 = lychee.upload_path + data.publicThumb0; else publicAlbum.thumb0 = "";
|
||||
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);
|
||||
|
||||
/* Albums */
|
||||
if (data.albums) {
|
||||
|
||||
albumsData = build.divider("Albums");
|
||||
$.each(data.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(albumID) {
|
||||
|
||||
if (albumID=="f"||albumID=="s"||albumID==0) {
|
||||
|
||||
lychee.headerTitle.removeClass("editable");
|
||||
|
||||
lychee.api("getSmartInfo", "json", function(data) {
|
||||
|
||||
switch (albumID) {
|
||||
case "f":
|
||||
document.title = "Lychee - Starred";
|
||||
lychee.headerTitle.html("Starred<span> - " + data.starredNum + " photos</span>");
|
||||
$("#button_edit_album, #button_trash_album, .button_divider").hide();
|
||||
break;
|
||||
case "s":
|
||||
document.title = "Lychee - Public";
|
||||
lychee.headerTitle.html("Public<span> - " + data.publicNum + " photos</span>");
|
||||
$("#button_edit_album, #button_trash_album, .button_divider").hide();
|
||||
break;
|
||||
case "0":
|
||||
document.title = "Lychee - Unsorted";
|
||||
lychee.headerTitle.html("Unsorted<span> - " + data.unsortNum + " photos</span>");
|
||||
$("#button_edit_album").hide();
|
||||
$("#button_trash_album, .button_divider").show();
|
||||
break;
|
||||
}
|
||||
|
||||
loadingBar.hide();
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
params = "getAlbumInfo&albumID=" + albumID;
|
||||
lychee.api(params, "json", function(data) {
|
||||
|
||||
$("#button_edit_album, #button_trash_album, .button_divider").show();
|
||||
|
||||
if (!data.title) data.title = "Untitled";
|
||||
document.title = "Lychee - " + data.title;
|
||||
lychee.headerTitle.html(data.title + "<span> - " + data.num + " photos</span>").addClass("editable");
|
||||
|
||||
loadingBar.hide();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
add: function() {
|
||||
|
||||
title = prompt("Please enter a title for this album:", "Untitled");
|
||||
lychee.closeModal();
|
||||
|
||||
if (title.length>2&&title.length<31) {
|
||||
|
||||
loadingBar.show();
|
||||
|
||||
params = "addAlbum&title=" + escape(title);
|
||||
lychee.api(params, "text", function(data) {
|
||||
|
||||
if (data) lychee.goto("a" + data);
|
||||
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(albumID) {
|
||||
|
||||
$(".album[data-id='" + albumID + "']").css("opacity", 0).animate({
|
||||
width: 0,
|
||||
marginLeft: 0
|
||||
}, 300, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
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("");
|
||||
|
||||
} else loadingBar.show("error");
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
deleteDialog: function(albumID) {
|
||||
|
||||
if (albumID==0) {
|
||||
|
||||
f1 = "albums.delete(0, true);";
|
||||
f2 = "";
|
||||
modal = build.modal("Clear Unsorted", "Are you sure you want to delete all photos from 'Unsorted'?<br>This action can't be undone!", ["Clear Unsorted", "Keep Photos"], [f1, f2]);
|
||||
$("body").append(modal);
|
||||
|
||||
} else {
|
||||
|
||||
if (visible.albums()) albumTitle = $(".album[data-id='" + albumID + "'] .overlay h1").html();
|
||||
else albumTitle = lychee.title();
|
||||
|
||||
f1 = "albums.delete(" + albumID + ", true);";
|
||||
f2 = "albums.delete(" + albumID + ", 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(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();
|
||||
|
||||
params = "setAlbumTitle&albumID=" + albumID + "&title=" + encodeURI(newTitle);
|
||||
lychee.api(params, "text", function(data) {
|
||||
|
||||
if (data) {
|
||||
if (visible.albums()) $(".album[data-id='" + albumID + "'] .overlay h1").html(newTitle);
|
||||
else {
|
||||
lychee.headerTitle.html(newTitle + "<span>" + $("#title span").html() + "</span>");
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,251 @@
|
||||
/**
|
||||
* @name build.js
|
||||
* @author Philipp Maurer
|
||||
* @author Tobias Reich
|
||||
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
||||
*
|
||||
* Build Module
|
||||
* This module is used to generate HTML-Code.
|
||||
*/
|
||||
|
||||
build = {
|
||||
|
||||
divider: function(title) {
|
||||
|
||||
return "<div class='divider fadeIn'><h1>" + title + "</h1></div>";
|
||||
|
||||
},
|
||||
|
||||
album: function(albumJSON) {
|
||||
|
||||
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.title) albumJSON.title = "Untitled";
|
||||
if(albumJSON.title.length>18) albumJSON.title = albumJSON.title.substr(0, 18) + "...";
|
||||
|
||||
var album = "";
|
||||
album += "<div class='album' data-id='" + albumJSON.id + "'>";
|
||||
album += "<img src='" + lychee.upload_path + albumJSON.thumb2 + "' width='200' height='200' alt='thumb'>";
|
||||
album += "<img src='" + lychee.upload_path + albumJSON.thumb1 + "' width='200' height='200' alt='thumb'>";
|
||||
album += "<img src='" + lychee.upload_path + albumJSON.thumb0 + "' width='200' height='200' alt='thumb'>";
|
||||
album += "<div class='overlay'>";
|
||||
album += "<h1>" + albumJSON.title + "</h1>";
|
||||
album += "<a>" + albumJSON.sysdate + "</a>";
|
||||
album += "</div>";
|
||||
|
||||
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.unsorted=="1") album += "<a class='badge red icon-reorder'></a>";
|
||||
|
||||
album += "</div>";
|
||||
|
||||
return album;
|
||||
|
||||
},
|
||||
|
||||
photo: function(photoJSON) {
|
||||
|
||||
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 += "<div class='photo' data-album-id='" + photoJSON.album + "' data-id='" + photoJSON.id + "'>";
|
||||
photo += "<img src='" + lychee.upload_path + photoJSON.thumbUrl + "' width='200' height='200' alt='thumb'>";
|
||||
photo += "<div class='overlay'>";
|
||||
photo += "<h1>" + photoJSON.title + "</h1>";
|
||||
photo += "<a>" + photoJSON.sysdate + "</a>";
|
||||
photo += "</div>";
|
||||
|
||||
if(photoJSON.star=="1") photo += "<a class='badge red icon-star'></a>";
|
||||
if(photoJSON.public=="1") photo += "<a class='badge red icon-rss'></a>";
|
||||
|
||||
photo += "</div>";
|
||||
|
||||
return photo;
|
||||
|
||||
},
|
||||
|
||||
modal: function(title, text, button, func) {
|
||||
|
||||
var modal = "";
|
||||
modal += "<div class='message_overlay fadeIn'>";
|
||||
modal += "<div class='message center'>";
|
||||
modal += "<h1>" + title + "</h1>";
|
||||
modal += "<a class='close icon-remove-sign'></a>";
|
||||
modal += "<p>" + text + "</p>";
|
||||
|
||||
$.each(button, function(index) {
|
||||
|
||||
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>";
|
||||
|
||||
});
|
||||
|
||||
modal += "</div>";
|
||||
|
||||
modal += "<script>";
|
||||
modal += "function message_click(action) {";
|
||||
modal += "switch (action) {";
|
||||
|
||||
$.each(func, function(index) {
|
||||
|
||||
modal += "case " + index + ":";
|
||||
modal += this.toString();
|
||||
modal += "break;";
|
||||
|
||||
});
|
||||
|
||||
modal += "} lychee.closeModal(); }";
|
||||
modal += "</script>";
|
||||
|
||||
modal += "</div>";
|
||||
|
||||
return modal;
|
||||
|
||||
},
|
||||
|
||||
addModal: function() {
|
||||
|
||||
var modal = "";
|
||||
modal += "<div class='message_overlay fadeIn'>";
|
||||
modal += "<div class='message center add'>";
|
||||
modal += "<h1>Add Album or Photo</h1>";
|
||||
modal += "<a class='close icon-remove-sign'></a>";
|
||||
modal += "<div id='add_album' class='add_album'>";
|
||||
modal += "<div class='icon icon-folder-close'></div>";
|
||||
modal += "<a>Add new Album</a>";
|
||||
modal += "</div>";
|
||||
modal += "<div id='add_photo' class='add_album'>";
|
||||
modal += "<div class='icon icon-picture'></div>";
|
||||
modal += "<a>Upload new Photo</a>";
|
||||
modal += "</div>";
|
||||
modal += "</div>";
|
||||
modal += "</div>";
|
||||
|
||||
return modal;
|
||||
|
||||
},
|
||||
|
||||
signInModal: function() {
|
||||
|
||||
var modal = "";
|
||||
modal += "<div class='message_overlay'>";
|
||||
modal += "<div class='message center'>";
|
||||
modal += "<h1><a class='icon-lock'></a> Sign in</h1>";
|
||||
modal += "<div class='sign_in'>";
|
||||
modal += "<input id='username' type='text' name='' value='' placeholder='username'>";
|
||||
modal += "<input id='password' type='password' name='' value='' placeholder='password'>";
|
||||
modal += "</div>";
|
||||
modal += "<div id='version'>Version " + lychee.version + "</div>";
|
||||
modal += "<a onclick='lychee.login()' class='button active'>Sign in</a>";
|
||||
modal += "</div>";
|
||||
modal += "</div>";
|
||||
|
||||
return modal;
|
||||
|
||||
},
|
||||
|
||||
uploadModal: function() {
|
||||
|
||||
var modal = "";
|
||||
modal += "<div class='upload_overlay fadeIn'>";
|
||||
modal += "<div class='upload_message center'>";
|
||||
modal += "<a class='icon-upload'></a>";
|
||||
modal += "<div class='progressbar'><div></div></div>";
|
||||
modal += "</div>";
|
||||
modal += "</div>";
|
||||
|
||||
return modal;
|
||||
|
||||
},
|
||||
|
||||
contextMenu: function(items) {
|
||||
|
||||
var menu = "";
|
||||
menu += "<div class='contextmenu_bg'></div>";
|
||||
menu += "<div class='contextmenu'>";
|
||||
menu += "<table>";
|
||||
menu += "<tbody>";
|
||||
|
||||
$.each(items, function(index) {
|
||||
|
||||
if (items[index][1].length!=0) {
|
||||
menu += "<tr><td onclick='" + items[index][1] + "; contextMenu.close();'>" + items[index][0] + "</td></tr>";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
menu += "</tbody>";
|
||||
menu += "</table>";
|
||||
menu += "</div>";
|
||||
|
||||
return menu;
|
||||
|
||||
},
|
||||
|
||||
infobox: function(photo, forView) {
|
||||
|
||||
var infobox = "";
|
||||
infobox += "<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>";
|
||||
infobox += "<div class='wrapper'>";
|
||||
|
||||
if (photo.public==1) photo.public = "Public"; else photo.public = "Private";
|
||||
if (forView==true) editTitleHTML = ""; else editTitleHTML = " <div id='edit_title'><a class='icon-pencil'></a></div>";
|
||||
if (forView==true) editDescriptionHTML = ""; else editDescriptionHTML = " <div id='edit_description'><a class='icon-pencil'></a></div>";
|
||||
|
||||
infos = [
|
||||
["", "Basics"],
|
||||
["Name", photo.title + editTitleHTML],
|
||||
["Uploaded", photo.sysdate],
|
||||
["Description", photo.description + editDescriptionHTML],
|
||||
["", "Image"],
|
||||
["Size", photo.size],
|
||||
["Format", photo.type],
|
||||
["Resolution", photo.width + " x " + photo.height],
|
||||
["", "Camera"],
|
||||
["Captured", photo.takedate],
|
||||
["Make", photo.make],
|
||||
["Type/Model", photo.model],
|
||||
["Shutter Speed", photo.shutter],
|
||||
["Aperture", photo.aperture],
|
||||
["Focal Length", photo.focal],
|
||||
["ISO", photo.iso],
|
||||
["", "Share"],
|
||||
["Privacy", photo.public],
|
||||
["Short Link", photo.shortlink]
|
||||
];
|
||||
|
||||
$.each(infos, function(index) {
|
||||
|
||||
if (infos[index][1]==""||infos[index][1]==undefined||infos[index][1]==null) infos[index][1] = "-";
|
||||
|
||||
if (infos[index][0]=="") {
|
||||
|
||||
infobox += "</table>";
|
||||
infobox += "<div class='separater'><h1>" + infos[index][1] + "</h1></div>";
|
||||
infobox += "<table id='infos'>";
|
||||
|
||||
} else {
|
||||
|
||||
infobox += "<tr>";
|
||||
infobox += "<td>" + infos[index][0] + "</td>";
|
||||
infobox += "<td class='attr_" + infos[index][0].toLowerCase() + "'>" + infos[index][1] + "</td>";
|
||||
infobox += "</tr>";
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
infobox += "</table>";
|
||||
infobox += "<div class='bumper'></div>";
|
||||
infobox += "</div>";
|
||||
|
||||
return infobox;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
/**
|
||||
* @name contextMenu.js
|
||||
* @author Philipp Maurer
|
||||
* @author Tobias Reich
|
||||
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
||||
*
|
||||
* ContextMenu Module
|
||||
* This module is used for the context menu.
|
||||
*/
|
||||
|
||||
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(photoID, mouse_x, mouse_y) {
|
||||
|
||||
mouse_y -= $(document).scrollTop();
|
||||
|
||||
lychee.api("getAlbums", "json", function(data) {
|
||||
|
||||
if (lychee.content.attr("data-id")==0) {
|
||||
items = [];
|
||||
} else {
|
||||
items = [
|
||||
["Unsorted", "photos.move(" + photoID + ", 0)"]
|
||||
];
|
||||
}
|
||||
|
||||
if (!data.albums) {
|
||||
items = [
|
||||
["Create 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 + ")");
|
||||
} else {
|
||||
items[items.length] = new Array("", "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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-150
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
share: function(photoID, mouse_x, mouse_y) {
|
||||
|
||||
mouse_y -= $(document).scrollTop();
|
||||
|
||||
items = [
|
||||
["<a class='icon-eye-close'></a> Make Private", "photos.setPublic()"],
|
||||
["<a class='icon-twitter'></a> Twitter", "photos.share(0, " + photoID + ")"],
|
||||
["<a class='icon-facebook'></a> Facebook", "photos.share(1, " + photoID + ")"],
|
||||
["<a class='icon-envelope'></a> Mail", "photos.share(2, " + photoID + ")"],
|
||||
["<a class='icon-link'></a> Copy Link", "photos.share(3, " + photoID + ")"],
|
||||
["<a class='icon-link'></a> Copy Shortlink", "photos.share(4, " + 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
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
close: function() {
|
||||
|
||||
$(".contextmenu_bg, .contextmenu").remove();
|
||||
$(".photo.active, .album.active").removeClass("active");
|
||||
$("body").css("overflow", "scroll");
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @name loadingBar.js
|
||||
* @author Philipp Maurer
|
||||
* @author Tobias Reich
|
||||
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
||||
*
|
||||
* LoadingBar Module
|
||||
* This module is used to show and hide the loading bar.
|
||||
*/
|
||||
|
||||
loadingBar = {
|
||||
|
||||
show: function(status, errorTitle, errorText) {
|
||||
|
||||
if (!status) status = "loading";
|
||||
|
||||
switch (status) {
|
||||
|
||||
case "error":
|
||||
if (!errorTitle||!errorText) {
|
||||
errorTitle = "Error";
|
||||
errorText = "Whoops, it looks like something went wrong. Please reload the site and try again!"
|
||||
}
|
||||
lychee.loadingBar
|
||||
.removeClass("loading uploading error")
|
||||
.addClass(status)
|
||||
.html("<h1>" + errorTitle + ": <span>" + errorText + "</span></h1>")
|
||||
.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;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
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(); });
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,296 @@
|
||||
/**
|
||||
* @name lychee.js
|
||||
* @author Philipp Maurer
|
||||
* @author Tobias Reich
|
||||
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
||||
*
|
||||
* Lychee Module
|
||||
* This module provides the basic functions of Lychee.
|
||||
*/
|
||||
|
||||
lychee = {
|
||||
|
||||
init: function(api_path, upload_path) {
|
||||
|
||||
this.version = "1.1";
|
||||
this.api_path = api_path;
|
||||
this.upload_path = upload_path;
|
||||
|
||||
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(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();
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
api: function(params, type, callback) {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: lychee.api_path,
|
||||
data: "function=" + params,
|
||||
dataType: type,
|
||||
success: callback,
|
||||
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(data) {
|
||||
if (data) {
|
||||
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(data) {
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
upload: function(files) {
|
||||
|
||||
pre_progress = 0;
|
||||
|
||||
$(".upload_overlay").remove();
|
||||
$("body").append(build.uploadModal());
|
||||
|
||||
var formData = new FormData();
|
||||
for (var i = 0; i < files.length; i++) formData.append(i, files[i]);
|
||||
|
||||
formData.append("function", "upload");
|
||||
|
||||
if (lychee.content.attr("data-id")=="") formData.append("albumID", 0);
|
||||
else formData.append("albumID", lychee.content.attr("data-id"));
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('POST', lychee.api_path);
|
||||
xhr.onload = function () {
|
||||
|
||||
if (xhr.status===200) {
|
||||
|
||||
$(".progressbar div").css("width", "100%");
|
||||
$(".upload_overlay").removeClass("fadeIn").css("opacity", 0);
|
||||
$.timer(300,function(){ $(".upload_overlay").remove() });
|
||||
|
||||
if (window.webkitNotifications&&BrowserDetect.browser=="Safari") {
|
||||
var popup = window.webkitNotifications.createNotification("", "Upload complete", "You can now manage your new photos.");
|
||||
popup.show();
|
||||
}
|
||||
|
||||
if (lychee.content.attr("data-id")=="") lychee.goto("a0");
|
||||
else photos.load(lychee.content.attr("data-id"));
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
xhr.upload.onprogress = function (event) {
|
||||
|
||||
if (event.lengthComputable) {
|
||||
|
||||
var progress = (event.loaded / event.total * 100 | 0);
|
||||
|
||||
if (progress>pre_progress) {
|
||||
$(".progressbar div").css("width", progress + "%");
|
||||
pre_progress = progress;
|
||||
}
|
||||
|
||||
if (progress>=100) $(".progressbar div").css("opacity", 0.2);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$("#upload_files").val("");
|
||||
|
||||
xhr.send(formData);
|
||||
|
||||
},
|
||||
|
||||
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) {
|
||||
|
||||
// Show ImageView
|
||||
if (lychee.content.html()==""||$("#search").val().length!=0) {
|
||||
lychee.content.hide();
|
||||
photos.load(albumID, true);
|
||||
}
|
||||
photos.loadInfo(photoID);
|
||||
|
||||
} else if (albumID) {
|
||||
|
||||
// Show Album
|
||||
if (visible.infobox) photos.hideInfobox();
|
||||
if (!visible.controls()) lychee.showControls();
|
||||
if (visible.imageview()) photos.hideView();
|
||||
else photos.load(albumID, false);
|
||||
|
||||
} else {
|
||||
|
||||
// Show Albums
|
||||
if (visible.infobox) photos.hideInfobox();
|
||||
if (!visible.controls()) lychee.showControls();
|
||||
if (visible.imageview()) photos.hideView();
|
||||
albums.load();
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
goto: function(url) {
|
||||
|
||||
document.location.hash = url;
|
||||
|
||||
},
|
||||
|
||||
title: function() {
|
||||
|
||||
return lychee.headerTitle.html().replace($("#title span").html(), "").replace("<span></span>", "");
|
||||
|
||||
},
|
||||
|
||||
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(obj, animation) {
|
||||
|
||||
animations = [
|
||||
["fadeIn", "fadeOut"],
|
||||
["contentZoomIn", "contentZoomOut"]
|
||||
];
|
||||
|
||||
if (!obj.jQuery) obj = $(obj);
|
||||
|
||||
for (i = 0; i < animations.length; i++) {
|
||||
for (var x = 0; x < animations[i].length; x++) {
|
||||
if (animations[i][x]==animation) {
|
||||
obj.removeClass(animations[i][0] + " " + animations[i][1]).addClass(animation);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
},
|
||||
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
|
||||
console.log(jqXHR);
|
||||
console.log(textStatus);
|
||||
console.log(errorThrown);
|
||||
loadingBar.show("error", textStatus, errorThrown);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,425 @@
|
||||
/**
|
||||
* @name photos.js
|
||||
* @author Philipp Maurer
|
||||
* @author Tobias Reich
|
||||
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
||||
*
|
||||
* Photos Module
|
||||
* Takes care of every action photos can handle and execute.
|
||||
*/
|
||||
|
||||
photos = {
|
||||
|
||||
load: function(albumID, refresh) {
|
||||
|
||||
// If refresh is true the function will only refresh the content and not change the toolbar buttons either the title
|
||||
|
||||
if (!refresh) {
|
||||
loadingBar.show();
|
||||
if (visible.imageview()) photos.hideView();
|
||||
lychee.animate(".album, .photo", "contentZoomOut");
|
||||
lychee.animate(".divider", "fadeOut");
|
||||
}
|
||||
|
||||
startTime = new Date().getTime();
|
||||
|
||||
params = "getPhotos&albumID=" + albumID;
|
||||
lychee.api(params, "json", function(data) {
|
||||
|
||||
durationTime = (new Date().getTime() - startTime);
|
||||
if (durationTime>300) waitTime = 0; else if (refresh) waitTime = 0; else waitTime = 300 - durationTime;
|
||||
|
||||
$.timer(waitTime,function(){
|
||||
|
||||
photosData = "";
|
||||
$.each(data, function() { photosData += build.photo(this); });
|
||||
lychee.content.html(photosData);
|
||||
|
||||
if (!refresh) {
|
||||
|
||||
lychee.animate(".album, .photo", "contentZoomIn");
|
||||
$("#tools_albums, #tools_photo").hide();
|
||||
$("#tools_album").show();
|
||||
$("img").retina();
|
||||
|
||||
albums.loadInfo(albumID);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
loadInfo: function(photoID) {
|
||||
|
||||
photos.showView();
|
||||
|
||||
loadingBar.show();
|
||||
|
||||
params = "getPhotoInfo&photoID=" + photoID;
|
||||
lychee.api(params, "json", function(data) {
|
||||
|
||||
if (!data.title) data.title = "Untitled";
|
||||
|
||||
document.title = "Lychee - " + data.title;
|
||||
lychee.headerTitle.html(data.title).addClass("editable");
|
||||
|
||||
$("#button_star a").removeClass("icon-star-empty icon-star");
|
||||
if (data.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 (data.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");
|
||||
}
|
||||
|
||||
data.url = lychee.upload_path + data.url;
|
||||
|
||||
if (visible.controls()&&photos.isSmall(data)) lychee.image_view.html("<a id='previous' class='icon-caret-left'></a><a id='next' 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-20) + "px; margin-left: -" + data.width/2 + "px;'></div>");
|
||||
else if (visible.controls()) lychee.image_view.html("<a id='previous' class='icon-caret-left'></a><a id='next' class='icon-caret-right'></a><div id='image' style='background-image: url(" + data.url + ")'></div>");
|
||||
else if (photos.isSmall(data)) lychee.image_view.html("<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 lychee.image_view.html("<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>");
|
||||
|
||||
lychee.animate(image_view, "fadeIn");
|
||||
lychee.image_view.show();
|
||||
|
||||
if (!visible.controls()) lychee.hideControls();
|
||||
|
||||
lychee.infobox.html(build.infobox(data)).show();
|
||||
|
||||
$.timer(300,function(){ lychee.content.show(); });
|
||||
|
||||
loadingBar.hide();
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
isSmall: function(photo) {
|
||||
|
||||
size = [
|
||||
["width", false],
|
||||
["height", false]
|
||||
];
|
||||
|
||||
if (photo.width<$(window).width()-60) size["width"] = true;
|
||||
if (photo.height<$(window).height()-100) size["height"] = true;
|
||||
|
||||
if (size["width"]&&size["height"]) return true;
|
||||
else return false;
|
||||
|
||||
},
|
||||
|
||||
showView: function() {
|
||||
|
||||
// Change toolbar-buttons
|
||||
$("#tools_albums, #tools_album").hide();
|
||||
$("#tools_photo").show();
|
||||
|
||||
// Make body not scrollable
|
||||
$("body").css("overflow", "hidden");
|
||||
|
||||
},
|
||||
|
||||
hideView: function() {
|
||||
|
||||
// Change toolbar-buttons
|
||||
$("#tools_photo, #tools_albums").hide();
|
||||
$("#tools_album").show();
|
||||
|
||||
// Make body scrollable
|
||||
$("body").css("overflow", "scroll");
|
||||
|
||||
// Change website title and url by using albums.loadInfo
|
||||
albums.loadInfo(lychee.content.attr("data-id"));
|
||||
|
||||
// Hide ImageViewer
|
||||
lychee.animate(image_view, "fadeOut");
|
||||
$.timer(300,function(){ lychee.image_view.hide() });
|
||||
|
||||
},
|
||||
|
||||
showInfobox: function() {
|
||||
|
||||
if (!visible.infobox()) $("body").append("<div id='infobox_overlay'></div>");
|
||||
lychee.infobox.css("right", "0px");
|
||||
|
||||
},
|
||||
|
||||
hideInfobox: function() {
|
||||
|
||||
$("#infobox_overlay").remove();
|
||||
lychee.infobox.css("right", "-320px");
|
||||
|
||||
},
|
||||
|
||||
hide: function(photoID) {
|
||||
|
||||
$(".photo[data-id='" + photoID + "']").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(photoID) {
|
||||
|
||||
loadingBar.show();
|
||||
|
||||
params = "deletePhoto&photoID=" + photoID;
|
||||
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");
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
deleteDialog: function(photoID) {
|
||||
|
||||
if (!photoID) photoID = lychee.image_view.attr("data-id");
|
||||
|
||||
if (visible.imageview()) photoTitle = lychee.title();
|
||||
else photoTitle = $(".photo[data-id='" + photoID + "'] .overlay h1").html();
|
||||
if (photoTitle=="") photoTitle = "Untitled";
|
||||
|
||||
f1 = "photos.delete(" + photoID + ");";
|
||||
f2 = "";
|
||||
modal = build.modal("Delete Photo", "Are you sure you want to delete the photo '" + photoTitle + "'?<br>This action can't be undone!", ["Delete Photo", "Keep Photo"], [f1, f2]);
|
||||
$("body").append(modal);
|
||||
|
||||
},
|
||||
|
||||
rename: function(photoID) {
|
||||
|
||||
if (!photoID) oldTitle = lychee.title(); else oldTitle = "";
|
||||
if (!photoID) photoID = lychee.image_view.attr("data-id");
|
||||
|
||||
newTitle = prompt("Please enter a new title for this photo:", oldTitle);
|
||||
|
||||
if (photoID!=null&&photoID&&newTitle.length<31) {
|
||||
|
||||
loadingBar.show();
|
||||
|
||||
if (newTitle=="") newTitle = "Untitled";
|
||||
|
||||
params = "setPhotoTitle&photoID=" + photoID + "&title=" + encodeURI(newTitle);
|
||||
lychee.api(params, "text", function(data) {
|
||||
|
||||
if (data) {
|
||||
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='" + photoID + "'] .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(photoID, albumID) {
|
||||
|
||||
if (albumID>=0) {
|
||||
|
||||
loadingBar.show();
|
||||
|
||||
params = "movePhoto&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");
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
setStar: function() {
|
||||
|
||||
loadingBar.show();
|
||||
|
||||
photoID = lychee.image_view.attr("data-id");
|
||||
|
||||
params = "setPhotoStar&photoID=" + photoID;
|
||||
lychee.api(params, "text", function(data) {
|
||||
|
||||
if (data) {
|
||||
|
||||
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(data) {
|
||||
|
||||
if (data) {
|
||||
|
||||
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(data) {
|
||||
|
||||
if (data) 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(service, photoID) {
|
||||
|
||||
loadingBar.show();
|
||||
|
||||
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: <input class='copylink' value='" + photos.getViewLink(photoID) + "'>", ["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: <input class='copylink' value='" + data.shortlink + "'>", ["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(photoID) {
|
||||
|
||||
if (location.href.indexOf("index.html")>0) return location.href.replace("index.html" + location.hash, "view.php?p=" + photoID);
|
||||
else return location.href.replace(location.hash, "view.php?p=" + photoID);
|
||||
|
||||
},
|
||||
|
||||
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(data) {
|
||||
|
||||
if (data!=false) lychee.goto("a" + albumID + "p" + data.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(data) {
|
||||
|
||||
if (data) lychee.goto("a" + albumID + "p" + data.id);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @name photos.js
|
||||
* @author Philipp Maurer
|
||||
* @author Tobias Reich
|
||||
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
||||
*
|
||||
* Search Module
|
||||
* Searches through your photos and albums.
|
||||
*/
|
||||
|
||||
search = {
|
||||
|
||||
find: function(term) {
|
||||
|
||||
clearTimeout($(window).data("timeout"));
|
||||
$(window).data("timeout", setTimeout(function() {
|
||||
|
||||
if ($("#search").val().length!=0) {
|
||||
|
||||
params = "search&term=" + term;
|
||||
lychee.api(params, "json", function(data) {
|
||||
|
||||
albumsData = "";
|
||||
if (data&&data.albums) $.each(data.albums, function() { albumsData += build.album(this); });
|
||||
|
||||
photosData = "";
|
||||
if (data&&data.photos) $.each(data.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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @name visible.js
|
||||
* @author Philipp Maurer
|
||||
* @author Tobias Reich
|
||||
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
||||
*
|
||||
* Visible Module
|
||||
* This module is used to check if elements are visible or not.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/**
|
||||
* @name upload.js
|
||||
* @author Philipp Maurer
|
||||
* @author Tobias Reich
|
||||
* @copyright 2012 by Philipp Maurer, Tobias Reich
|
||||
*/
|
||||
|
||||
var global_progress = new Array(),
|
||||
last_final_progress = 0;
|
||||
|
||||
function handleFiles(files) {
|
||||
|
||||
var i = 0;
|
||||
var auswahl_div = document.getElementById('auswahl');
|
||||
var imageType = /image.*/;
|
||||
var fileList = files;
|
||||
|
||||
for(i = 0; i < fileList.length; i++) {
|
||||
var img = document.createElement("img");
|
||||
img.height = 0;
|
||||
img.file = fileList[i];
|
||||
img.name = 'pic_'+ i;
|
||||
img.classList.add("obj");
|
||||
auswahl_div.appendChild(img);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function sendFiles(){
|
||||
|
||||
imgs = document.querySelectorAll(".obj");
|
||||
|
||||
$(".upload_overlay").remove();
|
||||
$("body").append(buildUploadModal());
|
||||
|
||||
global_progress = new Array();
|
||||
last_final_progress = 0;
|
||||
|
||||
for(i = 0; i < imgs.length; i++) {
|
||||
global_progress[i] = 0;
|
||||
new FileUpload(i, imgs[i], imgs[i].file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function changeProgress(i, progress) {
|
||||
|
||||
global_progress[i] = progress;
|
||||
final_progress = 0;
|
||||
|
||||
for(i = 0; i < global_progress.length; 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)) {
|
||||
$(".progressbar div").css("width", Math.round(final_progress/document.querySelectorAll(".obj").length) + "%");
|
||||
}
|
||||
|
||||
last_final_progress = final_progress;
|
||||
|
||||
if ((final_progress/document.querySelectorAll(".obj").length)>=100) {
|
||||
|
||||
$(".progressbar div").css("width", "100%");
|
||||
|
||||
$.timer(1000,function(){
|
||||
|
||||
$(".upload_overlay").removeClass("fadeIn").css("opacity", 0);
|
||||
$.timer(300,function(){ $(".upload_overlay").remove() });
|
||||
|
||||
if (content.attr("data-id")=="") setURL("a0");
|
||||
else loadPhotos(content.attr("data-id"));
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function FileUpload(i, img, file) {
|
||||
|
||||
var old_percent = 0,
|
||||
xhr = new XMLHttpRequest(),
|
||||
fd = new FormData,
|
||||
percent = 0;
|
||||
|
||||
this.xhr = xhr;
|
||||
|
||||
this.xhr.upload.addEventListener("progress", function(e) {
|
||||
if (e.lengthComputable) percent = Math.round((e.loaded * 100) / e.total);
|
||||
changeProgress(i, percent);
|
||||
}, false);
|
||||
|
||||
fd.append("File", file);
|
||||
fd.append("function", "upload");
|
||||
if (content.attr("data-id")=="") fd.append("albumID", 0);
|
||||
else fd.append("albumID", content.attr("data-id"));
|
||||
|
||||
xhr.open("POST", "php/api.php", true);
|
||||
xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
|
||||
xhr.send(fd);
|
||||
|
||||
}
|
@ -1,43 +1,43 @@
|
||||
<?php
|
||||
function array2json($arr) {
|
||||
<?php
|
||||
function array2json($arr) {
|
||||
if(function_exists('json_encode')) return json_encode($arr); //Lastest versions of PHP already has this functionality.
|
||||
$parts = array();
|
||||
$is_list = false;
|
||||
$parts = array();
|
||||
$is_list = false;
|
||||
|
||||
//Find out if the given array is a numerical array
|
||||
$keys = array_keys($arr);
|
||||
$max_length = count($arr)-1;
|
||||
//Find out if the given array is a numerical array
|
||||
$keys = array_keys($arr);
|
||||
$max_length = count($arr)-1;
|
||||
if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {//See if the first key is 0 and last key is length - 1
|
||||
$is_list = true;
|
||||
for($i=0; $i<count($keys); $i++) { //See if each key correspondes to its position
|
||||
if($i != $keys[$i]) { //A key fails at position check.
|
||||
$is_list = false; //It is an associative array.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$is_list = true;
|
||||
for($i=0; $i<count($keys); $i++) { //See if each key correspondes to its position
|
||||
if($i != $keys[$i]) { //A key fails at position check.
|
||||
$is_list = false; //It is an associative array.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($arr as $key=>$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 . '":';
|
||||
foreach($arr as $key=>$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?)
|
||||
//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
|
||||
$parts[] = $str;
|
||||
}
|
||||
}
|
||||
$json = implode(',',$parts);
|
||||
|
||||
if($is_list) return '[' . $json . ']';//Return numerical JSON
|
||||
return '{' . $json . '}';//Return associative JSON
|
||||
}
|
||||
?>
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
define("LYCHEE", true);
|
||||
|
||||
// Declare
|
||||
$error = "";
|
||||
|
||||
// Include
|
||||
include("config.php");
|
||||
|
||||
// PHP Version
|
||||
if (floatval(phpversion())<5.2) $error .= ("Error 100: Please upgrade to PHP 5.2 or higher!<br>\n");
|
||||
|
||||
// Extensions
|
||||
if (!extension_loaded("exif")) $error .= ("Error 200: PHP exif extension not activated.<br>\n");
|
||||
if (!extension_loaded("mbstring")) $error .= ("Error 201: PHP mbstring extension not activated.<br>\n");
|
||||
if (!extension_loaded("gd")) $error .= ("Error 202: PHP gd extension not activated.<br>\n");
|
||||
if (!extension_loaded("mysqli")) $error .= ("Error 203: PHP mysqli extension not activated.<br>\n");
|
||||
|
||||
// Config
|
||||
if (!$db||$db=="") $error .= ("Error 300: No property for \$db in config.php.<br>\n");
|
||||
if (!$dbUser||$dbUser=="") $error .= ("Error 301: No property for \$dbUser in config.php.<br>\n");
|
||||
if (!$dbPassword||$dbPassword=="") $error .= ("Error 302: No property for \$dbPassword in config.php.<br>\n");
|
||||
if (!$dbHost||$dbHost=="") $error .= ("Error 303: No property for \$dbHost in config.php.<br>\n");
|
||||
if (!$user||$user=="") $error .= ("Error 304: No property for \$user in config.php.<br>\n");
|
||||
if (!$password||$password=="") $error .= ("Error 305: No property for \$password in config.php.<br>\n");
|
||||
|
||||
// Database
|
||||
$database = new mysqli($dbHost, $dbUser, $dbPassword, $db);
|
||||
if (mysqli_connect_errno()!=0) $error .= ("Error 400: " . mysqli_connect_errno() . ": " . mysqli_connect_error() . "<br>\n");
|
||||
|
||||
// Permissions
|
||||
if (substr(sprintf('%o', fileperms("../uploads/big/")), -4) != "0777") $error .= ("Error 500: Wrong permissions for \"/uploads/big\" (777 required).<br>\n");
|
||||
if (substr(sprintf('%o', fileperms("../uploads/thumb/")), -4) != "0777") $error .= ("Error 501: Wrong permissions for \"/uploads/thumb\" (777 required).<br>\n");
|
||||
if (substr(sprintf('%o', fileperms("../uploads/import/")), -4) != "0777") $error .= ("Error 502: Wrong permissions for \"/uploads/import\" (777 required).<br>\n");
|
||||
|
||||
if ($error == "") echo("Lychee is ready!"); else echo $error;
|
||||
|
||||
?>
|