-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
99 lines (80 loc) · 3.07 KB
/
Copy pathindex.html
File metadata and controls
99 lines (80 loc) · 3.07 KB
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
97
98
99
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
<script type="module" src="/src/main.ts"></script>
<style>
body {
font-family: sans-serif;
margin: 0 auto;
padding: 2rem 1rem;
max-width: 800px;
}
[aria-hidden="true"] {
display: none;
}
.exampletarget {
border: 1px solid #ccc;
padding: 1rem;
}
</style>
</head>
<body>
<div id="root">
<h1>Store manager</h1>
<p>This page shows different examples of you can use the store manager</p>
</div>
<div id="examples">
<section id="example1">
<h2>Example 1. Store with namespace</h2>
<script>
document.addEventListener("DOMContentLoaded", async function () {
const statusElm = document.querySelector("#example1 pre");
if (window.StoreManager) {
statusElm.innerHTML += `StoreManager found \n`;
}
console.log('window.StoreManager', window.StoreManager)
const storeInstance = new window.StoreManager("customprefix");
console.log('storeInstance', storeInstance)
if (storeInstance) {
statusElm.innerHTML += `Store Manager initiated on with prefix 'customprefix' \n`;
}
storeInstance.Set('example1key', {
'store object': 123
});
statusElm.innerHTML += `Stored 'customprefix-example1key' in session storage \n`;
statusElm.innerHTML += `Verified 'example2key' does not exist: ${storeInstance.Has('example2key')} \n`;
storeInstance.Set('example2key', "123", true);
statusElm.innerHTML +=
`Stored 'example2key' in local storage with value ${storeInstance.Get('example2key')}\n`;
storeInstance.Set('example3key', "123", true);
storeInstance.Set('example3key', "123", false);
storeInstance.Remove('example3key');
statusElm.innerHTML += `Stored stored and removed 'example3key' in both local and session storage\n`;
// if (storeInstance.has('example1key')) {
// statusElm.innerHTML += `Verified that store 'example1store' has reference 'example1key' \n`;
// }
// if (!storeInstance.has('nonExistingKey')) {
// statusElm.innerHTML += `Verified that store 'example1store' does NOT have reference 'nonExistingKey' \n`;
// }
// const example1ref = storeInstance.get('example1key');
// if (example1ref) {
// statusElm.innerHTML += `Got reference for 'example1key' in store 'example1store' \n`;
// if (example1ref()) {
// statusElm.innerHTML += `Reference function 'example1key' in store 'example1store has run successfully' \n`;
// }
// }
});
function example1callback() {
console.log('Inside of example1callback')
return true;
}
</script>
<pre></pre>
</section>
</div>
</body>
</html>