remove old examples

This commit is contained in:
Alan Kligman 2013-12-14 22:23:00 -05:00
parent dac59f97b3
commit 45fdb7aa66
6 changed files with 0 additions and 512 deletions

View File

@ -1,15 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="stdout"></div>
</body>
<script src="../lib/crypto-js/rollups/sha256.js"></script>
<script>
console.log(CryptoJS.SHA256('/').toString(CryptoJS.enc.hex));
</script>
</html>

View File

@ -1,87 +0,0 @@
<!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"
}
});
require(["src/indexeddb2"], function(idb) {
var opened = idb.open('test').then(
function(event) {
return event.db;
},
function(event) {
console.error('error:', event);
},
function(event) {
if('upgradeneeded' == event.type) {
db = event.target.result;
if(db.objectStoreNames.contains('FILES')) {
db.deleteObjectStore('FILES');
}
var files = db.createObjectStore('FILES');
}
}
);
opened.then(
function(db) {
console.log(db);
}
);
/*
var db = idb.open('test');
db.progress(
function(event) {
if('upgradeneeded' == event.type) {
db = event.target.result;
if(db.objectStoreNames.contains('FILES')) {
db.deleteObjectStore('FILES');
}
var files = db.createObjectStore('FILES');
}
}
);
db.otherwise(
function(event) {
console.error('error:', event);
}
);
db.transaction(['FILES'], 'readwrite')(
function(transaction) {
var files = transaction.objectStore('FILES');
return files.clear();
}
).transaction(['FILES'], 'readonly')(
function(transaction) {
}
);
db.transaction(['FILES'], 'readwrite')(
function(transaction) {
}
);
*/
});
</script>
</html>

View File

@ -1,94 +0,0 @@
<!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"
}
});
require(["src/fs"], function(IDBFS) {
IDBFS.mount("default", "format", function(error, fs) {
if(error) {
return console.error(error);
}
fs.mkdir("/tmp", function(error) {
if(error) {
return console.error(error);
}
fs.stat("/tmp", function(error, result) {
if(error) {
return console.error(error);
}
console.info("stat /tmp", result);
fs.open("/tmp/0", "create", "rw", function(error, fd) {
if(error) {
return console.error(error);
}
var writeBuffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
fd.write(writeBuffer, function(error, bytes_written, buffer) {
if(error) {
return console.error(error);
}
console.info("bytes written:", bytes_written);
var readBuffer = new Uint8Array(8);
fd.seek(-bytes_written, "current", function(error) {
if(error) {
return console.error(error);
}
fd.read(readBuffer, function(error, bytes_read, buffer) {
if(error) {
return console.error(error);
}
console.info("bytes read:", bytes_read);
console.info("buffer:", buffer);
fs.close(fd, function(error) {
fs.stat("/tmp/0", function(error, result) {
if(error) {
return console.error(error);
}
console.info("stat /tmp/0", result);
fs.link("/tmp/0", "/tmp/1", function(error) {
if(error) {
return console.error(error);
}
fs.stat("/tmp/1", function(error, result) {
if(error) {
return console.error(error);
}
console.info("stat /tmp/1", result);
fs.unlink("/tmp/0", function(error) {
if(error) {
return console.error(error);
}
fs.stat("/tmp/1", function(error, result) {
if(error) {
return console.error(error);
}
console.info("stat /tmp/1", result);
});
});
});
});
});
});
});
});
});
});
});
});
});
});
</script>
</html>

View File

@ -1,67 +0,0 @@
<!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"
}
});
require(["src/fs"], function(IDBFS) {
IDBFS.mount("default", "format", function(error, fs) {
if(error) {
return console.error(error);
}
fs.mkdir("/tmp", function(error) {
if(error) {
return console.error(error);
}
fs.stat("/tmp", function(error, result) {
if(error) {
return console.error(error);
}
console.info("stat /tmp", result);
fs.open("/tmp/file-0", "create", "rw", function(error, fd) {
if(error) {
return console.error(error);
}
fs.link("/tmp/file-0", "/tmp/file-1", function(error) {
if(error) {
return console.error(error);
}
fs.stat("/tmp", function(error, result) {
if(error) {
return console.error(error);
}
console.info("stat /tmp", result);
fs.open("/tmp", "", "ro", function(error, fd) {
if(error) {
return console.error(error);
}
var dirBuffer = [];
fd.readdir(dirBuffer, 4, function(error, count, buffer) {
if(error) {
return console.error(error);
}
console.info(count, buffer);
});
});
});
});
});
});
});
});
});
</script>
</html>

View File

@ -1,97 +0,0 @@
<!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"
}
});
function Archive(text) {
this.files = [];
this.offset = 0;
this.offset = this.parseTarChunk(text, this.offset)
}
Archive.prototype = {
parseTarNumber: function parseTarNumber(text) {
// if (text.charCodeAt(0) & 0x80 == 1) {
// GNU tar 8-byte binary big-endian number
// } else {
return parseInt(text, 8);
// }
},
parseTarHeader: function parseTarHeader(text, offset) {
var i = offset || 0;
var h = {};
h.filename = text.substring(i, i+=100).split("\0", 1)[0];
h.mode = text.substring(i, i+=8).split("\0", 1)[0];
h.uid = text.substring(i, i+=8).split("\0", 1)[0];
h.gid = text.substring(i, i+=8).split("\0", 1)[0];
h.length = this.parseTarNumber(text.substring(i, i+=12));
h.lastModified = text.substring(i, i+=12).split("\0", 1)[0];
h.checkSum = text.substring(i, i+=8).split("\0", 1)[0];
h.fileType = text.substring(i, i+=1).split("\0", 1)[0];
h.linkName = text.substring(i, i+=100).split("\0", 1)[0];
return h;
},
parseTarChunk: function parseTarChunk(text, offset) {
while (text.length >= offset + 512) {
var header = this.files.length == 0 ? null : this.files[this.files.length-1];
if (header && header.data == null) {
if (offset + header.length <= text.length) {
header.data = text.substring(offset, offset+header.length);
offset += 512 * Math.ceil(header.length / 512);
} else { // not loaded yet
break;
}
} else {
var header = this.parseTarHeader(text, offset);
if (header.length > 0 || header.filename != '') {
this.files.push(header);
offset += 512;
header.offset = offset;
} else { // empty header, stop processing
offset = text.length;
}
}
}
return offset;
}
};
require(["src/fs"], function(IDBFS) {
var xhr = new XMLHttpRequest();
xhr.open('GET', './archive.tar', true);
// xhr.responseType = 'arraybuffer';
xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.setRequestHeader("Content-Type", "text/plain");
xhr.onload = function(e) {
// var uInt8Array = new Uint8Array(this.response);
var archive = new Archive(this.response);
archive.files.forEach(function(file) {
console.log(file.filename);
});
};
xhr.send(null);
function unpack(archive) {
}
});
</script>
</html>

View File

@ -1,152 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="stdout"></div>
</body>
<script src="../dist/idbfs.min.js"></script>
<script src="../lib/buffer.js"></script>
<script>
var LF_NORMAL = "0",
LF_LINK = "1",
LF_SYMLINK = "2",
LF_CHR = "3",
LF_BLK = "4",
LF_DIR = "5",
LF_FIFO = "6",
LF_CONTIG = "7";
function Archive(buffer) {
this.files = [];
this.offset = 0;
this.offset = this.parseTarChunk(buffer, this.offset)
}
Archive.prototype = {
parseTarHeader: function parseTarHeader(buffer) {
var text = new Buffer(buffer).toString();
var i = 0;
var h = {};
h.filename = text.substring(i, i+=100).split("\0", 1)[0];
h.mode = text.substring(i, i+=8).split("\0", 1)[0];
h.uid = text.substring(i, i+=8).split("\0", 1)[0];
h.gid = text.substring(i, i+=8).split("\0", 1)[0];
h.length = parseInt(text.substring(i, i+=12), 8);
h.lastModified = text.substring(i, i+=12).split("\0", 1)[0];
h.checkSum = text.substring(i, i+=8).split("\0", 1)[0];
h.fileType = text.substring(i, i+=1).split("\0", 1)[0];
h.linkName = text.substring(i, i+=100).split("\0", 1)[0];
return h;
},
parseTarChunk: function parseTarChunk(buffer, offset) {
while (buffer.length >= offset + 512) {
var header = this.files.length == 0 ? null : this.files[this.files.length-1];
if (header && header.data == null) {
if (offset + header.length <= buffer.length) {
header.data = buffer.subarray(offset, offset+header.length);
offset += 512 * Math.ceil(header.length / 512);
} else { // not loaded yet
break;
}
} else {
var header = this.parseTarHeader(buffer.subarray(offset, offset+512));
if (header.length > 0 || header.filename != '') {
this.files.push(header);
offset += 512;
header.offset = offset;
} else { // empty header, stop processing
offset = buffer.length;
}
}
}
return offset;
}
};
var xhr = new XMLHttpRequest();
xhr.open('GET', './archive.tar', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
var buffer = new Uint8Array(this.response);
var archive = new Archive(buffer);
IDBFS.mount("default", "format", function(error, fs) {
if(error) {
return console.error(error);
}
function stat(path) {
fs.stat(path, function(error, result) {
if(error) {
return console.error(error);
}
console.info("stat " + path, result);
});
}
function ls(dir) {
fs.open(dir, "", "R", function(error, fd) {
contents = [];
fd.readdir(contents, undefined, function(error, count, contents) {
if(error) {
return console.error(error);
}
console.info("ls " + dir, contents);
fs.close(fd);
});
});
}
var i = 0;
function createNextFile(error) {
if(error) {
return console.error(error);
} else if(i >= archive.files.length) {
stat("/");
ls("/");
stat("/archive");
ls("/archive");
stat("/archive/js");
ls("/archive/js");
stat("/archive/js/gl-matrix.js");
stat("/archive/img");
ls("/archive/img");
stat("/archive/img/firefox_logo-only_RGB-300dpi.jpg");
} else {
var file = archive.files[i ++];
if(LF_DIR == file.fileType) {
fs.mkdir(file.filename, createNextFile);
} else {
fs.open(file.filename, "CREATE", "RW", function(error, fd) {
if(error) {
return console.error(error);
}
fd.write(file.data, function(error, bytes_written, buffer) {
if(error) {
return console.error(error);
}
fs.close(fd, createNextFile);
});
});
}
}
}
createNextFile();
});
};
xhr.send(null);
function unpack(archive) {
}
</script>
</html>