/** * @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 "

" + title + "

"; }, album: function(albumJSON) { if (!albumJSON) return ""; var album = "" title = albumJSON.title; if (title.length>18) title = albumJSON.title.substr(0, 18) + "..."; album += "
"; album += "thumb"; album += "thumb"; album += "thumb"; album += "
"; if (albumJSON.password&&!lychee.publicMode) album += "

" + title + "

"; else album += "

" + title + "

"; album += "" + albumJSON.sysdate + ""; album += "
"; if(!lychee.publicMode&&albumJSON.star==1) album += ""; if(!lychee.publicMode&&albumJSON.public==1) album += ""; if(!lychee.publicMode&&albumJSON.unsorted==1) album += ""; album += "
"; return album; }, photo: function(photoJSON) { if (!photoJSON) return ""; var photo = "", title = photoJSON.title; if (title.length>18) title = photoJSON.title.substr(0, 18) + "..."; photo += "
"; photo += "thumb"; photo += "
"; photo += "

" + title + "

"; photo += "" + photoJSON.sysdate + ""; photo += "
"; if (photoJSON.star==1) photo += ""; if (!lychee.publicMode&&photoJSON.public==1&&album.json.public!=1) photo += ""; photo += "
"; return photo; }, no_content: function(typ) { var no_content = ""; no_content += "
"; no_content += ""; if (typ=="search") no_content += "

No results

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

No public albums

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

" + title + "

"; modal += ""; modal += "

" + text + "

"; $.each(button, function(index) { if (this[0]!="") { if (index==0) modal += "" + this[0] + ""; else modal += "" + this[0] + ""; } }); modal += "
"; modal += "
"; return modal; }, addModal: function() { var modal = ""; modal += "
"; modal += "
"; modal += "

Add Album or Photo

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

Sign In

"; modal += ""; modal += "
Version " + lychee.version + "Update available!
"; modal += "Sign in"; modal += "
"; modal += "
"; return modal; }, uploadModal: function() { var modal = ""; modal += "
"; modal += "
"; modal += ""; modal += "
"; modal += "
"; modal += "
"; return modal; }, contextMenu: function(items) { var menu = ""; menu += "
"; menu += "
"; menu += ""; menu += ""; $.each(items, function(index) { if (items[index][0]=="separator"&&items[index][1]==-1) menu += ""; else if (items[index][1]==-1) menu += ""; else if (items[index][2]!=undefined) menu += ""; else menu += ""; }); menu += ""; menu += "
" + items[index][0] + "
" + items[index][0] + "
" + items[index][0] + "
"; menu += "
"; return menu; }, infobox: function(photoJSON, forView) { if (!photoJSON) return ""; var infobox = "", public, editTitleHTML, editDescriptionHTML, infos; infobox += "

About

"; infobox += "
"; switch (photoJSON.public) { case "0": public = "Private"; break; case "1": public = "Public"; break; case "2": public = "Public (Album)"; break; default: public = "-"; break; } editTitleHTML = (forView==true||lychee.publicMode) ? "" : "
"; editDescriptionHTML = (forView==true||lychee.publicMode) ? "" : "
"; infos = [ ["", "Basics"], ["Name", photoJSON.title + editTitleHTML], ["Uploaded", photoJSON.sysdate], ["Description", photoJSON.description + editDescriptionHTML], ["", "Image"], ["Size", photoJSON.size], ["Format", photoJSON.type], ["Resolution", photoJSON.width + " x " + photoJSON.height], ["", "Camera"], ["Captured", photoJSON.takedate], ["Make", photoJSON.make], ["Type/Model", photoJSON.model], ["Shutter Speed", photoJSON.shutter], ["Aperture", photoJSON.aperture], ["Focal Length", photoJSON.focal], ["ISO", photoJSON.iso], ["", "Share"], ["Visibility", public] ]; $.each(infos, function(index) { if (infos[index][1]==""||infos[index][1]==undefined||infos[index][1]==null) infos[index][1] = "-"; if (infos[index][0]=="") { infobox += ""; infobox += "

" + infos[index][1] + "

"; infobox += ""; } else { infobox += ""; infobox += ""; infobox += ""; infobox += ""; } }); infobox += "
" + infos[index][0] + "" + infos[index][1] + "
"; infobox += "
"; infobox += "
"; return infobox; } }