-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
98 lines (83 loc) · 2.32 KB
/
index.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
console.log(`meow :3
/l、
゙(゚、 。 7
l、゙ ~ヽ
じしf_, )ノ
`);
let theme = localStorage.getItem("darkTheme");
const enableDarkMode = () => {
document.querySelector("body").classList.remove("light");
document.querySelector("body").classList.add("dark");
icon = document.getElementById("btn-icon");
icon.removeAttribute("data-icon");
icon.setAttribute(
"data-icon",
"line-md:sunny-outline-to-moon-alt-loop-transition",
);
localStorage.removeItem("darkTheme");
localStorage.setItem("darkTheme", "enabled");
};
const disableDarkMode = () => {
document.querySelector("body").classList.remove("dark");
document.querySelector("body").classList.add("light");
icon = document.getElementById("btn-icon");
icon.removeAttribute("data-icon");
icon.setAttribute(
"data-icon",
"line-md:moon-alt-to-sunny-outline-loop-transition",
);
localStorage.removeItem("darkTheme");
localStorage.setItem("darkTheme", "disabled");
};
if (
theme == "enabled" ||
(window.matchMedia("(prefers-color-scheme: dark)").matches &&
theme !== "disabled")
) {
enableDarkMode();
} else {
disableDarkMode();
}
const changetheme = () => {
theme = localStorage.getItem("darkTheme");
theme !== "enabled" ? enableDarkMode() : disableDarkMode();
};
//make repos load automatically
var projects = document.querySelector(".projects");
const repos = "https://api.github.com/users/PsyNyde/repos?sort=updated";
const api = "https://api.github.com/users/PsyNyde";
fetch(api)
.then((res) => res.json())
.then((data) => {
var followers = data.followers;
});
fetch(repos)
.then((res) => res.json())
.then((data) => {
i = 0;
num = 6;
while (i < num) {
repo = data[i];
projects.innerHTML += `
<div class=project-holder>
<a href="${repo.html_url}" target=_blank>
<div>
<h4>
<span>
<span class=iconify data-icon=bx:book></span> ${repo.name}
</span>
<span class="star">${repo.stargazers_count} <span class="iconify" data-icon="fluent-emoji-high-contrast:star"></span></span>
</h4>
<p class=description>${repo.description}</p>
</div>
</a>
</div>
`;
i++;
}
});
const age = document.querySelector(".age");
age.textContent = `${(
(new Date() - new Date(2003, 11, 10)) /
31557600000
).toFixed(2)}`;