-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch.js
36 lines (33 loc) · 1.4 KB
/
fetch.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
30
31
32
33
34
35
console.log('Hi you!😉');
fetch('https://api.github.com/users/annaudziela/repos?sort=created&direction=asc')
.then(resp => resp.json())
.then(resp => {
for (let repo of resp) {
const {name, html_url} = repo;
const repositoryList = document.querySelector('.list__details--js');
const myTemplate = `<li>
${name} || <a href="${html_url}" title="link to ${name} repository on gitHub"> go to Github</a>
</li>`;
repositoryList.innerHTML += myTemplate;
}
})
.catch(error => {
console.log('Error: unable to download repos');
})
let isDark = false;
const switchModes = document.querySelector('.button--js');
switchModes.addEventListener('click' , () => {
if (isDark) {
document.documentElement.style.setProperty('--background-color', 'whitesmoke');
document.documentElement.style.setProperty('--text-color', '#373F47');
document.documentElement.style.setProperty('--border-style', '#373F47 1px solid');
document.documentElement.style.setProperty('--link-color', 'rgba(0, 0, 0, 0.781)');
isDark = false;
} else {
document.documentElement.style.setProperty('--background-color', 'rgba(140, 144, 144, 0.800)');
document.documentElement.style.setProperty('--text-color', 'whitesmoke');
document.documentElement.style.setProperty('--border-style', 'whitesmoke 1px solid');
document.documentElement.style.setProperty('--link-color', 'whitesmoke');
isDark = true;
}
});