|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
<script>
|
|
|
|
|
import { onMount } from 'svelte';
|
|
|
|
|
import Lightbox from './lightbox.svelte';
|
|
|
|
|
|
|
|
|
|
let file_list;
|
|
|
|
|
let open;
|
|
|
|
|
let thumb_list = [];
|
|
|
|
@ -16,24 +17,27 @@
|
|
|
|
|
.then(resp => resp.text())
|
|
|
|
|
.then(data => data.split('\n'));
|
|
|
|
|
|
|
|
|
|
// Loop backwards efficiently
|
|
|
|
|
// Loop backwards efficiently.
|
|
|
|
|
for (let i = file_list.length - 2; i >= 0; i--) {
|
|
|
|
|
const file = file_list[i];
|
|
|
|
|
|
|
|
|
|
// Thumbs are only ever .jpg
|
|
|
|
|
thumb_list.push(file.substr(0, file.lastIndexOf('.')) + '.jpg');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function open_lightbox(i) {
|
|
|
|
|
open = null;
|
|
|
|
|
// If `open' is already `i' updates aren't sent to lightbox.
|
|
|
|
|
open = null;
|
|
|
|
|
open = i;
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if file_list}
|
|
|
|
|
<section>
|
|
|
|
|
{#each thumb_list as thumb, i}
|
|
|
|
|
<img on:click={() => open_lightbox(i)} src="{url.root}{url.thumb}{thumb}" />
|
|
|
|
|
{/each}
|
|
|
|
|
{#each thumb_list as thumb, i}
|
|
|
|
|
<img on:click={() => open_lightbox(i)} src="{url.root}{url.thumb}{thumb}" />
|
|
|
|
|
{/each}
|
|
|
|
|
</section>
|
|
|
|
|
{/if}
|
|
|
|
|
<Lightbox open={open} url={url} images={file_list} />
|
|
|
|
|