-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
23 lines (21 loc) · 821 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
document.addEventListener('DOMContentLoaded', function() {
const gallery = document.getElementById('gallery');
for (let folder = 0; folder <= 9; folder++) {
for (let image = 1; image <= 1000; image++) {
const img = document.createElement('img');
const imageName = `${folder}/${image.toString().padStart(5, '0')}.svg`;
img.src = imageName;
img.alt = `Image ${imageName}`;
img.addEventListener('click', () => downloadImage(imageName));
gallery.appendChild(img);
}
}
});
function downloadImage(imageName) {
const link = document.createElement('a');
link.href = imageName;
link.download = imageName.split('/').pop();
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}