You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
863 B

<script>
import { onMount } from 'svelte';
import Lightbox from './lightbox.svelte';
let file_list;
let open;
let thumb_list = [];
const url = {
root: 'https://wg.flanchan.moe/cake/',
thumb: 'thumb/',
files: 'filelist.txt'
};
onMount(async () => {
file_list = await fetch(url.root + url.files)
.then(resp => resp.text())
.then(data => data.split('\n'));
// Loop backwards efficiently
for (let i = file_list.length - 2; i >= 0; i--) {
const file = file_list[i];
thumb_list.push(file.substr(0, file.lastIndexOf('.')) + '.jpg');
}
});
function open_lightbox(i) {
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}
</section>
{/if}
<Lightbox open={open} url={url} images={file_list} />