質問編集履歴
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,6 +38,8 @@
|
|
38
38
|
|
39
39
|
```
|
40
40
|
|
41
|
+
|
42
|
+
|
41
43
|
<!DOCTYPE html>
|
42
44
|
|
43
45
|
<html>
|
@@ -60,25 +62,21 @@
|
|
60
62
|
|
61
63
|
<input type="button" value="設定" onclick="setValue()"/>
|
62
64
|
|
63
|
-
|
65
|
+
<!--
|
64
66
|
|
65
67
|
<h3>参照</h3>
|
66
68
|
|
67
69
|
<input type="button" value="全取得" onclick="getAll()"/>
|
68
70
|
|
69
|
-
|
71
|
+
-->
|
70
|
-
|
72
|
+
|
71
|
-
|
73
|
+
<h3>2処理結果</h3>
|
72
74
|
|
73
75
|
<div id="result"></div>
|
74
76
|
|
75
|
-
|
76
|
-
|
77
77
|
<hr/>
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
<h3>3インデックスを使った検索</h3>
|
82
80
|
|
83
81
|
<form action="#">
|
84
82
|
|
@@ -88,17 +86,13 @@
|
|
88
86
|
|
89
87
|
<p>小分類:<input type="text" id="copykey" placeholder="キー"/></p>
|
90
88
|
|
91
|
-
<!--
|
89
|
+
<!-- <input type="button" value="設定" onclick="copysetValue()"/>-->
|
92
|
-
|
93
|
-
|
90
|
+
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
<h3>4処理結果2
|
91
|
+
<h3>4処理結果2
|
98
|
-
|
92
|
+
|
99
|
-
</h3>
|
93
|
+
</h3>
|
100
|
-
|
94
|
+
|
101
|
-
<div id="result2"></div>
|
95
|
+
<div id="result2"></div>
|
102
96
|
|
103
97
|
</form>
|
104
98
|
|
@@ -118,41 +112,27 @@
|
|
118
112
|
|
119
113
|
// indexedDB.deleteDatabase("mydb");
|
120
114
|
|
121
|
-
|
122
|
-
|
123
115
|
var openRequest = indexedDB.open("mydb", 1.0);
|
124
116
|
|
125
|
-
|
126
|
-
|
127
117
|
openRequest.onupgradeneeded = function(event) {
|
128
118
|
|
129
119
|
// データベースのバージョンに変更があった場合(初めての場合もここを通ります。)
|
130
120
|
|
131
121
|
db = event.target.result;
|
132
122
|
|
133
|
-
var store = db.createObjectStore("mystore", { keyPath: "mykey"
|
123
|
+
var store = db.createObjectStore("mystore", { keyPath: "mykey",autoIncrement:true});
|
134
|
-
|
135
|
-
|
124
|
+
|
136
|
-
|
137
|
-
});
|
138
|
-
|
139
|
-
store.createIndex("myvalueIndex",["myvalue","myvalue2"]
|
125
|
+
store.createIndex("myvalueIndex",["myvalue","myvalue2"],{unique:false,multiEntry:false});
|
140
|
-
|
141
|
-
|
126
|
+
|
142
|
-
|
143
|
-
);
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
store.createIndex("myvalueIndexcate",["myvalue"],{unique:false,multiEntry:false});
|
127
|
+
store.createIndex("myvalueIndexcate",["myvalue"],{unique:false,multiEntry:false});
|
148
128
|
|
149
129
|
}
|
150
130
|
|
151
131
|
openRequest.onsuccess = function(event) {
|
152
132
|
|
153
|
-
|
133
|
+
db = event.target.result;
|
154
|
-
|
134
|
+
|
155
|
-
|
135
|
+
}
|
156
136
|
|
157
137
|
} else {
|
158
138
|
|
@@ -160,7 +140,7 @@
|
|
160
140
|
|
161
141
|
}
|
162
142
|
|
163
|
-
|
143
|
+
|
164
144
|
|
165
145
|
function setValue(event) {
|
166
146
|
|
@@ -168,7 +148,7 @@
|
|
168
148
|
|
169
149
|
var value = document.getElementById("newvalue").value;
|
170
150
|
|
171
|
-
|
151
|
+
var value2 = document.getElementById("newvalue2").value;
|
172
152
|
|
173
153
|
var transaction = db.transaction(["mystore"], "readwrite");
|
174
154
|
|
@@ -182,15 +162,13 @@
|
|
182
162
|
|
183
163
|
document.getElementById("newvalue").value = "";
|
184
164
|
|
185
|
-
|
165
|
+
document.getElementById("newvalue2").value = "";
|
186
|
-
|
166
|
+
|
187
|
-
}
|
167
|
+
}
|
188
|
-
|
168
|
+
|
189
|
-
}
|
169
|
+
}
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
170
|
+
|
171
|
+
|
194
172
|
|
195
173
|
function getAll(event) {
|
196
174
|
|
@@ -214,23 +192,21 @@
|
|
214
192
|
|
215
193
|
var cursor = event.target.result;
|
216
194
|
|
217
|
-
|
195
|
+
var data = cursor.value;
|
218
|
-
|
196
|
+
|
219
|
-
result.innerHTML += "<table border='1'><td>"+"key:" + cursor.key + "</td>" +"<td>"+"value:" + data.myvalue + " value2:" + data.myvalue2 +"</td></table>";
|
197
|
+
result.innerHTML += "<table border='1'><td>"+"key:" + cursor.key + "</td>" +"<td>"+"value:" + data.myvalue + " value2:" + data.myvalue2 +"</td></table>";
|
220
198
|
|
221
199
|
cursor.continue();
|
222
200
|
|
223
|
-
|
224
|
-
|
225
|
-
}
|
201
|
+
}
|
226
|
-
|
202
|
+
|
227
|
-
}
|
203
|
+
}
|
228
|
-
|
229
|
-
|
230
|
-
|
204
|
+
|
205
|
+
|
206
|
+
|
231
|
-
|
207
|
+
function getAllcate(event) {
|
232
|
-
|
208
|
+
|
233
|
-
|
209
|
+
var result = document.getElementById("result2");
|
234
210
|
|
235
211
|
result.innerHTML = "";
|
236
212
|
|
@@ -240,62 +216,50 @@
|
|
240
216
|
|
241
217
|
var index = store.index("myvalueIndexcate");
|
242
218
|
|
243
|
-
var request = index.openCursor(null,"nextunique");
|
219
|
+
var request = index.openCursor(null,"nextunique");
|
244
220
|
|
245
221
|
request.onsuccess = function (event) {
|
246
222
|
|
247
|
-
if(event.target.result == null) {
|
223
|
+
if(event.target.result == null) {
|
248
|
-
|
224
|
+
|
249
|
-
return;
|
225
|
+
return;
|
250
|
-
|
226
|
+
|
251
|
-
}
|
227
|
+
}
|
252
228
|
|
253
229
|
var cursor = event.target.result;
|
254
230
|
|
255
|
-
|
231
|
+
var data = cursor.value;
|
256
|
-
|
232
|
+
|
257
|
-
|
233
|
+
result.innerHTML += "<p class='txt' value='data.myvalue'>" + '大分類: ' +data.myvalue +"</p>";
|
258
234
|
|
259
235
|
cursor.continue();
|
260
236
|
|
261
|
-
|
262
|
-
|
263
|
-
}
|
237
|
+
}
|
264
|
-
|
238
|
+
|
265
|
-
}
|
239
|
+
}
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
240
|
+
|
241
|
+
|
242
|
+
|
271
|
-
window.addEventListener('DOMContentLoaded', function(e){
|
243
|
+
window.addEventListener('DOMContentLoaded', function(e){
|
272
|
-
|
244
|
+
|
273
|
-
[].forEach.call(document.querySelectorAll('.txt'),function(x){
|
245
|
+
[].forEach.call(document.querySelectorAll('.txt'),function(x){
|
274
|
-
|
246
|
+
|
275
|
-
["click","input"].forEach(function(y){
|
247
|
+
["click","input"].forEach(function(y){x.addEventListener(y,function(e){
|
276
|
-
|
277
|
-
|
248
|
+
|
278
|
-
|
279
|
-
|
249
|
+
var v=(x.nodeName=="INPUT")?x.value:x.textContent;
|
280
250
|
|
281
251
|
document.querySelector('#copy').value=v;
|
282
252
|
|
283
253
|
});
|
284
254
|
|
255
|
+
});
|
256
|
+
|
285
257
|
});
|
286
258
|
|
287
259
|
});
|
288
260
|
|
289
|
-
});
|
290
|
-
|
291
261
|
</script>
|
292
262
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
263
|
</html>
|
298
264
|
|
299
|
-
|
300
|
-
|
301
265
|
```
|