Commit 93c5a742 authored by Sven Franck's avatar Sven Franck

jslint pass dummystorages.js

parent f6015801
/*global window, define */ /*jslint indent: 2, maxlen: 80, sloppy: true */
/*global setTimeout: true, window: true, define: true, jIO: true */
// Adds 5 dummy storages to JIO // Adds 5 dummy storages to JIO
// type: // type:
// - dummyallok // - dummyallok
...@@ -23,7 +24,7 @@ ...@@ -23,7 +24,7 @@
}; };
that.post = function (command) { that.post = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() "id": command.getDocId()
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
}; // end post }; // end post
that.put = function (command) { that.put = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() "id": command.getDocId()
...@@ -41,17 +42,16 @@ ...@@ -41,17 +42,16 @@
}; // end put }; // end put
that.putAttachment = function (command) { that.putAttachment = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() + "/" + "id": command.getDocId() + "/" + command.getAttachmentId()
command.getAttachmentId()
}); });
}, 100); // 100 ms, for jiotests simple job waiting }, 100); // 100 ms, for jiotests simple job waiting
}; // end putAttachment }; // end putAttachment
that.get = function (command) { that.get = function (command) {
window.setTimeout(function () { setTimeout(function () {
if (command.getAttachmentId()) { if (command.getAttachmentId()) {
return that.success('0123456789'); return that.success('0123456789');
} }
...@@ -62,27 +62,24 @@ ...@@ -62,27 +62,24 @@
}, 100); // 100 ms, for jiotests simple job waiting }, 100); // 100 ms, for jiotests simple job waiting
}; // end get }; // end get
that.allDocs = function (command) { that.allDocs = function () {
window.setTimeout(function () { setTimeout(function () {
that.error({ that.error({
"status": 405, "status": 405,
"statusText": "Method Not Allowed", "statusText": "Method Not Allowed",
"error": "method_not_allowed", "error": "method_not_allowed",
"message": "Your are not allowed to use" + "message": "Your are not allowed to use" + "this command",
"this command", "reason": "LocalStorage forbids AllDocs" + "command executions"
"reason": "LocalStorage forbids AllDocs" +
"command executions"
}); });
}); });
}; // end allDocs }; // end allDocs
that.remove = function (command) { that.remove = function (command) {
window.setTimeout(function () { setTimeout(function () {
if (command.getAttachmentId()) { if (command.getAttachmentId()) {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() + "/" + "id": command.getDocId() + "/" + command.getAttachmentId()
command.getAttachmentId()
}); });
} else { } else {
that.success({ that.success({
...@@ -106,7 +103,7 @@ ...@@ -106,7 +103,7 @@
priv = {}; priv = {};
priv.error = function () { priv.error = function () {
window.setTimeout(function () { setTimeout(function () {
that.error({ that.error({
status: 0, status: 0,
statusText: 'Unknown Error', statusText: 'Unknown Error',
...@@ -117,37 +114,35 @@ ...@@ -117,37 +114,35 @@
}, 100); }, 100);
}; };
that.post = function (command) { that.post = function () {
priv.error(); priv.error();
}; // end post }; // end post
that.put = function (command) { that.put = function () {
priv.error(); priv.error();
}; // end put }; // end put
that.putAttachment = function (command) { that.putAttachment = function () {
priv.error(); priv.error();
}; // end put }; // end put
that.get = function (command) { that.get = function () {
priv.error(); priv.error();
}; // end get }; // end get
that.allDocs = function (command) { that.allDocs = function () {
window.setTimeout(function () { setTimeout(function () {
that.error({ that.error({
"status": 405, "status": 405,
"statusText": "Method Not Allowed", "statusText": "Method Not Allowed",
"error": "method_not_allowed", "error": "method_not_allowed",
"message": "Your are not allowed to use" + "message": "Your are not allowed to use" + "this command",
"this command", "reason": "LocalStorage forbids AllDocs" + "command executions"
"reason": "LocalStorage forbids AllDocs" +
"command executions"
}); });
}); });
}; // end allDocs }; // end allDocs
that.remove = function (command) { that.remove = function () {
priv.error(); priv.error();
}; // end remove }; // end remove
return that; return that;
...@@ -161,7 +156,7 @@ ...@@ -161,7 +156,7 @@
var that = my.basicStorage(spec, my); var that = my.basicStorage(spec, my);
that.post = function (command) { that.post = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() "id": command.getDocId()
...@@ -170,7 +165,7 @@ ...@@ -170,7 +165,7 @@
}; // end post }; // end post
that.put = function (command) { that.put = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() "id": command.getDocId()
...@@ -179,49 +174,43 @@ ...@@ -179,49 +174,43 @@
}; // end put }; // end put
that.putAttachment = function (command) { that.putAttachment = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() + "/" + "id": command.getDocId() + "/" + command.getAttachmentId()
command.getAttachmentId()
}); });
}, 100); }, 100);
}; // end put }; // end put
that.get = function (command) { that.get = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.error({ that.error({
"status": 404, "status": 404,
"statusText": "Not Found", "statusText": "Not Found",
"error": "not_found", "error": "not_found",
"message": "Document '" + command.getDocId() + "message": "Document '" + command.getDocId() + "' not found",
"' not found", "reason": "Document '" + command.getDocId() + "'does not exist"
"reason": "Document '" + command.getDocId() +
"'does not exist"
}); });
}, 100); }, 100);
}; // end get }; // end get
that.allDocs = function (command) { that.allDocs = function () {
window.setTimeout(function () { setTimeout(function () {
that.error({ that.error({
"status": 405, "status": 405,
"statusText": "Method Not Allowed", "statusText": "Method Not Allowed",
"error": "method_not_allowed", "error": "method_not_allowed",
"message": "Your are not allowed to use" + "message": "Your are not allowed to use" + "this command",
"this command", "reason": "LocalStorage forbids AllDocs" + "command executions"
"reason": "LocalStorage forbids AllDocs" +
"command executions"
}); });
}); });
}; // end allDocs }; // end allDocs
that.remove = function (command) { that.remove = function () {
window.setTimeout(function () { setTimeout(function () {
that.error({ that.error({
"status": 404, "status": 404,
"statusText": "Not Found", "statusText": "Not Found",
"error": "not_found", "error": "not_found",
"message": "Cannot remove an unexistant" + "message": "Cannot remove an unexistant" + "document",
"document",
"reason": "missing" // or deleted "reason": "missing" // or deleted
}); });
}, 100); }, 100);
...@@ -247,9 +236,8 @@ ...@@ -247,9 +236,8 @@
}; };
priv.doJob = function (command, if_ok_return) { priv.doJob = function (command, if_ok_return) {
// wait a little to simulate asynchronous operation // wait a little to simulate asynchronous operation
window.setTimeout(function () { setTimeout(function () {
priv.Try3OKElseFail(command.getTried(), priv.Try3OKElseFail(command.getTried(), if_ok_return);
if_ok_return);
}, 100); }, 100);
}; };
priv.Try3OKElseFail = function (tries, if_ok_return) { priv.Try3OKElseFail = function (tries, if_ok_return) {
...@@ -295,8 +283,7 @@ ...@@ -295,8 +283,7 @@
that.putAttachment = function (command) { that.putAttachment = function (command) {
priv.doJob(command, { priv.doJob(command, {
"ok": true, "ok": true,
"id": command.getDocId() + "/" + "id": command.getDocId() + "/" + command.getAttachmentId()
command.getAttachmentId()
}); });
}; // end put }; // end put
that.get = function (command) { that.get = function (command) {
...@@ -309,16 +296,14 @@ ...@@ -309,16 +296,14 @@
}); });
} }
}; // end get }; // end get
that.allDocs = function (command) { that.allDocs = function () {
window.setTimeout(function () { setTimeout(function () {
that.error({ that.error({
"status": 405, "status": 405,
"statusText": "Method Not Allowed", "statusText": "Method Not Allowed",
"error": "method_not_allowed", "error": "method_not_allowed",
"message": "Your are not allowed to use" + "message": "Your are not allowed to use" + "this command",
"this command", "reason": "LocalStorage forbids AllDocs" + "command executions"
"reason": "LocalStorage forbids AllDocs" +
"command executions"
}); });
}); });
}; // end allDocs }; // end allDocs
...@@ -326,8 +311,7 @@ ...@@ -326,8 +311,7 @@
if (command.getAttachmentId()) { if (command.getAttachmentId()) {
priv.doJob(command, { priv.doJob(command, {
"ok": true, "ok": true,
"id": command.getDocId() + "/" + "id": command.getDocId() + "/" + command.getAttachmentId()
command.getAttachmentId()
}); });
} else { } else {
priv.doJob(command, { priv.doJob(command, {
...@@ -351,7 +335,7 @@ ...@@ -351,7 +335,7 @@
}; };
}; };
that.post = function (command) { that.post = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() "id": command.getDocId()
...@@ -359,7 +343,7 @@ ...@@ -359,7 +343,7 @@
}, 100); // 100 ms, for jiotests simple job waiting }, 100); // 100 ms, for jiotests simple job waiting
}; // end post }; // end post
that.put = function (command) { that.put = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() "id": command.getDocId()
...@@ -367,16 +351,15 @@ ...@@ -367,16 +351,15 @@
}, 100); // 100 ms, for jiotests simple job waiting }, 100); // 100 ms, for jiotests simple job waiting
}; // end put }; // end put
that.putAttachment = function (command) { that.putAttachment = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() + "/" + "id": command.getDocId() + "/" + command.getAttachmentId()
command.getAttachmentId()
}); });
}, 100); // 100 ms, for jiotests simple job waiting }, 100); // 100 ms, for jiotests simple job waiting
}; // end putAttachment }; // end putAttachment
that.get = function (command) { that.get = function (command) {
window.setTimeout(function () { setTimeout(function () {
if (command.getAttachmentId()) { if (command.getAttachmentId()) {
return that.success('0123456789'); return that.success('0123456789');
} }
...@@ -387,7 +370,7 @@ ...@@ -387,7 +370,7 @@
}, 100); // 100 ms, for jiotests simple job waiting }, 100); // 100 ms, for jiotests simple job waiting
}; // end get }; // end get
that.allDocs = function (command) { that.allDocs = function (command) {
window.setTimeout(function () { setTimeout(function () {
var addRow, var addRow,
o = { o = {
"total_rows": 0, "total_rows": 0,
...@@ -395,8 +378,8 @@ ...@@ -395,8 +378,8 @@
}; };
addRow = function (id, key, doc) { addRow = function (id, key, doc) {
var row = { var row = {
"id": "file", "id": id,
"key": "file", "key": key,
"value": {} "value": {}
}; };
if (command.getOption("include_docs")) { if (command.getOption("include_docs")) {
...@@ -419,12 +402,11 @@ ...@@ -419,12 +402,11 @@
}); });
}; // end allDocs }; // end allDocs
that.remove = function (command) { that.remove = function (command) {
window.setTimeout(function () { setTimeout(function () {
if (command.getAttachmentId()) { if (command.getAttachmentId()) {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() + "/" + "id": command.getDocId() + "/" + command.getAttachmentId()
command.getAttachmentId()
}); });
} else { } else {
that.success({ that.success({
...@@ -444,8 +426,8 @@ ...@@ -444,8 +426,8 @@
newDummyStorageAllFound = function (spec, my) { newDummyStorageAllFound = function (spec, my) {
var that = my.basicStorage(spec, my); var that = my.basicStorage(spec, my);
that.post = function (command) { that.post = function () {
window.setTimeout(function () { setTimeout(function () {
that.error({ that.error({
"status": 409, "status": 409,
"statusText": "Conflicts", "statusText": "Conflicts",
...@@ -456,7 +438,7 @@ ...@@ -456,7 +438,7 @@
}, 100); }, 100);
}; // end post }; // end post
that.put = function (command) { that.put = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() "id": command.getDocId()
...@@ -464,16 +446,15 @@ ...@@ -464,16 +446,15 @@
}, 100); }, 100);
}; // end put }; // end put
that.putAttachment = function (command) { that.putAttachment = function (command) {
window.setTimeout(function () { setTimeout(function () {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() + "/" + "id": command.getDocId() + "/" + command.getAttachmentId()
command.getAttachmentId()
}); });
}, 100); }, 100);
}; // end put }; // end put
that.get = function (command) { that.get = function (command) {
window.setTimeout(function () { setTimeout(function () {
if (command.getAttachmentId()) { if (command.getAttachmentId()) {
return that.success('0123456789'); return that.success('0123456789');
} }
...@@ -483,26 +464,23 @@ ...@@ -483,26 +464,23 @@
}); });
}, 100); // 100 ms, for jiotests simple job waiting }, 100); // 100 ms, for jiotests simple job waiting
}; // end get }; // end get
that.allDocs = function (command) { that.allDocs = function () {
window.setTimeout(function () { setTimeout(function () {
that.error({ that.error({
"status": 405, "status": 405,
"statusText": "Method Not Allowed", "statusText": "Method Not Allowed",
"error": "method_not_allowed", "error": "method_not_allowed",
"message": "Your are not allowed to use" + "message": "Your are not allowed to use" + "this command",
"this command", "reason": "LocalStorage forbids AllDocs" + "command executions"
"reason": "LocalStorage forbids AllDocs" +
"command executions"
}); });
}); });
}; // end allDocs }; // end allDocs
that.remove = function (command) { that.remove = function (command) {
window.setTimeout(function () { setTimeout(function () {
if (command.getAttachmentId()) { if (command.getAttachmentId()) {
that.success({ that.success({
"ok": true, "ok": true,
"id": command.getDocId() + "/" + "id": command.getDocId() + "/" + command.getAttachmentId()
command.getAttachmentId()
}); });
} else { } else {
that.success({ that.success({
...@@ -519,8 +497,7 @@ ...@@ -519,8 +497,7 @@
// add key to storageObjectType of global jio // add key to storageObjectType of global jio
jIO.addStorageType('dummyallok', newDummyStorageAllOk); jIO.addStorageType('dummyallok', newDummyStorageAllOk);
jIO.addStorageType('dummyallfail', newDummyStorageAllFail); jIO.addStorageType('dummyallfail', newDummyStorageAllFail);
jIO.addStorageType('dummyallnotfound', jIO.addStorageType('dummyallnotfound', newDummyStorageAllNotFound);
newDummyStorageAllNotFound);
jIO.addStorageType('dummyall3tries', newDummyStorageAll3Tries); jIO.addStorageType('dummyall3tries', newDummyStorageAll3Tries);
jIO.addStorageType('dummyalldocs', newDummyStorageAllDocs); jIO.addStorageType('dummyalldocs', newDummyStorageAllDocs);
jIO.addStorageType('dummyallfound', newDummyStorageAllFound); jIO.addStorageType('dummyallfound', newDummyStorageAllFound);
......
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