Commit 54e878be authored by root's avatar root

wip

parent f641ef58
<html>
<head>
<script type="text/javascript" src="../node_modules/rsvp/dist/rsvp-2.0.4.js">
</script>
<script type="text/javascript" src="../dist/jio-latest.js"></script>
</head>
<body> <p>jio example, see console</p>
<script type="text/javascript">
(
function (jio) {
var storage = jIO.createJIO({"type": "indexeddb", "database": "foo"});
console.log(storage);
function foo(message) {
return storage.put("doc1", message)
.push(function () { return storage.put("doc2", {"hello again":"hi again"})})
.push(function (result) {
console.log(result);
return storage.get("doc1");
})
.push(function (result) {console.log(result) })
.push(undefined, function (error) {
console.log(error);});
}
return foo({"hello":"hi"});
}(jIO)
);
</script>
<p> more text </p>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="../node_modules/rsvp/dist/rsvp-2.0.4.js">
</script>
<script type="text/javascript" src="../dist/jio-latest.js"></script>
</head>
<body> <p>jio example, see console</p>
<script type="text/javascript">
(function (jIO) { // create a new jIO storage
var jio_instance = jIO.createJIO({type:"memory"});
<!-- var jio_instance = jIO.createJIO({type: "indexeddb", "database": "foo"}); -->
// post the metadata for "myVideo"
return jio_instance.put("document", {
title: "My Video",
type: "MovingImage",
format: "video/ogg",
description: "Images Compilation" })
// post a thumbnail attachment
.push(function () {
return jio_instance.putAttachment(
"document",
"thumbnail",
new Blob(["img.png"],{type: "image/jpeg"})
)
})
// post video attachment
.push(function () {
return jio_instance.putAttachment(
"document",
"video",
new Blob(["vid.txt"], {type: "video/ogg"})
)
})
// catch any errors and throw
.push(undefined, function(error) {
console.log(error); throw error;
});
}(jIO));
</script>
<p> more text </p>
</body>
</html>
(function (jIO) { // create a new jIO storage
var jio_instance = jIO.createJIO({type: "local"});
// post the metadata for "myVideo"
return jio_instance.put("document", {
title: "My Video",
type: "MovingImage",
format: "video/ogg",
description: "Images Compilation" })
// post a thumbnail attachment
.push(function () {
return jio_instance.putAttachment(
"document",
"thumbnail",
new Blob([my_image],
{type: "image/jpeg"})
})
// post video attachment
.push(function () {
return jio_instance.putAttachment(
"document",
"video",
new Blob([my_video],
{type: "video/ogg"})
})
// catch any errors and throw
.push(undefined, function(error) {
console.log(error); throw error;
});
}(jIO));
<html>
<head>
<script type="text/javascript" src="../node_modules/rsvp/dist/rsvp-2.0.4.js">
</script>
<script type="text/javascript" src="../dist/jio-latest.js"></script>
</head>
<body> <p>Retrieving local data:</p>
<script type="text/javascript">
(function (jIO) {
// create a new jIO storage
var jio_instance = jIO.createJIO({type: "indexeddb", "database":"foo"});
// post the metadata for "myVideo"
return jio_instance.put("document", {
title: "My Video"
})
// post a thumbnail attachment
.push(function () {
return jio_instance.putAttachment(
"document",
"thumbnail",
new Blob(["img.jpg"], {type: "image/jpeg"}))
})
.push(function () {
return jio_instance.getAttachment(
"document",
"thumbnail",
{format:"text"})
})
.push(function (res) {console.log(res)})
// catch any errors and throw
.push(undefined, function(error) {
console.log(error);
throw error;
});
}(jIO));
</script>
<p> more text </p>
</body>
</html>
test test image
<html>
<head>
<script type="text/javascript" src="../node_modules/rsvp/dist/rsvp-2.0.4.js">
</script>
<script type="text/javascript" src="../dist/jio-latest.js"></script>
</head>
<body> <p>jio example, see console</p>
<script type="text/javascript">
(function (jIO) {
var jio = jIO.createJIO({
type: "bryan",
sub_storage: {
type: "uuid",
sub_storage: {
//type: "memory"
type: "indexeddb",
database: "testdb_2"
}
}
}),
not_bryan = jIO.createJIO({
type: "uuid",
sub_storage: {
//type: "memory"
type: "indexeddb",
database: "testdb_2"
}
});
jio.put("A", {
"k": "v0"
})
.push(function () {
jio.put("A", {
"k": "v1"
})
})
.push(function () {
jio.put("A", {
"k": "v2"
})
})
.push(function () {
jio.put("A", {
"k": "v3"
})
})
.push(function () {
return not_bryan.buildQuery({
query: ""
});
})
.push(function (results) {
console.log(results);
},
function (err) {
console.log(err);
});
}(jIO));
</script>
<p> more text </p>
</body>
</html>
\ No newline at end of file
test test video test
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Coverage Scenario</title>
<script src="../node_modules/rsvp/dist/rsvp-2.0.4.js"></script>
<script src="../dist/jio-latest.js"></script>
<link rel="stylesheet" href="../node_modules/grunt-contrib-qunit/test/libs/qunit.css" type="text/css" media="screen"/>
<script src="../node_modules/grunt-contrib-qunit/test/libs/qunit.js" type="text/javascript"></script>
<script src="scenario_officejs.js"></script>
</head>
<body>
<h1 id="qunit-header">OfficeJS Coverage Scenario</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</body>
</html>
......@@ -156,9 +156,12 @@
local_sub_storage: {
type: "history",
sub_storage: {
type: "uuid",
type: "query",
sub_storage: {
type: "memory"
type: "uuid",
sub_storage: {
type: "memory"
}
}
}
},
......
......@@ -133,7 +133,6 @@
throw error;
}
}
return substorage.buildQuery(sub_options)
// Include docs if needed
......@@ -198,6 +197,7 @@
if (options.select_list) {
options.select_list.push("__id");
}
console.log("query:",options.query);
result = jIO.QueryFactory.create(options.query || "",
context._key_schema).
exec(data_rows, options);
......
......@@ -228,7 +228,6 @@
number_queue) {
var result_promise_list = [],
i;
function pushAndExecute(queue) {
queue
.push(function () {
......@@ -1297,12 +1296,12 @@
}
ReplicateStorage.prototype.repair = function () {
var context = this,
argument_list = arguments,
skip_document_dict = {},
skip_deleted_document_dict = {},
cache = {};
return new RSVP.Queue()
.push(function () {
// Ensure that the document storage is usable
......@@ -1425,6 +1424,7 @@
context._check_remote_attachment_deletion) {
// Attachments are synchronized if and only if their parent document
// has been also marked as synchronized.
return context._signature_sub_storage.allDocs({
select_list: ['hash', 'attachment_hash', 'from_local']
})
......@@ -1433,6 +1433,7 @@
local_argument_list = [],
row,
len = result.data.total_rows;
//skip_deleted_document_dict = {};
for (i = 0; i < len; i += 1) {
row = result.data.rows[i];
......
This diff is collapsed.
/*jslint nomen: true*/
/*global jIO, RSVP*/
(function (jIO, RSVP) {
"use strict";
/**
* The jIO SafeRepairStorage extension
*
* @class SafeRepairStorage
* @constructor
*/
function SafeRepairStorage(spec) {
this._sub_storage = jIO.createJIO(spec.sub_storage);
this._id_dict = {};
}
SafeRepairStorage.prototype.get = function () {
return this._sub_storage.get.apply(this._sub_storage, arguments);
};
SafeRepairStorage.prototype.allAttachments = function () {
return this._sub_storage.allAttachments.apply(this._sub_storage, arguments);
};
SafeRepairStorage.prototype.post = function () {
return this._sub_storage.post.apply(this._sub_storage, arguments);
};
SafeRepairStorage.prototype.put = function (id, doc) {
var storage = this;
return this._sub_storage.put.apply(this._sub_storage, arguments)
.push(undefined, function (error) {
if (error instanceof jIO.util.jIOError &&
error.status_code === 403) {
if (storage._id_dict[id]) {
return storage._sub_storage.put(storage._id_dict[id], doc);
}
return storage._sub_storage.post(doc)
.push(function (sub_id) {
storage._id_dict[id] = sub_id;
return sub_id;
});
}
});
};
SafeRepairStorage.prototype.remove = function () {
return;
};
SafeRepairStorage.prototype.getAttachment = function () {
return this._sub_storage.getAttachment.apply(this._sub_storage, arguments);
};
SafeRepairStorage.prototype.putAttachment = function (id, attachment_id,
attachment) {
var storage = this;
return this._sub_storage.putAttachment.apply(this._sub_storage, arguments)
.push(undefined, function (error) {
if (error instanceof jIO.util.jIOError &&
error.status_code === 403) {
return new RSVP.Queue()
.push(function () {
if (storage._id_dict[id]) {
return storage._id_dict[id];
}
return storage._sub_storage.get(id)
.push(function (doc) {
return storage._sub_storage.post(doc);
});
})
.push(function (sub_id) {
storage._id_dict[id] = sub_id;
return storage._sub_storage.putAttachment(sub_id, attachment_id,
attachment);
});
}
});
};
SafeRepairStorage.prototype.removeAttachment = function () {
return;
};
SafeRepairStorage.prototype.repair = function () {
return this._sub_storage.repair.apply(this._sub_storage, arguments);
};
SafeRepairStorage.prototype.hasCapacity = function (name) {
return this._sub_storage.hasCapacity(name);
};
SafeRepairStorage.prototype.buildQuery = function () {
return this._sub_storage.buildQuery.apply(this._sub_storage,
arguments);
};
jIO.addStorage('saferepair', SafeRepairStorage);
}(jIO, RSVP));
\ No newline at end of file
......@@ -1414,13 +1414,20 @@
})
.push(function () {
return RSVP.all([
jio.allDocs(),
jio.allDocs({query: "title: version0"}),
jio.allDocs({limit: [0, 1]}),
jio.allDocs({})
jio.allDocs({select_list: ['title']}),
jio.allDocs({
query: "title: version0",
select_list: ['title']
}),
jio.allDocs({
limit: [0, 1],
select_list: ['title']
}),
jio.allDocs({select_list: ['title']})
]);
})
.push(function (results) {
console.log(results);
var ind = 0;
for (ind = 0; ind < results.length - 1; ind += 1) {
deepEqual(results[ind],
......@@ -1436,12 +1443,14 @@
"Exactly one result returned");
deepEqual(results.data.rows[0], {
doc: {},
value: {},
value: {
title: "version0"
},
//timestamp: timestamp,
id: "doc"
},
"Correct document format is returned."
);
);///
return not_revision.allDocs();
})
.push(function (results) {
......@@ -1609,6 +1618,7 @@
);
})
.push(function () {
console.log("about to fail");
return revision.allDocs({
query: "",
select_list: ["title", "subtitle"]
......@@ -1690,7 +1700,7 @@
"A different storage type can retrieve all versions as expected.");
})
.fail(function (error) {
//console.log(error);
console.log(error);
ok(false, error);
})
.always(function () {start(); });
......@@ -1826,14 +1836,13 @@
.push(function () {
return jio.allDocs({
query: "NOT (date: > 2)",
select_list: ["date", "non-existent-key"],
sort_on: [["date", "ascending"],
["non-existent-key", "ascending"]
]
select_list: ["date"],//, "non-existent-key"],
sort_on: [["date", "ascending"]]//,
//["non-existent-key", "ascending"]]
});
})
.push(function (results) {
equal(results.data.total_rows, 3);
equal(results.data.total_rows, 3, "Correct number of results");
deepEqual(results.data.rows, [
{
doc: {},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment