thumb list resolve

ご主人様
Avril 4 years ago
parent 5363954095
commit 8b6cd3f49c
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -12,17 +12,49 @@
files: 'filelist.txt'
};
onMount(async () => {
file_list = await fetch(url.root + url.files)
const fetch_things = async (first_number) => {
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(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.
for (let i = file_list.length - 2; i >= 0; i--) {
const file = file_list[i];
for (let i = 1; i < file_lists.file.length; i++) {
const file = file_lists.file[i];
if (/^\s*$/.test(file)) continue;
// 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);
}
}
});

Loading…
Cancel
Save