/** * @description This module is used to generate HTML-Code. * @copyright 2015 by Tobias Reich */ window.build = {} build.iconic = function(icon, classes, file) { var html = '', path = 'src/images/'; file = file || 'iconic'; classes = classes || ''; html = ` ` return html; } build.divider = function(title) { var html = ''; html = `

${ title }

` return html; } build.editIcon = function(id) { var html = ''; html = `
${ build.iconic('pencil') }
` return html; } build.multiselect = function(top, left) { var html = ''; html = `
` return html; } build.album = function(data) { if (data===null||data===undefined) return ''; var html = '', title = data.title, longTitle = '', typeThumb = ''; if (title!==null&&title.length>18) { title = data.title.substr(0, 18) + '...'; longTitle = data.title; } if (data.thumbs[0].split('.').pop()==='svg') typeThumb = 'nonretina'; html = `
thumb thumb thumb

${ title }

${ data.sysdate }
` if (lychee.publicMode===false) { if (data.star==='1') html += `${ build.iconic('star') }`; if (data.public==='1') html += `${ build.iconic('eye') }`; if (data.unsorted==='1') html += `${ build.iconic('list') }`; if (data.recent==='1') html += `${ build.iconic('clock') }`; if (data.password==='1') html += `${ build.iconic('lock-locked') }`; } html += '
' return html; } build.photo = function(data) { if (data===null||data===undefined) return ''; var html = '', title = data.title, longTitle = ''; if (title!==null&&title.length>18) { title = data.title.substr(0, 18) + '...'; longTitle = data.title; } html = `
thumb

${ title }

` if (data.cameraDate==='1') html += `${ build.iconic('camera-slr') }${ data.sysdate }`; else html += `${ data.sysdate }`; html += '
'; if (lychee.publicMode===false) { if (data.star==='1') html += `${ build.iconic('star') }`; if (data.public==='1'&&album.json.public!=='1') html += `${ build.iconic('eye') }`; } html += '
'; return html } build.imageview = function(data, size, visibleControls) { if (data===null||data===undefined) return ''; var html = ''; html = `
` if (size==='big') { if (visibleControls===true) html += `
`; else html += `
`; } else if (size==='medium') { if (visibleControls===true) html += `
`; else html += `
`; } else if (size==='small') { if (visibleControls===true) html += `
`; else html += `
`; } return html; } build.no_content = function(typ) { var html; html = `
${ build.iconic(typ) } ` switch (typ) { case 'magnifying-glass': html += '

No results

'; break; case 'eye': html += '

No public albums

'; break; case 'cog': html += '

No configuration

'; break; } html += '
'; return html; } build.uploadModal = function(title, files) { var html = '', i = 0, file = null; html = `

${ title }

` while (i40) file.name = file.name.substr(0, 17) + '...' + file.name.substr(file.name.length-20, 20); html += `
${ lychee.escapeHTML(file.name) } ` if (file.supported===true) html += ``; else html += `Not supported`; html += `

` i++; } html += '
'; return html; } build.tags = function(tags, forView = false) { var html = '', editTagsHTML = ''; if (forView===false&&lychee.publicMode===false) editTagsHTML = ' ' + build.editIcon('edit_tags'); if (tags!=='') { tags = tags.split(','); tags.forEach(function(tag, index, array) { html += `${ tag }${ build.iconic('x') }` }); html += editTagsHTML; } else { html = `
No Tags${ editTagsHTML }
`; } return html; } build.sidebarPhoto = function(data, forView = false) { var html = '', visible = '', editTitleHTML = '', editDescriptionHTML = '', exifHash = '', info = []; switch (data.public) { case '0': visible = 'No'; break; case '1': visible = 'Yes'; break; case '2': visible = 'Yes (Album)'; break; default: visible = '-'; break; } if (forView===false&&lychee.publicMode===false) { editTitleHTML = ' ' + build.editIcon('edit_title'); editDescriptionHTML = ' ' + build.editIcon('edit_description'); } infos = [ ['', 'Basics'], ['Title', data.title + editTitleHTML], ['Uploaded', data.sysdate], ['Description', data.description + editDescriptionHTML], ['', 'Image'], ['Size', data.size], ['Format', data.type], ['Resolution', data.width + ' x ' + data.height], ['Tags', build.tags(data.tags, forView)] ] exifHash = data.takestamp+data.make+data.model+data.shutter+data.aperture+data.focal+data.iso; if (exifHash!=='0') { infos = infos.concat([ ['', 'Camera'], ['Captured', data.takedate], ['Make', data.make], ['Type/Model', data.model], ['Shutter Speed', data.shutter], ['Aperture', data.aperture], ['Focal Length', data.focal], ['ISO', data.iso] ]); } infos = infos.concat([ ['', 'Share'], ['Public', visible] ]); infos.forEach(function(info, i, items) { // Set default for empty values if (info[1]===''||info[1]===null||info[1]===undefined) info[1] = '-'; switch (info[0]) { case '': // Divider html += `

${ info[1] }

` break; case 'Tags': // Tags if (forView===false&&lychee.publicMode===false) { html += `

${ info[0] }

${ info[1] }
` } break; default: // Item html += ` ${ info[0] } ${ info[1] } ` break; } }); html += ` ` return html; } build.sidebarAlbum = function(data, forView = false) { var html = '', visible = '', password = '', downloadable = '', editTitleHTML = '', editDescriptionHTML = '', infos = []; switch (data.public) { case '0': visible = 'No'; break; case '1': visible = 'Yes'; break; default: visible = '-'; break; } switch (data.password) { case '0': password = 'No'; break; case '1': password = 'Yes'; break; default: password = '-'; break; } switch (data.downloadable) { case '0': downloadable = 'No'; break; case '1': downloadable = 'Yes'; break; default: downloadable = '-'; break; } if (forView===false&&lychee.publicMode===false) { editTitleHTML = ' ' + build.editIcon('edit_title'); editDescriptionHTML = ' ' + build.editIcon('edit_description'); } infos = [ ['', 'Basics'], ['Title', data.title + editTitleHTML], ['Description', data.description + editDescriptionHTML], ['', 'Album'], ['Created', data.sysdate], ['Images', data.num], ['', 'Share'], ['Public', visible], ['Downloadable', downloadable], ['Password', password] ] infos.forEach(function(info, i, items) { // Set default for empty values if (info[1]===''||info[1]===null||info[1]===undefined) info[1] = '-'; if (info[0]==='') { // Divider html += `

${ info[1] }

` } else { // Item html += ` ` } }); html += `
${ info[0] } ${ info[1] }
` return html; }