forked from jensarps/IDBWrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
99 lines (86 loc) · 2.46 KB
/
index.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
97
98
99
<!DOCTYPE html>
<html>
<head>
<title>IndexedDB Wrapper</title>
</head>
<body onload="onload();">
<p>Open the console and click 'Open DB'. You will then see a bunch of buttons that allow data manipulation. Click them, and check the console for results.</p>
<p id="openWrapper" style="display: none;">
<button onclick="createStore_1_1()">Open DB</button>
</p>
<p id="dataWrapper" style="display: none;">
<button onclick="testWrite()">put</button>
<br />
<button onclick="testRead()">get</button>
<br />
<button onclick="testGetAll()">getAll</button>
<br />
<button onclick="testRemove()">remove</button>
<br />
<button onclick="testClear()">clear</button>
</p>
<script type="text/javascript" src="IDBStore.js"></script>
<script type="text/javascript">
function onload(){
document.getElementById('openWrapper').style.display='';
}
/* methods for walking thorugh the data ops: */
function testWrite(store){
store = store || store_1_1;
store.put({
id: 2,
name: 'Doe',
age: 52
},
function(result){
console.log('put() call success. Result:', result);
}
);
}
function testRead(store){
store = store || store_1_1;
store.get(2, function(result){
console.log('get() call success. Result:', result);
});
}
function testGetAll(store){
store = store || store_1_1;
store.getAll(function(result){
console.log('getAll() call success. Result:', result);
});
}
function testRemove(store){
store = store || store_1_1;
store.remove(2, function(result){
console.log('remove() call success. Result:', result);
});
}
function testClear(store){
store = store || store_1_1;
store.clear(function(result){
console.log('clear() call success. Result:', result);
});
}
function testDeleteStore(store){
store = store || store_1_1;
store.deleteObjectStore();
}
/* create a store using the wrapper and kick off: */
function createStore_1_1(){
window['store_1_1'] = new IDBStore({
dbName: 'idbTestDb',
dbDescription: 'test db 1',
dbVersion: '1',
storeName: 'testStore_1_1',
keyPath: 'id',
autoIncrement: true,
onStoreReady: function(){
console.log('Store ready, go ahead!');
document.getElementById('openWrapper').style.display='none';
document.getElementById('dataWrapper').style.display='';
}
});
}
</script>
</body>
</html>