-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestpage.html
79 lines (63 loc) · 2.62 KB
/
testpage.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MicroCookie Test</title>
<style>
body {
display: grid;
grid-template-columns: auto auto auto;
}
#c {
text-align: center;
}
button {
display: inline-grid;
}
#out {
font-family: monospace;
text-align: center;
}
</style>
<script src="../dist/microcookie-min.js"></script>
<script>
function showCookie(cookie) {
var c = MicroCookie.get(cookie)
console.log(c)
document.getElementById("out").innerHTML = c
}
function addCookie(cookie, value, days, options) {
let expiration = MicroCookie.makeExpiration(days)
MicroCookie.set(cookie, value, expiration, options)
//show timestamp & new cookie values.
console.log(expiration)
console.log(document.cookie)
}
function deleteCookie(cookie, path) {
MicroCookie.remove(cookie, path)
}
</script>
</head>
<body>
<br>
<div id="c"><p>This page is a test integration for the MicroCookie JS library.</p></div>
<br>
<button onclick="showCookie('test')">Show "test" cookie</button>
<button onclick="showCookie('test2')">Show "test2" cookie</button>
<button onclick="showCookie('test3')">Show "test3" cookie</button>
<button onclick="addCookie('test', 'this is a test!', 1)">Add "test" cookie <br>expiring in 1 day</button>
<button onclick="addCookie('test2', 'this is another test!', 2)">Add "test2" cookie <br>expiring in 2 days</button>
<button onclick="addCookie('test3', 'this is the third test!', 3, {path: '/' })">Add "test3" cookie expiring <br>in 3 days and path is "/"</button>
<button onclick="deleteCookie('test')">Delete "test" cookie <br>with no path specified</button>
<button onclick="deleteCookie('test2')">Delete "test2" cookie <br>with no path specified</button>
<button onclick="deleteCookie('test3')">Delete "test3" cookie <br>with no path specified</button>
<button onclick="deleteCookie('test', '/')">Delete "test" cookie <br>with / path specified</button>
<button onclick="deleteCookie('test2', '/')">Delete "test2" cookie <br>with / path specified</button>
<button onclick="deleteCookie('test3', '/')">Delete "test3" cookie <br>with / path specified</button>
<br>
<p>Output: <span id="out"></span></p>
<br>
</body>
</html>