remove outdated examples

This commit is contained in:
Alan K 2014-08-25 20:12:18 -04:00
parent 3134c0be46
commit 08f4b7e528
10 changed files with 0 additions and 4092 deletions

View File

@ -1,163 +0,0 @@
#indexedDBViewer {
padding: 0px;
margin: 0px;
font-family: Courier;
font-size: 12px;
width: 100%;
position: absolute;
bottom: 0px;
right: 0px;
height: 100%;
z-index: 999999;
background-color: lightgray;
overflow: hidden;
}
#indexedDBViewer li {
padding: 0px;
margin: 0px;
list-style: none;
}
#indexedDBViewer ul {
list-style: none;
margin: 0px;
padding: 0px 0px 0px 15px;
}
#indexedDBViewer h1 {
padding: 0px 0px 5px 0px;
margin: 0px;
font-size: 14px;
}
#indexedDBViewerHeader {
height: 15px;
width: 100%;
cursor: row-resize;
text-align: right;
}
#indexedDBViewerHeader span {
cursor: pointer;
height: 13px;
width: 13px;
padding-left: 0px;
padding-right: 0px;
border: 1px solid black;
display: inline-block;
text-align: center;
}
#indexedDBViewerNavigation {
display: inline-block;
height: 100%;
width: auto;
min-width: 200px;
vertical-align: top;
padding: 2px 2px 2px 2px;
overflow: auto;
}
#indexedDBViewerContent {
display: inline-block;
height: 100%;
width: auto;
min-width: 400px;
vertical-align: top;
padding: 2px 2px 2px 12px;
overflow: auto;
}
#indexedDBViewerContentObjectStoresTable {
width: 100%
}
#indexedDBViewerContentObjectStoresRowHeaderName {
width: auto;
min-width: 100px;
text-align: left;
}
#indexedDBViewerContentObjectStoresRowHeaderKeyPath {
width: 100px;
text-align: left;
}
#indexedDBViewerContentObjectStoresRowHeaderAutoIncrement {
width: 100px;
text-align: left;
}
#indexedDBViewerContentIndexTable {
width: 100%
}
#indexedDBViewerContentIndexRowHeaderName {
width: auto;
min-width: 150px;
text-align: left;
}
#indexedDBViewerContentIndexRowHeaderKeyPath {
width: auto;
min-width: 100px;
text-align: left;
}
#indexedDBViewerContentIndexRowHeaderObjectStore {
width: auto;
min-width: 100px;
text-align: left;
}
#indexedDBViewerContentIndexRowHeaderMultiEntry {
width: 100px;
text-align: left;
}
#indexedDBViewerContentIndexRowHeaderUnique {
width: 100px;
text-align: left;
}
#indexedDBViewerContentObjectStoreRowHeaderKey {
width: auto;
min-width: 100px;
text-align: left;
}
#indexedDBViewerContentObjectStoreRowHeaderValue {
width: auto;
min-width: 400px;
text-align: left;
}
#indexedDBViewerContentIndexRowHeaderKey {
width: auto;
min-width: 100px;
text-align: left;
}
#indexedDBViewerContentIndexRowHeaderPrimaryKey {
width: auto;
min-width: 100px;
text-align: left;
}
#indexedDBViewerContentIndexRowHeaderValue {
width: auto;
min-width: 400px;
text-align: left;
}
#indexedDBViewerContentObjectStoreTable td, #indexedDBViewerContentIndexTable td {
vertical-align: top;
text-align: left;
padding: 0px;
margin: 0px;
}
#indexedDBViewer .clickable {
cursor: pointer;
}

View File

@ -1,317 +0,0 @@
/// <reference path="jquery-1.7.2.js" />
/// <reference path="Linq2IndexedDB.js" />
$(function () {
function initializeViewer() {
var placeholder = $("#indexedDBViewer");
var dbName = placeholder.attr("data-dbName");
createHeader('indexedDBViewerHeader', placeholder);
var navigation = retrieveOrCreateElement('indexedDBViewerNavigation', 'div', placeholder);
var menu = retrieveOrCreateElement('indexedDBViewerMenu', 'ul', navigation);
var menuOverview = expandableListItem('indexedDBViewerMenuOverview', dbName, menu, viewDb, { dbName: dbName, objectStore: null, index: null });
navigation.addClass('nav');
linq2indexedDB.prototype.core.db(dbName).then(function () {
var connection = arguments[0][0];
linq2indexedDB.prototype.core.dbStructureChanged.addListener(linq2indexedDB.prototype.core.databaseEvents.databaseBlocked, function () {
connection.close();
});
var menuObjectStores = retrieveOrCreateElement('indexedDBViewerMenuObjectStores', 'ul', menuOverview);
for (var i = 0; i < connection.objectStoreNames.length; i++) {
var storeName = connection.objectStoreNames[i];
var menuObjectStore = expandableListItem('indexedDBViewerMenuObjectStore' + storeName, storeName, menuObjectStores, viewDb, { dbName: dbName, objectStore: storeName, index: null });
linq2indexedDB.prototype.core.objectStore(linq2indexedDB.prototype.core.transaction(connection, storeName, linq2indexedDB.prototype.core.transactionTypes.READ_ONLY, false), storeName).then(function (args) {
var store = args[1];
var menuObjectStore = retrieveOrCreateElement('indexedDBViewerMenuObjectStore' + storeName, 'li', menuObjectStores);
var menuIndexes = retrieveOrCreateElement('indexedDBViewerMenuObjectStore' + store.name + 'Indexes', 'ul', menuObjectStore);
for (var j = 0; j < store.indexNames.length; j++) {
var indexName = store.indexNames[i];
expandableListItem('indexedDBViewerMenuObjectStore' + store.name + 'Index' + indexName, indexName, menuIndexes, viewDb, { dbName: dbName, objectStore: store.name, index: indexName });
}
});
}
}, null, function (args) {
if (args[1].type == "upgradeneeded") {
args[0].abort();
}
});
}
function viewDb(e) {
var dbName = e.data.dbName;
var objectStore = e.data.objectStore;
var index = e.data.index;
var content = retrieveOrCreateElement('indexedDBViewerContent', 'div', $("#indexedDBViewer"));
content.empty();
if (objectStore != null) {
if (index != null) {
retrieveOrCreateElement('indexedDBViewerContentGeneral', 'h1', content).text(index);
}
else {
retrieveOrCreateElement('indexedDBViewerContentGeneral', 'h1', content).text(objectStore);
}
}
linq2indexedDB.prototype.core.db(dbName).then(function () {
var connection = arguments[0][0];
if (objectStore == null) {
retrieveOrCreateElement('indexedDBViewerContentGeneral', 'h1', content).text("General");
retrieveOrCreateElement('indexedDBViewerContentGeneralName', 'span', content).text("Name: " + connection.name);
content.append("<br/>");
retrieveOrCreateElement('indexedDBViewerContentGeneralVersion', 'span', content).text("Version: " + connection.version);
content.append("<br/>");
content.append("<br/>");
retrieveOrCreateElement('indexedDBViewerContentObjectStores', 'h1', content).text("Object stores");
retrieveOrCreateElement('indexedDBViewerContentObjectStoresTable', 'table', content);
content.append("<br/>");
content.append("<br/>");
retrieveOrCreateElement('indexedDBViewerContentIndex', 'h1', content).text("Indexes");
retrieveOrCreateElement('indexedDBViewerContentIndexTable', 'table', content);
content.append("<br/>");
}
linq2indexedDB.prototype.core.dbStructureChanged.addListener(linq2indexedDB.prototype.core.databaseEvents.databaseBlocked, function () {
connection.close();
});
for (var i = 0; i < connection.objectStoreNames.length; i++) {
var storeName = connection.objectStoreNames[i];
linq2indexedDB.prototype.core.objectStore(linq2indexedDB.prototype.core.transaction(connection, storeName, linq2indexedDB.prototype.core.transactionTypes.READ_ONLY, false), storeName).then(function (args) {
var store = args[1];
if (objectStore == null) {
viewObjectStoreDefinition(store.name, store.keyPath, store.autoIncrement, content);
}
else {
if (index == null && store.name == objectStore) {
linq2indexedDB.prototype.core.cursor(store).then(function () {
}, function () {
}, function (args1) {
var keyValue = args1[0];
viewObjectStoreData(keyValue.key, keyValue.data, content);
});
}
}
for (var j = 0; j < store.indexNames.length; j++) {
linq2indexedDB.prototype.core.index(store, store.indexNames[j], false).then(function (args1) {
var ix = args1[1];
if (objectStore == null) {
viewIndexDefinition(ix.name, ix.keyPath, ix.objectStore.name, ix.multiEntry || ix.multiRow, ix.unique, content);
}
else {
if (index != null && ix.name == index) {
linq2indexedDB.prototype.core.cursor(ix).then(function () {
var x = 1;
}, function () {
}, function (args1) {
var keyValue = args1[0];
viewIndexData(args1[1].key, args1[1].primaryKey, keyValue.data, content);
});
}
}
});
}
});
}
});
}
function viewObjectStoreDefinition(name, keyPath, autoIncrement, parent) {
var table = retrieveOrCreateElement('indexedDBViewerContentObjectStoresTable', 'table', parent);
var headerRow = retrieveOrCreateElement('indexedDBViewerContentObjectStoresRowHeader', 'tr', table);
retrieveOrCreateElement('indexedDBViewerContentObjectStoresRowHeaderName', 'th', headerRow).text("name");
retrieveOrCreateElement('indexedDBViewerContentObjectStoresRowHeaderKeyPath', 'th', headerRow).text("keyPath");
retrieveOrCreateElement('indexedDBViewerContentObjectStoresRowHeaderAutoIncrement', 'th', headerRow).text("autoIncrement");
var dataRow = retrieveOrCreateElement('indexedDBViewerContentObjectStoresRow' + name, 'tr', table);
retrieveOrCreateElement('indexedDBViewerContentObjectStoresRow' + name + 'Name', 'td', dataRow).text(name);
retrieveOrCreateElement('indexedDBViewerContentObjectStoresRow' + name + 'KeyPath', 'td', dataRow).text(keyPath);
retrieveOrCreateElement('indexedDBViewerContentObjectStoresRow' + name + 'AutoIncrement', 'td', dataRow).text(autoIncrement);
}
function viewIndexDefinition(name, keyPath, objectStore, multiEntry, unique, parent) {
var table = retrieveOrCreateElement('indexedDBViewerContentIndexTable', 'table', parent);
var headerRow = retrieveOrCreateElement('indexedDBViewerContentIndexRowHeader', 'tr', table);
retrieveOrCreateElement('indexedDBViewerContentIndexRowHeaderName', 'th', headerRow).text("name");
retrieveOrCreateElement('indexedDBViewerContentIndexRowHeaderKeyPath', 'th', headerRow).text("keyPath");
retrieveOrCreateElement('indexedDBViewerContentIndexRowHeaderObjectStore', 'th', headerRow).text("objectStore");
retrieveOrCreateElement('indexedDBViewerContentIndexRowHeaderMultiEntry', 'th', headerRow).text("multiEntry");
retrieveOrCreateElement('indexedDBViewerContentIndexRowHeaderUnique', 'th', headerRow).text("unique");
var dataRow = retrieveOrCreateElement('indexedDBViewerContentIndexRow' + name, 'tr', table);
retrieveOrCreateElement('indexedDBViewerContentIndexRow' + name + 'Name', 'td', dataRow).text(name);
retrieveOrCreateElement('indexedDBViewerContentIndexRow' + name + 'KeyPath', 'td', dataRow).text(keyPath);
retrieveOrCreateElement('indexedDBViewerContentIndexRow' + name + 'ObjectStore', 'td', dataRow).text(objectStore);
retrieveOrCreateElement('indexedDBViewerContentIndexRow' + name + 'MultiEntry', 'td', dataRow).text(multiEntry);
retrieveOrCreateElement('indexedDBViewerContentIndexRow' + name + 'Unique', 'td', dataRow).text(unique);
}
function viewObjectStoreData(key, value, parent) {
var table = retrieveOrCreateElement('indexedDBViewerContentObjectStoreTable', 'table', parent);
var headerRow = retrieveOrCreateElement('indexedDBViewerContentObjectStoreRowHeader', 'tr', table);
retrieveOrCreateElement('indexedDBViewerContentObjectStoreRowHeaderKey', 'th', headerRow).text("key");
retrieveOrCreateElement('indexedDBViewerContentObjectStoreRowHeaderValue', 'th', headerRow).text("value");
var dataRow = retrieveOrCreateElement('indexedDBViewerContentObjectStoreRow' + key, 'tr', table);
viewData(key, retrieveOrCreateElement('indexedDBViewerContentObjectStoreRow' + key + 'Key', 'td', dataRow));
viewData(value, retrieveOrCreateElement('indexedDBViewerContentObjectStoreRow' + key + 'Value', 'td', dataRow));
}
function viewIndexData(key, primaryKey, value, parent) {
var table = retrieveOrCreateElement('indexedDBViewerContentIndexTable', 'table', parent);
var headerRow = retrieveOrCreateElement('indexedDBViewerContentIndexRowHeader', 'tr', table);
retrieveOrCreateElement('indexedDBViewerContentIndexRowHeaderKey', 'th', headerRow).text("key");
retrieveOrCreateElement('indexedDBViewerContentIndexRowHeaderPrimaryKey', 'th', headerRow).text("primary key");
retrieveOrCreateElement('indexedDBViewerContentIndexRowHeaderValue', 'th', headerRow).text("value");
var dataRow = retrieveOrCreateElement('indexedDBViewerContentIndexRow' + primaryKey, 'tr', table);
viewData(key, retrieveOrCreateElement('indexedDBViewerContentIndexRow' + primaryKey + 'Key', 'td', dataRow));
viewData(primaryKey, retrieveOrCreateElement('indexedDBViewerContentIndexRow' + primaryKey + 'PrimaryKey', 'td', dataRow));
viewData(value, retrieveOrCreateElement('indexedDBViewerContentIndexRow' + primaryKey + 'Value', 'td', dataRow));
}
function viewData(value, parent, propName) {
var text;
if (propName) {
text = propName + value;
}
else {
parent = retrieveOrCreateElement(null, 'ul', parent);
text = value;
}
if (typeof (value) === "object" && !(value instanceof Date)) {
var object = expandableListItem(null, text, parent);
var properties = retrieveOrCreateElement(null, 'ul', object);
for (prop in value) {
viewData(value[prop], properties, prop + ": ");
}
object.find('.expendable')[0].click();
}
else {
retrieveOrCreateElement(null, 'li', parent).text(text);
}
}
function expandableListItem(id, text, parent, clickEvent, clickEventData) {
var li = retrieveOrCreateElement(id, 'li', parent);
var col = retrieveOrCreateElement(null, 'span', li);
col.text(' - ');
col.data('status', 'open');
col.click(function () {
if ($(this).data('status') == 'closed') {
$($($(this)[0].parentElement).find('ul')[0]).show();
col.text(' - ');
col.data('status', 'open');
}
else if ($(this).data('status') == 'open') {
$($($(this)[0].parentElement).find('ul')[0]).hide();
col.text(' + ');
col.data('status', 'closed');
}
});
col.addClass("clickable");
col.addClass("expendable");
var item = retrieveOrCreateElement(null, 'span', li);
item.text(text);
if (clickEvent) {
item.click(clickEventData, clickEvent);
item.addClass("clickable");
}
return li;
}
function createHeader(id, parent) {
var header = retrieveOrCreateElement(id, 'div', parent);
var col = retrieveOrCreateElement(null, 'span', header);
col.text(' - ');
col.data('status', 'open');
col.addClass("clickable");
col.addClass("expendable");
col.click(function () {
if ($(this).data('status') == 'closed') {
$('#indexedDBViewer').height(170);
$('#indexedDBViewer').width('100%');
$('#indexedDBViewerNavigation').show();
$('#indexedDBViewerContent').show();
col.text(' - ');
col.data('status', 'open');
}
else if ($(this).data('status') == 'open') {
$('#indexedDBViewer').height($(this).outerHeight());
$('#indexedDBViewer').width($(this).outerWidth());
$('#indexedDBViewerNavigation').hide();
$('#indexedDBViewerContent').hide();
col.text(' + ');
col.data('status', 'closed');
}
});
}
function retrieveOrCreateElement(id, element, parent) {
var el;
if (id && id != null && id != '') {
if ($('#' + id).length > 0) {
el = $('#' + id);
} else {
el = $('<' + element + ' id="' + id + '"></' + element + '>');
parent.append(el);
}
}
else {
el = $('<' + element + '></' + element + '>');
parent.append(el);
}
return el;
}
initializeViewer();
// mousedown, mousemove, mouseup and mouseleave for resizing the placeholder
$(window).bind('mousedown', function (event) {
var location = $(window).height() - $("#indexedDBViewer").height();
if ((location - 2) <= event.pageY && event.pageY <= (location + 5)) {
$(window).bind('mousemove', resize);
}
});
$(window).bind('mouseup', function () {
$(window).unbind('mousemove', resize);
});
$(window).bind('mouseleave', function () {
$(window).unbind('mousemove', resize);
});
function resize(event) {
var pageHeight = $(window).height();
if (pageHeight - event.pageY >= 50) {
$("#indexedDBViewer").height(pageHeight - event.pageY);
var height = $("#indexedDBViewer").height() - $("#indexedDBViewerHeader").height();
$("#indexedDBViewerNavigation").height(height);
$("#indexedDBViewerContent").height(height);
}
}
});

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -1,149 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<progress id="progress" value=0></progress>
<div id="output"></div>
<div id="stderr"></div>
</body>
<script src="../dist/filer.js"></script>
<script type="text/javascript" src="https://rawgithub.com/tmcw/simple-statistics/master/src/simple_statistics.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="../lib/require.js"></script>
<script>
require.config({
baseUrl: "../lib",
paths: {
"src": "../src",
"tests": "../tests",
"Filer": "../src/index",
"util": "../tests/lib/test-utils"
}
});
function nextTick(cb) {
setTimeout(cb, 0);
}
function parse_query() {
var query = window.location.search.substring(1);
var parsed = {};
query.split('&').forEach(function(pair) {
pair = pair.split('=');
var key = decodeURIComponent(pair[0]);
var value = decodeURIComponent(pair[1]);
parsed[key] = value;
});
return parsed;
}
require(["Filer", "util"], function(Filer, util) {
function time(test, cb) {
var start = performance.now();
function done() {
var end = performance.now();
cb(end - start);
}
test(done);
}
var random_data = new Uint8Array(1024); // 1kB buffer
var read_buffer = new Uint8Array(1024);
function run(iter) {
iter = (undefined == iter) ? 0 : iter;
function before() {
util.setup(function() {
nextTick(during);
});
}
function during() {
var fs = util.fs();
window.crypto.getRandomValues(random_data);
time(function(done) {
fs.mkdir('/tmp', function(err) {
fs.stat('/tmp', function(err, stats) {
fs.open('/tmp/test', 'w', function(err, fd) {
fs.write(fd, random_data, null, null, null, function(err, nbytes) {
fs.close(fd, function(err) {
fs.stat('/tmp/test', function(err, stats) {
fs.open('/tmp/test', 'r', function(err, fd) {
fs.read(fd, read_buffer, null, null, null, function(err, nbytes) {
fs.close(fd, function(err) {
fs.unlink('/tmp/test', function(err) {
done();
});});});});});});});});});});
}, after);
}
function after(dt) {
util.cleanup(complete.bind(null, iter, dt));
}
before();
}
var results = [];
function complete(iter, result) {
results.push(result);
if(++iter < iterations) {
nextTick(run.bind(null, iter));
} else {
do_stats();
}
progress.value = iter;
}
function do_stats() {
var output = document.getElementById("output");
var stats = {
mean: ss.mean(results) + " ms",
min: ss.min(results),
max: ss.max(results),
med_abs_dev: ss.median_absolute_deviation(results),
};
var t = document.createElement("table");
var tbody = document.createElement("tbody");
var keys = Object.keys(stats);
keys.forEach(function(key) {
var row = document.createElement("tr");
var key_cell = document.createElement("td");
var key_cell_text = document.createTextNode(key);
key_cell.appendChild(key_cell_text);
row.appendChild(key_cell);
var val_cell = document.createElement("td");
var val_cell_text = document.createTextNode(stats[key]);
val_cell.appendChild(val_cell_text);
row.appendChild(val_cell);
tbody.appendChild(row);
});
t.appendChild(tbody);
output.appendChild(t);
}
var query = parse_query();
var iterations = query.iterations || 10;
var progress = document.getElementById("progress");
progress.max = iterations;
run();
});
</script>
</html>

View File

@ -1,31 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="stdout"></div>
</body>
<script src="../dist/filer.js"></script>
<script>
window.Filer = Filer;
var fs = new Filer.FileSystem({
name: 'local',
flags: ['FORMAT']
});
//var buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
//console.log('buffer', buffer);
//var data = new Uint8Array(buffer.length);
try {
fs.readdir('\u0000', function(error, files) {
if(error) throw error;
console.log('contents:', files);
});
} catch(e) {
console.error(e);
}
</script>
</html>

View File

@ -1,35 +0,0 @@
var write_buffer = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
var read_buffer = new Uint8Array(16);
var fs = new Filer.FileSystem('local');
fs.mkdir('/tmp');
fs.open('/tmp/', 'w+', function(error, fd) {
if(error) return console.error(error);
fs.write(fd, ...);
fs.read(fd, ...);
});
fs.then(
function() {
return this.mkdir('/tmp');
}
);
var fd = fs.open('/myfile.txt', fs.RW);
fd.then(
function() {
return this.write(write_buffer);
}
).then(
function(nbytes) {
this.seek(-nbytes);
return this.read(read_buffer);
}
).then(
function(nbytes) {
console.log(read_buffer);
}
);
});

View File

@ -1,14 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<link rel='stylesheet' href='IndexedDBViewer.css'></link>
</head>
<script src="jquery-1.10.0.min.js"></script>
<script src="Linq2IndexedDB.js"></script>
<script src="IndexedDBViewer.js"></script>
<body>
<div id="stdout"></div>
<div id="indexedDBViewer" data-dbName="local"></div>
</body>
</html>