Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
jio
Commits
93c5a742
Commit
93c5a742
authored
Jan 10, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jslint pass dummystorages.js
parent
f6015801
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
473 additions
and
496 deletions
+473
-496
src/jio.dummystorages.js
src/jio.dummystorages.js
+473
-496
No files found.
src/jio.dummystorages.js
View file @
93c5a742
/*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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment