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) {
|
|
|
|
db = event.target._result;
|
|
|
|
var transaction = db.transaction(['FILES'], 'readwrite');
|
|
|
|
var files = transaction.objectStore('FILES');
|
|
|
|
return files.clear();
|
|
|
|
},
|
|
|
|
function(event) {
|
|
|
|
console.error('error:', event);
|
|
|
|
},
|
|
|
|
function(event) {
|
|
|
|
db = event.target._result;
|
|
|
|
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>
|