var icons = { 'title': {img: 'text.png', alt: 'Titel / Beschreibung'},
'where': {img: 'map.png', alt: 'Ort'},
'what': {img: 'thing.png', alt: 'Sache'},
'photography': {img: 'camera.png', alt: 'Fotografie'},
'gallery': {img: 'gallery.png', alt: 'Galerie'},
'who' : {img: 'person.png', alt: 'Person'},
'year' : {img: 'calendar.png', alt: 'Jahr'},
'default' : {img: 'calendar.png', alt: 'default'},
'description' : {img: 'description.png', alt: 'Beschreibung'} };
var jdata = JSON.parse(data);
var metadata = JSON.parse(metadata);
$(document).ready(function(){
// $('#txt-search').keyup(function(){
$('#txt-search').on('keyup input', function(){
$('#myTab a[href="#filters"]').tab('show')
var searchField = $(this).val();
if(searchField === '') {
$('#filter-records').html('');
return;
}
var regex = new RegExp(searchField, "i");
var output = '
';
var count = 1;
$.each(jdata, function(key, val) {
if (val.name.search(regex) != -1) {
// console.log('Type: ' + val.type);
output += '
';
output += '
';
output += '
';
output += '
' + val.name + '
';
output += '';
output += '
';
if(count%4 == 0){
output += '
'
}
count++;
}
});
output += '
';
$('#filters').html(output);
});
});
function thumb_with_path( img ) {
path = img.replace(/\/.*$/gi, '');
thumb = img.replace(/.*\//gi, '');
return(path + '/_thumbnails/' + thumb);
}
function build_lightgallery(id) {
console.log('build_lightgallery ' + id);
record = jdata[id];
if (record.type == 'gallery') {
console.log(window.location + record.dir + '/');
window.open(window.location + record.dir + '/');
} else {
images = record.images;
var dynimages = [];
var output = ''
// i = 0;
for (let img of images) {
// console.log(img);
// dynimages[i] = {'src': img, 'thumb': thumb_with_path(img), 'subHtml':'dummy'};
output += '';
//i = i + 1;
}
$('#results').html(output);
$('#myTab a[href="#results"]').tab('show')
lightGallery(document.getElementById('results'), {
plugins: [lgZoom, lgThumbnail, lgAutoplay, lgFullscreen
], /* , lgMediumZoom, lgRelativeCaption, lgShare, lgPager, lgHash */
speed: 500,
// licenseKey: '0000-0000-000-0000',
mode: 'fade'
});
}
}