|
|
@ -12,17 +12,49 @@
|
|
|
|
files: 'filelist.txt'
|
|
|
|
files: 'filelist.txt'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
const fetch_things = async (first_number) => {
|
|
|
|
file_list = await fetch(url.root + url.files)
|
|
|
|
const file = fetch(url.root + url.files)
|
|
|
|
|
|
|
|
.then(resp => resp.text())
|
|
|
|
|
|
|
|
.then(data => data.split('\n'));
|
|
|
|
|
|
|
|
const thumb = fetch(url.root + url.thumb + url.files)
|
|
|
|
.then(resp => resp.text())
|
|
|
|
.then(resp => resp.text())
|
|
|
|
.then(data => data.split('\n'));
|
|
|
|
.then(data => data.split('\n'));
|
|
|
|
|
|
|
|
const out = await Promise.all([file, thumb]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If we only want to get first N
|
|
|
|
|
|
|
|
if(first_number) {
|
|
|
|
|
|
|
|
(out[0].length > first_number && (out[0].length = first_number));
|
|
|
|
|
|
|
|
(out[1].length > first_number && (out[0].length = first_number));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {file: out[0], thumb: out[1]};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
|
|
|
|
const file_lists = await fetch_things(10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const thumbs_resolved = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(const thumb of file_lists.thumb)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
thumbs_resolved[thumb] = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file_list = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("uhh");
|
|
|
|
// Loop backwards efficiently.
|
|
|
|
// Loop backwards efficiently.
|
|
|
|
for (let i = file_list.length - 2; i >= 0; i--) {
|
|
|
|
for (let i = 1; i < file_lists.file.length; i++) {
|
|
|
|
const file = file_list[i];
|
|
|
|
const file = file_lists.file[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (/^\s*$/.test(file)) continue;
|
|
|
|
|
|
|
|
|
|
|
|
// Thumbs are only ever .jpg
|
|
|
|
// Thumbs are only ever .jpg
|
|
|
|
thumb_list.push(file.substr(0, file.lastIndexOf('.')) + '.jpg');
|
|
|
|
const thumb_name = file.substr(0, file.lastIndexOf('.')) + '.jpg';
|
|
|
|
|
|
|
|
if (thumbs_resolved[thumb_name]) {
|
|
|
|
|
|
|
|
thumb_list.push(thumb_name);
|
|
|
|
|
|
|
|
file_list.push(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|