forked from fac-17/week-3-MEIA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeature-meme.js
28 lines (27 loc) · 940 Bytes
/
feature-meme.js
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
const pages = Math.floor(Math.random() * 10);
request(`https://picsum.photos/v2/list?page=${pages}&limit=100`, function(
response
) {
const image = document.querySelector(".image");
const random = Math.floor(Math.random() * 100);
imageObj=response[random];
image.src = imageObj.download_url;
let aspectRatio= imageObj.width/imageObj.height;
//dont load really wide images and portrait images
while(aspectRatio<(4/3)|| aspectRatio>(16/9))
{
imageObj=response[Math.floor(Math.random() * 100)];
image.src = imageObj.download_url;
aspectRatio= imageObj.width/imageObj.height;
}
image.addEventListener("load", () => {
request("https://corporatebs-generator.sameerkumar.website/", function(
response
) {
const sentence = document.querySelector(".sentence");
let p = document.createElement("p");
p.textContent = response.phrase;
sentence.appendChild(p);
});
});
});