-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
53 lines (44 loc) · 1.16 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
/**
* @constant {HTMLElement}
* @type {HTMLElement}
*/
const root = document.documentElement;
/**
* @constant {HTMLImageElement}
* @type {Object}
*/
const avatar = document.querySelector(".profile__img");
/**
* Changes the page theme between dark and light
* @return {void}
*/
function changeTheme() {
root.classList.toggle("light");
changePicture();
}
/**
Changes the Picture according to the page theme
* @return {void}
*/
function changePicture() {
if (root.classList.contains("light")) {
avatar.src = "./assets/avatar-light.png";
avatar.alt = "Foto de Victor usando camiseta branca e óculos escuros";
} else {
avatar.src = "./assets/avatar.png";
avatar.alt = "Foto de Victor usando camiseta preta e óculos";
}
}
/**
* Changes the picture to a cartoon version on mouse over and returns to default on mouse out
* @return {void}
*/
function cartoonImage() {
if (root.classList.contains("light")) {
avatar.src = "./assets/avatar-cartoon-light.jpg";
avatar.alt = "Foto de Victor cartoonizada usando óculos escuros";
} else {
avatar.src = "./assets/avatar-cartoon.jpg";
avatar.alt = "Foto de Victor cartoonizada";
}
}