-
Notifications
You must be signed in to change notification settings - Fork 1
/
diario.js
46 lines (40 loc) · 1.57 KB
/
diario.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
// Função para definir um cookie
function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/";
}
// Função para obter o valor de um cookie
function getCookie(name) {
const cname = name + "=";
const decodedCookie = decodeURIComponent(document.cookie);
const ca = decodedCookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) === ' ') {
c = c.substring(1);
}
if (c.indexOf(cname) === 0) {
return c.substring(cname.length, c.length);
}
}
return "";
}
function checkAchievement(achievementName, message) {
console.log('Verificando conquista:', achievementName);
const achievementBox = document.createElement('div');
achievementBox.classList.add('achievement-box');
if (getCookie(achievementName) !== 'true') {
console.log('Conquista alcançada pela primeira vez:', achievementName);
showAchievementPopup(message);
setCookie(achievementName, 'true', 365);
achievementBox.textContent = message + "Concluído";
achievementBox.classList.add('achievement-completed');
} else {
console.log('Conquista já alcançada:', achievementName);
achievementBox.textContent = message + "Não concluído";
achievementBox.classList.add('achievement-not-completed');
}
document.body.appendChild(achievementBox);
}