build.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /**
  2. * @name build.js
  3. * @author Philipp Maurer
  4. * @author Tobias Reich
  5. * @copyright 2013 by Philipp Maurer, Tobias Reich
  6. *
  7. * Build Module
  8. * This module is used to generate HTML-Code.
  9. */
  10. build = {
  11. divider: function(title) {
  12. return "<div class='divider fadeIn'><h1>" + title + "</h1></div>";
  13. },
  14. album: function(albumJSON) {
  15. var album = "";
  16. if(!albumJSON) return "";
  17. if (albumJSON.password&&lychee.publicMode) {
  18. albumJSON.thumb0 = "img/password.png";
  19. albumJSON.thumb1 = "img/password.png";
  20. albumJSON.thumb2 = "img/password.png";
  21. } else {
  22. if(!albumJSON.thumb0) albumJSON.thumb0 = "img/no_images.png";
  23. if(!albumJSON.thumb1) albumJSON.thumb1 = "img/no_images.png";
  24. if(!albumJSON.thumb2) albumJSON.thumb2 = "img/no_images.png";
  25. }
  26. if(!albumJSON.title) albumJSON.title = "Untitled";
  27. if(albumJSON.title.length>18) albumJSON.title = albumJSON.title.substr(0, 18) + "...";
  28. album += "<div class='album' data-id='" + albumJSON.id + "' data-password='" + albumJSON.password + "'>";
  29. album += "<img src='" + lychee.upload_path + albumJSON.thumb2 + "' width='200' height='200' alt='thumb'>";
  30. album += "<img src='" + lychee.upload_path + albumJSON.thumb1 + "' width='200' height='200' alt='thumb'>";
  31. album += "<img src='" + lychee.upload_path + albumJSON.thumb0 + "' width='200' height='200' alt='thumb'>";
  32. album += "<div class='overlay'>";
  33. if (albumJSON.password&&!lychee.publicMode) album += "<h1><span class='icon-lock' title='Public album with password'></span> " + albumJSON.title + "</h1>";
  34. else album += "<h1>" + albumJSON.title + "</h1>";
  35. album += "<a>" + albumJSON.sysdate + "</a>";
  36. album += "</div>";
  37. if(!lychee.publicMode&&albumJSON.star=="1") album += "<a class='badge red icon-star'></a>";
  38. if(!lychee.publicMode&&albumJSON.public=="1") album += "<a class='badge red icon-share'></a>";
  39. if(!lychee.publicMode&&albumJSON.unsorted=="1") album += "<a class='badge red icon-reorder'></a>";
  40. album += "</div>";
  41. return album;
  42. },
  43. photo: function(photoJSON) {
  44. var photo = "";
  45. if(photoJSON=="") return "";
  46. if(!photoJSON.title) photoJSON.title = "";
  47. if(!photoJSON.thumbUrl) photoJSON.thumbUrl = "img/no_image.png";
  48. if(photoJSON.title.length>18) photoJSON.title = photoJSON.title.substr(0, 18) + "...";
  49. photo += "<div class='photo' data-album-id='" + photoJSON.album + "' data-id='" + photoJSON.id + "'>";
  50. photo += "<img src='" + lychee.upload_path + photoJSON.thumbUrl + "' width='200' height='200' alt='thumb'>";
  51. photo += "<div class='overlay'>";
  52. photo += "<h1>" + photoJSON.title + "</h1>";
  53. photo += "<a>" + photoJSON.sysdate + "</a>";
  54. photo += "</div>";
  55. if(photoJSON.star=="1") photo += "<a class='badge red icon-star'></a>";
  56. if(!lychee.publicMode&&photoJSON.public=="1") photo += "<a class='badge red icon-share'></a>";
  57. photo += "</div>";
  58. return photo;
  59. },
  60. no_content: function(typ) {
  61. var no_content = "";
  62. no_content += "<div class='no_content fadeIn'>";
  63. no_content += "<a class='icon icon-" + typ + "'></a>";
  64. if (typ=="search") no_content += "<p>No results</p>";
  65. else if (typ=="picture") no_content += "<p>No public albums</p>";
  66. no_content += "</div>";
  67. return no_content;
  68. },
  69. modal: function(title, text, button, func) {
  70. var modal = "";
  71. modal += "<div class='message_overlay fadeIn'>";
  72. modal += "<div class='message center'>";
  73. modal += "<h1>" + title + "</h1>";
  74. modal += "<a class='close icon-remove-sign'></a>";
  75. modal += "<p>" + text + "</p>";
  76. $.each(button, function(index) {
  77. if (index==0) modal += "<a onclick='message_click(" + index + ")' class='button active'>" + this + "</a>";
  78. else modal += "<a onclick='message_click(" + index + ")' class='button'>" + this + "</a>";
  79. });
  80. modal += "</div>";
  81. modal += "<script>";
  82. modal += "function message_click(action) {";
  83. modal += "switch (action) {";
  84. $.each(func, function(index) {
  85. modal += "case " + index + ":";
  86. modal += this.toString();
  87. modal += "break;";
  88. });
  89. modal += "} lychee.closeModal(); }";
  90. modal += "</script>";
  91. modal += "</div>";
  92. return modal;
  93. },
  94. addModal: function() {
  95. var modal = "";
  96. modal += "<div class='message_overlay fadeIn'>";
  97. modal += "<div class='message center add'>";
  98. modal += "<h1>Add Album or Photo</h1>";
  99. modal += "<a class='close icon-remove-sign'></a>";
  100. modal += "<div id='add_album' class='add_album'>";
  101. modal += "<div class='icon icon-folder-close'></div>";
  102. modal += "<a>New Album</a>";
  103. modal += "</div>";
  104. modal += "<div id='add_link' class='add_album'>";
  105. modal += "<div class='icon icon-link'></div>";
  106. modal += "<a>Import Link</a>";
  107. modal += "</div>";
  108. modal += "<div id='add_photo' class='add_album'>";
  109. modal += "<div class='icon icon-picture'></div>";
  110. modal += "<a>Upload Photo</a>";
  111. modal += "</div>";
  112. modal += "</div>";
  113. modal += "</div>";
  114. return modal;
  115. },
  116. signInModal: function() {
  117. var modal = "";
  118. modal += "<div class='message_overlay'>";
  119. modal += "<div class='message center'>";
  120. modal += "<h1><a class='icon-lock'></a> Sign In</h1>";
  121. modal += "<div class='sign_in'>";
  122. modal += "<input id='username' type='text' name='' value='' placeholder='username'>";
  123. modal += "<input id='password' type='password' name='' value='' placeholder='password'>";
  124. modal += "</div>";
  125. modal += "<div id='version'>Version " + lychee.version + "<span> &#8211; <a target='_blank' href='" + lychee.updateURL + "'>Update available!</a><span></div>";
  126. modal += "<a onclick='lychee.login()' class='button active'>Sign in</a>";
  127. modal += "</div>";
  128. modal += "</div>";
  129. return modal;
  130. },
  131. uploadModal: function() {
  132. var modal = "";
  133. modal += "<div class='upload_overlay fadeIn'>";
  134. modal += "<div class='upload_message center'>";
  135. modal += "<a class='icon-upload'></a>";
  136. modal += "<div class='progressbar'><div></div></div>";
  137. modal += "</div>";
  138. modal += "</div>";
  139. return modal;
  140. },
  141. contextMenu: function(items) {
  142. var menu = "";
  143. menu += "<div class='contextmenu_bg'></div>";
  144. menu += "<div class='contextmenu'>";
  145. menu += "<table>";
  146. menu += "<tbody>";
  147. $.each(items, function(index) {
  148. if (items[index][0]=="separator"&&items[index][1].length==0) menu += "<tr class='separator'></tr>";
  149. else if (items[index][1].length!=0) menu += "<tr><td onclick='" + items[index][1] + "; contextMenu.close();'>" + items[index][0] + "</td></tr>";
  150. });
  151. menu += "</tbody>";
  152. menu += "</table>";
  153. menu += "</div>";
  154. return menu;
  155. },
  156. infobox: function(photo, forView) {
  157. var infobox = "";
  158. infobox += "<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>";
  159. infobox += "<div class='wrapper'>";
  160. if (photo.public==1) photo.public = "Public"; else photo.public = "Private";
  161. if (forView==true||lychee.publicMode) editTitleHTML = ""; else editTitleHTML = " <div id='edit_title'><a class='icon-pencil'></a></div>";
  162. if (forView==true||lychee.publicMode) editDescriptionHTML = ""; else editDescriptionHTML = " <div id='edit_description'><a class='icon-pencil'></a></div>";
  163. infos = [
  164. ["", "Basics"],
  165. ["Name", photo.title + editTitleHTML],
  166. ["Uploaded", photo.sysdate],
  167. ["Description", photo.description + editDescriptionHTML],
  168. ["", "Image"],
  169. ["Size", photo.size],
  170. ["Format", photo.type],
  171. ["Resolution", photo.width + " x " + photo.height],
  172. ["", "Camera"],
  173. ["Captured", photo.takedate],
  174. ["Make", photo.make],
  175. ["Type/Model", photo.model],
  176. ["Shutter Speed", photo.shutter],
  177. ["Aperture", photo.aperture],
  178. ["Focal Length", photo.focal],
  179. ["ISO", photo.iso],
  180. ["", "Share"],
  181. ["Visibility", photo.public],
  182. ["Short Link", photo.shortlink]
  183. ];
  184. $.each(infos, function(index) {
  185. if (infos[index][1]==""||infos[index][1]==undefined||infos[index][1]==null) infos[index][1] = "-";
  186. if (infos[index][0]=="") {
  187. infobox += "</table>";
  188. infobox += "<div class='separater'><h1>" + infos[index][1] + "</h1></div>";
  189. infobox += "<table id='infos'>";
  190. } else {
  191. infobox += "<tr>";
  192. infobox += "<td>" + infos[index][0] + "</td>";
  193. infobox += "<td class='attr_" + infos[index][0].toLowerCase() + "'>" + infos[index][1] + "</td>";
  194. infobox += "</tr>";
  195. }
  196. });
  197. infobox += "</table>";
  198. infobox += "<div class='bumper'></div>";
  199. infobox += "</div>";
  200. return infobox;
  201. }
  202. }