-
Notifications
You must be signed in to change notification settings - Fork 2
/
webstore.js
54 lines (51 loc) · 1.57 KB
/
webstore.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
46
47
48
49
50
51
52
53
54
// save data in html 5 stores
const saveData = ()=>{
console.log(`Save data`);
// permanent store
// localStorage
// session store
// sessionStorage
localStorage.setItem('msg','Hello world');
}
// save data in session store
const saveSessionData = () =>{
sessionStorage.setItem('sessionMsg','Session Hello World');
}
// get data from session data
const getSessionStoreData = () =>{
const sessionBox = document.getElementById('session-store-data');
// set the session store data in textbox
sessionBox.value = sessionStorage.getItem('sessionMsg');
}
const getWebStoreData = ()=>{
// get data from local storage
const msg = localStorage.getItem('msg');
// get the text box
const data = document.getElementById('local-store-data');
// set the web store data into the textbox
data.value = msg;
}
// delete the msg from web store
const deleteWebStoreData = ()=>{
const data = document.getElementById('local-store-data');
data.value ='';
// delete the msg from local storage
localStorage.removeItem('msg');
}
// delete the msg from web store
const deleteSessionStoreData = ()=>{
const data = document.getElementById('session-store-data');
data.value ='';
// delete the msg from local storage
localStorage.removeItem('sessionMsg');
}
// just resetting the fields
const resetField= ()=>{
const data = document.getElementById('local-store-data');
data.value ='';
}
// just resetting the fields
const resetSessionField= ()=>{
const data = document.getElementById('session-store-data');
data.value ='';
}