2022-12-01 18:48:31 +00:00
|
|
|
{% extends 'layout.html' %}
|
2023-01-10 12:39:29 +00:00
|
|
|
|
|
|
|
{% block header %}
|
2023-01-14 01:46:11 +00:00
|
|
|
<img src="{{ url_for('static', filename='images/background.svg') }}" onload="imgFade(this)" style="opacity:0;"/>
|
2023-01-10 12:39:29 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
2022-12-01 18:48:31 +00:00
|
|
|
{% block content %}
|
|
|
|
<div class="app">
|
2023-01-14 01:46:11 +00:00
|
|
|
<!--<h1>Gallery</h1>-->
|
2023-01-10 18:12:55 +00:00
|
|
|
<div id="gallery" class="gallery">
|
|
|
|
{% for image in images %}
|
|
|
|
<a class="gallery__item" href="/image/{{ image['id'] }}">
|
|
|
|
<div class="gallery__item-info">
|
|
|
|
<p>{{ image['id'] }}</p>
|
|
|
|
<h2>{{ image['file_name'] }}</h2>
|
|
|
|
</div>
|
|
|
|
<span class="gallery__item-filter"></span>
|
2023-01-14 01:46:11 +00:00
|
|
|
<img
|
|
|
|
class="gallery__item-image"
|
|
|
|
src="/api/uploads/{{ image['file_name'] }}/400"
|
|
|
|
onload="imgFade(this)"
|
|
|
|
style="opacity:0;"
|
|
|
|
loading="lazy"
|
|
|
|
/>
|
2023-01-10 18:12:55 +00:00
|
|
|
</a>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
2022-12-01 18:48:31 +00:00
|
|
|
</div>
|
|
|
|
<script>
|
2022-12-14 19:55:40 +00:00
|
|
|
let imageList = [];
|
|
|
|
let imageIndex = 0;
|
2022-12-19 15:07:41 +00:00
|
|
|
|
2022-12-19 21:15:56 +00:00
|
|
|
function loadMore(startIndex, amount = 20) {
|
2022-12-14 19:55:40 +00:00
|
|
|
for (let i = startIndex; i < startIndex + amount; i++) {
|
|
|
|
if (i < imageList.length) {
|
2022-12-19 21:15:56 +00:00
|
|
|
loadImg(imageList[i][0], imageList[i][1]);
|
2022-12-14 19:55:40 +00:00
|
|
|
}
|
|
|
|
}
|
2023-01-06 15:47:58 +00:00
|
|
|
imageIndex = startIndex + amount;
|
2022-12-14 19:55:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadImg(id, fileName) {
|
|
|
|
var imgDiv = `
|
|
|
|
<a class="gallery__item" href="/image/${id}">
|
|
|
|
<div class="gallery__item-info">
|
|
|
|
<p>${id}</p>\
|
|
|
|
<h2>${fileName}</h2>
|
|
|
|
</div>
|
|
|
|
<span class="gallery__item-filter"></span>
|
2023-01-08 15:14:35 +00:00
|
|
|
<img class="gallery__item-image" src="https://supersecreteuploadtest.leggy.dev/usr/images/${fileName}" onload="imgFade(this)" style="display:none;">
|
2022-12-14 19:55:40 +00:00
|
|
|
</a>
|
|
|
|
`;
|
|
|
|
|
|
|
|
$(imgDiv).hide().appendTo('#gallery').fadeIn(250);
|
|
|
|
}
|
|
|
|
|
2022-12-01 18:48:31 +00:00
|
|
|
$.ajax({
|
2022-12-14 19:55:40 +00:00
|
|
|
url: '/fileList/original',
|
2022-12-01 18:48:31 +00:00
|
|
|
type: 'get',
|
|
|
|
success: function(response) {
|
2022-12-14 19:55:40 +00:00
|
|
|
imageList = response;
|
2022-12-19 21:15:56 +00:00
|
|
|
loadMore(0, 30);
|
2022-12-14 19:55:40 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(window).scroll(function() {
|
2022-12-19 21:15:56 +00:00
|
|
|
if ($(window).height() + $(window).scrollTop() >= $(document).height() - 500) {
|
2022-12-14 19:55:40 +00:00
|
|
|
loadMore(imageIndex);
|
2022-12-01 18:48:31 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|