-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
29 lines (24 loc) · 900 Bytes
/
main.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
29
const urlApi = "https://dog.ceo/api/breeds/image/random/10";
var resultApi = [];
var string = '';
fetch(urlApi)
.then(response => response.json())
.then(function (data) {
resultApi = data.message;
});
setTimeout(function getPhotos() {
resultApi.forEach(sendToHtml);
}, 1000);
function sendToHtml() {
for (let i = 0; i < resultApi.length; i++) {
if (i == 0) {
string = "<div class='item active'><img src=" + resultApi[i] + " class='photos' style='width:750px; height:750px;' alt='0'></div>";
} else
string += "<div class='item'><img src=" + resultApi[i] + " class='photos' style='width:750px; height:750px;' alt='0'></div>";
}
document.getElementById('inputCarousel').innerHTML = string;
}
var refresh = document.querySelector("#buttonRefresh");
refresh.addEventListener("click", function () {
location.reload();
});