2013-05-25 15:15:00 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="stdout"></div>
|
|
|
|
</body>
|
2013-05-26 00:37:13 +00:00
|
|
|
<script src='../lib/require.js'></script>
|
2013-05-25 15:15:00 +00:00
|
|
|
<script>
|
|
|
|
|
2013-05-26 00:37:13 +00:00
|
|
|
require.config({
|
|
|
|
baseUrl: "../lib",
|
|
|
|
paths: {
|
|
|
|
"src": "../src"
|
|
|
|
}
|
|
|
|
});
|
2013-05-25 15:15:00 +00:00
|
|
|
|
2013-05-26 00:37:13 +00:00
|
|
|
require(["src/indexeddb"], function(idb) {
|
2013-05-25 15:15:00 +00:00
|
|
|
|
|
|
|
var db;
|
2013-05-26 00:37:13 +00:00
|
|
|
idb.open('test').then(
|
2013-05-25 15:15:00 +00:00
|
|
|
function(event) {
|
2013-05-26 01:26:18 +00:00
|
|
|
db = event.target.result;
|
2013-05-25 15:15:00 +00:00
|
|
|
var transaction = db.transaction(['FILES'], 'readwrite');
|
|
|
|
var files = transaction.objectStore('FILES');
|
|
|
|
return files.clear();
|
|
|
|
},
|
|
|
|
function(event) {
|
|
|
|
console.error('error:', event);
|
|
|
|
},
|
|
|
|
function(event) {
|
2013-05-26 01:26:18 +00:00
|
|
|
db = event.target.result;
|
2013-05-25 15:15:00 +00:00
|
|
|
if(db.objectStoreNames().contains('FILES')) {
|
|
|
|
db.deleteObjectStore('FILES');
|
|
|
|
}
|
|
|
|
var files = db.createObjectStore('FILES');
|
|
|
|
}
|
|
|
|
).then(
|
|
|
|
function(event) {
|
|
|
|
var transaction = db.transaction(['FILES'], 'readwrite');
|
|
|
|
var files = transaction.objectStore('FILES');
|
|
|
|
return files.put('value', 'key');
|
|
|
|
}
|
|
|
|
).then(
|
|
|
|
function(event) {
|
|
|
|
var transaction = db.transaction(['FILES'], 'readwrite');
|
|
|
|
var files = transaction.objectStore('FILES');
|
|
|
|
return files.get('key');
|
|
|
|
}
|
|
|
|
).then(
|
|
|
|
function(event) {
|
|
|
|
console.info('result', event.target.result);
|
|
|
|
}
|
|
|
|
).otherwise(function(event) {
|
|
|
|
console.error('error: ', event);
|
|
|
|
});
|
|
|
|
|
2013-05-26 00:37:13 +00:00
|
|
|
});
|
|
|
|
|
2013-05-25 15:15:00 +00:00
|
|
|
</script>
|
|
|
|
</html>
|