This repository was archived by the owner on Jan 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (33 loc) · 1.26 KB
/
script.js
File metadata and controls
35 lines (33 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
request = new XMLHttpRequest();
request.open("GET", 'https://picsum.photos/v2/list');
request.onload = function()
{
let images = JSON.parse(request.responseText);
for (let imagenumber = 0; imagenumber < 30; imagenumber++)
{
images[imagenumber].download_url;
images[imagenumber].author;
images[imagenumber].width;
images[imagenumber].height;
aside = document.querySelector('aside');
thumb = document.createElement('div');
thumb.classList.add('thumb');
thumbOverlay = document.createElement('div');
thumbOverlay.classList.add('overlay');
let thumbImg = new Image();
thumbImg.src = images[imagenumber].download_url;
aside.appendChild(thumb);
thumb.appendChild(thumbOverlay);
thumb.appendChild(thumbImg);
thumb.addEventListener('click', function()
{
let bigImg = document.getElementById("big-img");
bigImg.src = images[imagenumber].download_url;
document.querySelector(".description").innerHTML =
'author: ' + images[imagenumber].author
+ '<br> width: ' + images[imagenumber].width + ' px'
+ '<br> height:' + images[imagenumber].height + ' px';
});
}
}
request.send();