filer/examples/refactoring-test.html

50 lines
874 B
HTML
Raw Normal View History

2013-05-30 18:57:33 +00:00
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="stdout"></div>
</body>
<script src="../lib/require.js"></script>
<script>
require.config({
baseUrl: "../lib",
paths: {
"src": "../src"
}
});
2013-05-31 01:38:44 +00:00
require(["src/file-system"], function(IDBFS) {
2013-05-30 18:57:33 +00:00
var flags = 'FORMAT';
//var flags = undefined;
2013-05-31 15:30:01 +00:00
var fs = new IDBFS.FileSystem('local', flags);
2013-05-30 18:57:33 +00:00
fs.promise.otherwise(
function(error) {
console.error(error);
}
);
function make_tmp_directory() {
return fs.mkdir('/tmp');
};
2013-05-30 22:49:31 +00:00
function remove_tmp_directory() {
return fs.rmdir('/tmp');
};
2013-05-31 07:52:04 +00:00
function create_tmp_file() {
2013-05-31 19:03:18 +00:00
return fs.open('/tmp/1', 'w+');
2013-05-31 07:52:04 +00:00
};
2013-05-30 22:49:31 +00:00
fs.promise.then(make_tmp_directory)
2013-05-31 07:52:04 +00:00
.then(create_tmp_file)
2013-05-30 22:49:31 +00:00
.then(function() { console.log('done'); })
2013-05-31 19:03:18 +00:00
.otherwise(function(error) { console.error(error, error.message); });
2013-05-30 18:57:33 +00:00
});
</script>
</html>