-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperfil.js
34 lines (30 loc) · 992 Bytes
/
perfil.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
const userId = localStorage.getItem('user_id');
const userName = localStorage.getItem('user_name');
const profilePicture = localStorage.getItem('user_pic');
const userPokemon = localStorage.getItem('user_pokemon');
//função de chamada
function hasUserEntered(userId){
return getCookie(`userPokemon_${userId}`);
}
//muda o atributos da pagina noavmente
fullname.textContent = userName;
pokemon.textContent = hasUserEntered(userId);
console.log(hasUserEntered(userId));
console.log("alo");
pic.setAttribute("src", profilePicture);
//pegando os cookies
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 "";
}