var imglist = null; var dirname = null; var filename = null; var currId = 0; function setLinks(e) { var doPush = false; /* browser navigation handling */ if (e === undefined || e.type != 'popstate') { doPush = true; } else { currId = e.state; } /* replace the content */ filename = imglist[currId].name; if (currId > 0) { $('#poprz').attr('href', scriptUrlPrefix + 'image.php?dir=' + dirname + '&file=' + imglist[currId-1].name); $('#poprz').show(); } else { $('#poprz').hide(); } if (currId < imglist.length - 1) { var url = scriptUrlPrefix + 'image.php?dir=' + dirname + '&file=' + imglist[currId+1].name; $('#nast').attr('href', url); $('#imagelink').attr('href', url); $('#nast').show(); } else { $('#nast').hide(); $('#imagelink').removeAttr('href'); } var image = $("#image"); image.css('opacity', '0.2'); image.attr('src', imageUrlPrefix + dirname + '/' + filename); image.on('load', function() { image.css('opacity', '1'); }); if (doPush) window.history.pushState(currId, '', scriptUrlPrefix + 'image.php?dir=' + dirname + '&file=' + filename); commentsImageReplace(imglist[currId]); refreshComments(); } function nextImage(e) { if (e) e.preventDefault(); if (currId >= imglist.length - 1) return; currId++; setLinks(); } function prevImage(e) { if (e) e.preventDefault(); if (currId == 0) return; currId--; setLinks(); } function imglistReceived(data) { imglist = data; /* find current id by url */ var found = false; for (var i=0; i