-
Notifications
You must be signed in to change notification settings - Fork 1
/
SelectPokemon.html
96 lines (74 loc) · 2.8 KB
/
SelectPokemon.html
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
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>chose</title>
<link rel="stylesheet" href="SelectPokemon.css">
</head>
<body>
<main id ="app">
<h1>Escolha seu pokemon inicial</h1>
<section class="cards">
<div id="charm" class="card pika animated"></div>
<div id="buba" class="card eevee animated"></div>
<div id="squirt" class="card mewtwo animated"></div>
</section>
<style class="hover"></style>
</main>
<div class="Pikachu">
<div ontouchstart="">
<div class="button">
<a id="Btpikachu" href="#">Start</a>
</div>
</div>
<script src="fonte.js"></script>
</body>
<script>
const userId = localStorage.getItem('user_id');
squirt.addEventListener('click', function() {
setCookie(`userPokemon_${userId}`, "squirtle", 365);
localStorage.setItem('user_pokemon', "squirtle");
window.location.href = "choseCaracter.html";
});
buba.addEventListener('click', function() {
setCookie(`userPokemon_${userId}`, "bubassour", 365);
localStorage.setItem('user_pokemon', "bubassour");
window.location.href = "choseCaracter.html";
});
charm.addEventListener('click', function() {
setCookie(`userPokemon_${userId}`, "charmander", 365);
localStorage.setItem('user_pokemon', "charmander");
window.location.href = "choseCaracter.html";
});
Btpikachu.addEventListener('click', function() {
setCookie(`userPokemon_${userId}`, "Pikachu", 365);
localStorage.setItem('user_pokemon', "Pikachu");
window.location.href = "showPikachu.html";
});
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=/";
}
function getCookiePokemon(name, userid) {
const userId = localStorage.getItem('user_id');
if (userid == userId){
const cname = name + "=" + userid + "/";
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 "";
}
}
</script>
</html>