1
0
Fork 0
su-collab/script/image_load.js

46 lines
1.3 KiB
JavaScript

let dictionaries = []
let image_count = 0
function load_image(image) {
viewer.addTiledImage({
tileSource: image.tileSource,
x: image.x,
y: image.y,
});
}
fetch('image/image.txt')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text();
})
.then(text => {
const lines = text.split('\n');
lines.forEach(line => {
if (!line.startsWith('#') && line.length > 0) {
const parts = line.split(' ');
const dictionary = {
imageCount: image_count,
tileSource: 'image/dzi_edited/' + parts[0] + '/' + parts[0] + '.dzi',
x: parseInt(parts[1]),
y: parseInt(parts[2]),
red: parseInt(parts[3]),
green: parseInt(parts[4]),
blue: parseInt(parts[5]),
};
load_image(dictionary);
dictionaries.push(dictionary);
image_count++;
}
});
document.getElementById("current").innerText = `Currently we are featuring ${image_count} images.`;
})
.catch(error => {
console.error('Error:', error);
});