-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
98 lines (88 loc) · 1.81 KB
/
script.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
/*
instructions and syntaxes
*/
const iconsList = [
"📷",
"📄",
"🐱💻",
"🐱👤",
"🐱🚀",
"🐱👓",
"🐱🐉",
"🔋",
"🔗",
"🔧",
"🔨",
"🎉",
"🎲",
"🚀",
"👨🚀",
"🧱",
"🔬",
"🧰",
"🎬",
"📺",
"📚",
"📁",
"💡",
"🧪",
"⚡",
"🎯",
"♟️",
"🎨",
];
function randomIntNumber(range = 2) {
return Math.floor(Math.random() * range);
}
function setFavicon(icon = "📄") {
const favicon = document.querySelector("link[rel~='icon']");
favicon.href =
"data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 110 100%22><text y=%22.9em%22 font-size=%2290%22>" +
icon +
"</text></svg>";
}
function setRandomIcon() {
setFavicon(iconsList[randomIntNumber(iconsList.length)]);
}
function setFaviconDevice() {
const iconsDevice = { desktop: "🖥️", laptop: "💻", mobile: "📱" };
if (window.innerWidth <= 800) {
setFavicon(iconsDevice.mobile);
} else if (window.innerWidth <= 1400) {
setFavicon(iconsDevice.laptop);
} else {
setFavicon(iconsDevice.desktop);
}
}
setFavicon("⚙️");
setTimeout(() => {
setRandomIcon();
}, 400);
setTimeout(() => {
setRandomIcon();
}, 800);
setTimeout(() => {
setRandomIcon();
}, 1500);
setTimeout(() => {
setFaviconDevice();
}, 3000);
function toggleMode() {
const html = document.documentElement;
html.classList.toggle("light");
// change img tag and switch images
const img = document.querySelector("#profile img");
if (html.classList.contains("light")) {
img.setAttribute(
"src",
"https://avatars.githubusercontent.com/u/77335626?v=4"
);
img.setAttribute("alt", "Foto de Bernardo Vaz.");
} else {
img.setAttribute("src", "./assets/Avatar.png");
img.setAttribute(
"alt",
"Foto de Bernardo em Belo Horizonte, Lagoa da Pampulha."
);
}
}