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