Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mukul
jio
Commits
fa6ae79d
Commit
fa6ae79d
authored
Jan 09, 2013
by
Sven Franck
Committed by
Sebastien Robin
Jan 09, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jslint pass dummystorages.js
parent
a497d65a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
502 additions
and
487 deletions
+502
-487
src/jio.dummystorages.js
src/jio.dummystorages.js
+502
-487
No files found.
src/jio.dummystorages.js
View file @
fa6ae79d
/*global window, define */
// Adds 5 dummy storages to JIO
// Adds 5 dummy storages to JIO
// type:
// type:
// - dummyallok
// - dummyallok
...
@@ -6,513 +7,527 @@
...
@@ -6,513 +7,527 @@
// - dummyall3tries
// - dummyall3tries
// - dummyalldocs
// - dummyalldocs
// - dummyallfound
// - dummyallfound
(
function
()
{
var
jioDummyStorageLoader
=
function
(
jIO
)
{
(
function
()
{
'
use strict
'
;
////////////////////////////////////////////////////////////////////////////
var
jioDummyStorageLoader
=
function
(
jIO
)
{
// Dummy Storage 1 : all ok
var
newDummyStorageAllOk
=
function
(
spec
,
my
)
{
/////////////////////////////////////////////////////////////////
var
that
=
my
.
basicStorage
(
spec
,
my
);
// Dummy Storage 1 : all ok
var
newDummyStorageAllOk
=
function
(
spec
,
my
)
{
that
.
specToStore
=
function
()
{
var
that
=
my
.
basicStorage
(
spec
,
my
);
return
{
"
username
"
:
spec
.
username
};
};
that
.
specToStore
=
function
()
{
return
{
that
.
post
=
function
(
command
)
{
"
username
"
:
spec
.
username
setTimeout
(
function
()
{
};
that
.
success
({
};
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end post
that
.
put
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end put
that
.
putAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end putAttachment
that
.
get
=
function
(
command
)
{
setTimeout
(
function
()
{
if
(
command
.
getAttachmentId
())
{
return
that
.
success
(
'
0123456789
'
);
}
that
.
success
({
"
_id
"
:
command
.
getDocId
(),
"
title
"
:
'
get_title
'
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end get
that
.
allDocs
=
function
(
command
)
{
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
"
});
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
that
.
post
=
function
(
command
)
{
setTimeout
(
function
()
{
window
.
setTimeout
(
function
()
{
if
(
command
.
getAttachmentId
())
{
that
.
success
({
that
.
success
({
"
ok
"
:
true
,
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
"
id
"
:
command
.
getDocId
()
});
});
}
else
{
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end post
that
.
put
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
success
({
that
.
success
({
"
ok
"
:
true
,
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
"
id
"
:
command
.
getDocId
()
});
});
}
},
100
);
// 100 ms, for jiotests simple job waiting
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end put
};
// end remove
return
that
;
},
// end Dummy Storage All Ok
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Dummy Storage 2 : all fail
newDummyStorageAllFail
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
priv
.
error
=
function
()
{
setTimeout
(
function
()
{
that
.
error
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
error
:
'
unknown_error
'
,
message
:
'
Execution encountred an error.
'
,
reason
:
'
Execution encountred an error
'
});
},
100
);
};
that
.
post
=
function
(
command
)
{
priv
.
error
();
};
// end post
that
.
put
=
function
(
command
)
{
priv
.
error
();
};
// end put
that
.
putAttachment
=
function
(
command
)
{
priv
.
error
();
};
// end put
that
.
get
=
function
(
command
)
{
priv
.
error
();
};
// end get
that
.
allDocs
=
function
(
command
)
{
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
"
});
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
priv
.
error
();
};
// end remove
return
that
;
},
// end Dummy Storage All Fail
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Dummy Storage 3 : all not found
newDummyStorageAllNotFound
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
);
that
.
post
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
};
// end post
that
.
put
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
};
// end put
that
.
putAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
},
100
);
};
// end put
that
.
get
=
function
(
command
)
{
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
"
});
},
100
);
};
// end get
that
.
allDocs
=
function
(
command
)
{
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
"
});
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
that
.
putAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
window
.
setTimeout
(
function
()
{
that
.
error
({
that
.
success
({
"
status
"
:
404
,
"
ok
"
:
true
,
"
statusText
"
:
"
Not Found
"
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
"
error
"
:
"
not_found
"
,
command
.
getAttachmentId
()
"
message
"
:
"
Cannot remove an unexistant document
"
,
});
"
reason
"
:
"
missing
"
// or deleted
},
100
);
// 100 ms, for jiotests simple job waiting
});
};
// end putAttachment
},
100
);
};
// end remove
return
that
;
},
// end Dummy Storage All Not Found
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Dummy Storage 4 : all 3 tries
newDummyStorageAll3Tries
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
// this specToStore method is used to make simple difference between
// two dummyall3tries storages:
// so {type:'dummyall3tries',a:'b'} differs from
// {type:'dummyall3tries',c:'d'}.
that
.
specToStore
=
function
()
{
return
{
"
application_name
"
:
spec
.
application_name
};
};
priv
.
doJob
=
function
(
command
,
if_ok_return
)
{
// wait a little in order to simulate asynchronous operation
setTimeout
(
function
()
{
priv
.
Try3OKElseFail
(
command
.
getTried
(),
if_ok_return
);
},
100
);
};
priv
.
Try3OKElseFail
=
function
(
tries
,
if_ok_return
)
{
if
(
typeof
tries
===
'
undefined
'
)
{
return
that
.
error
({
"
status
"
:
0
,
"
statusText
"
:
"
Unknown Error
"
,
"
error
"
:
"
unknown_error
"
,
"
message
"
:
"
Cannot get tried
"
,
"
reason
"
:
"
Unknown
"
});
}
if
(
tries
<
3
)
{
return
that
.
retry
(
{
message
:
''
+
(
3
-
tries
)
+
'
tries left.
'
});
}
if
(
tries
===
3
)
{
return
that
.
success
(
if_ok_return
);
}
if
(
tries
>
3
)
{
return
that
.
error
({
"
status
"
:
1
,
"
statusText
"
:
"
Too Much Tries
"
,
"
error
"
:
"
too_much_tries
"
,
"
message
"
:
"
Too much tries
"
,
"
reason
"
:
"
Too much tries
"
});
}
};
that
.
post
=
function
(
command
)
{
priv
.
doJob
(
command
,{
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()});
};
// end post
that
.
put
=
function
(
command
)
{
priv
.
doJob
(
command
,{
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()});
};
// end put
that
.
putAttachment
=
function
(
command
)
{
priv
.
doJob
(
command
,{
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
};
// end put
that
.
get
=
function
(
command
)
{
if
(
command
.
getAttachmentId
())
{
priv
.
doJob
(
command
,
"
0123456789
"
);
}
else
{
priv
.
doJob
(
command
,{
"
_id
"
:
command
.
getDocId
(),
"
title
"
:
'
Title of
'
+
command
.
getDocId
(),
});
}
};
// end get
that
.
allDocs
=
function
(
command
)
{
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
"
});
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
if
(
command
.
getAttachmentId
())
{
priv
.
doJob
(
command
,{
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
}
else
{
priv
.
doJob
(
command
,{
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()});
}
};
// end remove
return
that
;
},
// end Dummy Storage All 3 Tries
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Dummy Storage 5 : all docs
newDummyStorageAllDocs
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
);
that
.
specToStore
=
function
()
{
return
{
"
username
"
:
spec
.
username
};
};
that
.
post
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end post
that
.
put
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end put
that
.
putAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end putAttachment
that
.
get
=
function
(
command
)
{
that
.
get
=
function
(
command
)
{
setTimeout
(
function
()
{
window
.
setTimeout
(
function
()
{
if
(
command
.
getAttachmentId
())
{
if
(
command
.
getAttachmentId
())
{
return
that
.
success
(
'
0123456789
'
);
return
that
.
success
(
'
0123456789
'
);
}
}
that
.
success
({
that
.
success
({
"
_id
"
:
command
.
getDocId
(),
"
_id
"
:
command
.
getDocId
(),
"
title
"
:
"
get_title
"
"
title
"
:
'
get_title
'
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end get
that
.
allDocs
=
function
(
command
)
{
window
.
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
"
});
});
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end allDocs
};
// end get
that
.
remove
=
function
(
command
)
{
that
.
allDocs
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
if
(
command
.
getAttachmentId
())
{
var
addRow
,
o
=
{
that
.
success
({
"
total_rows
"
:
0
,
"
ok
"
:
true
,
"
rows
"
:
[]
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
}
else
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
}
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end remove
return
that
;
},
// end Dummy Storage All Ok
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Dummy Storage 2 : all fail
newDummyStorageAllFail
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
priv
.
error
=
function
()
{
window
.
setTimeout
(
function
()
{
that
.
error
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
error
:
'
unknown_error
'
,
message
:
'
Execution encountred an error.
'
,
reason
:
'
Execution encountred an error
'
});
},
100
);
};
};
addRow
=
function
(
id
,
key
,
doc
)
{
var
row
=
{
that
.
post
=
function
(
command
)
{
"
id
"
:
"
file
"
,
priv
.
error
();
"
key
"
:
"
file
"
,
};
// end post
"
value
"
:
{}
that
.
put
=
function
(
command
)
{
priv
.
error
();
};
// end put
that
.
putAttachment
=
function
(
command
)
{
priv
.
error
();
};
// end put
that
.
get
=
function
(
command
)
{
priv
.
error
();
};
// end get
that
.
allDocs
=
function
(
command
)
{
window
.
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
"
});
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
priv
.
error
();
};
// end remove
return
that
;
},
// end Dummy Storage All Fail
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Dummy Storage 3 : all not found
newDummyStorageAllNotFound
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
);
that
.
post
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
};
// end post
that
.
put
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
};
// end put
that
.
putAttachment
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
},
100
);
};
// end put
that
.
get
=
function
(
command
)
{
window
.
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
"
});
},
100
);
};
// end get
that
.
allDocs
=
function
(
command
)
{
window
.
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
"
});
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
"
Cannot remove an unexistant
"
+
"
document
"
,
"
reason
"
:
"
missing
"
// or deleted
});
},
100
);
};
// end remove
return
that
;
},
// end Dummy Storage All Not Found
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Dummy Storage 4 : all 3 tries
newDummyStorageAll3Tries
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
// this specToStore method is used to make simple
// difference between two dummyall3tries storages:
// so {type:'dummyall3tries',a:'b'} differs from
// {type:'dummyall3tries',c:'d'}.
that
.
specToStore
=
function
()
{
return
{
"
application_name
"
:
spec
.
application_name
};
};
if
(
command
.
getOption
(
"
include_docs
"
))
{
row
[
"
doc
"
]
=
doc
;
}
o
.
rows
.
push
(
row
);
o
.
total_rows
+=
1
;
};
};
addRow
(
"
file
"
,
"
file
"
,
{
priv
.
doJob
=
function
(
command
,
if_ok_return
)
{
"
_id
"
:
"
file
"
,
// wait a little to simulate asynchronous operation
"
Title
"
:
"
myFile
"
,
window
.
setTimeout
(
function
()
{
});
priv
.
Try3OKElseFail
(
command
.
getTried
(),
addRow
(
if_ok_return
);
"
mylongtitledfilethatidontliketowritebyhandonablackboard
"
,
},
100
);
"
mylongti.alias1
"
,
};
{
priv
.
Try3OKElseFail
=
function
(
tries
,
if_ok_return
)
{
"
_id
"
:
"
mylongtitledfilethatidontliketowritebyhandonablackboard
"
,
if
(
tries
===
'
undefined
'
)
{
"
Title
"
:
"
myLongFile
"
,
return
that
.
error
({
"
status
"
:
0
,
"
statusText
"
:
"
Unknown Error
"
,
"
error
"
:
"
unknown_error
"
,
"
message
"
:
"
Cannot get tried
"
,
"
reason
"
:
"
Unknown
"
});
}
}
);
if
(
tries
<
3
)
{
that
.
success
(
o
);
return
that
.
retry
({
});
message
:
'
Now
'
+
(
3
-
tries
)
+
'
tries left.
'
};
// end allDocs
});
}
that
.
remove
=
function
(
command
)
{
if
(
tries
===
3
)
{
setTimeout
(
function
()
{
return
that
.
success
(
if_ok_return
);
if
(
command
.
getAttachmentId
())
{
}
that
.
success
({
if
(
tries
>
3
)
{
return
that
.
error
({
"
status
"
:
1
,
"
statusText
"
:
"
Too Much Tries
"
,
"
error
"
:
"
too_much_tries
"
,
"
message
"
:
"
Too much tries
"
,
"
reason
"
:
"
Too much tries
"
});
}
};
that
.
post
=
function
(
command
)
{
priv
.
doJob
(
command
,
{
"
ok
"
:
true
,
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
"
id
"
:
command
.
getDocId
()
});
});
}
else
{
};
// end post
that
.
success
({
that
.
put
=
function
(
command
)
{
priv
.
doJob
(
command
,
{
"
ok
"
:
true
,
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
"
id
"
:
command
.
getDocId
()
});
});
}
};
// end put
},
100
);
// 100 ms, for jiotests simple job waiting
that
.
putAttachment
=
function
(
command
)
{
};
// end remove
priv
.
doJob
(
command
,
{
return
that
;
};
// end Dummy Storage All Docs
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Dummy Storage 6 : all found
newDummyStorageAllFound
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
);
that
.
post
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
error
({
"
status
"
:
409
,
"
statusText
"
:
"
Conflicts
"
,
"
error
"
:
"
conflicts
"
,
"
message
"
:
"
Cannot create a new document
"
,
"
reason
"
:
"
Document already exists
"
});
},
100
);
};
// end post
that
.
put
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
};
// end put
that
.
putAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
},
100
);
};
// end put
that
.
get
=
function
(
command
)
{
setTimeout
(
function
()
{
if
(
command
.
getAttachmentId
())
{
return
that
.
success
(
'
0123456789
'
);
}
that
.
success
({
"
_id
"
:
command
.
getDocId
(),
"
title
"
:
'
get_title
'
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end get
that
.
allDocs
=
function
(
command
)
{
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
"
});
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
setTimeout
(
function
()
{
if
(
command
.
getAttachmentId
())
{
that
.
success
({
"
ok
"
:
true
,
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
});
}
else
{
};
// end put
that
.
success
({
that
.
get
=
function
(
command
)
{
"
ok
"
:
true
,
if
(
command
.
getAttachmentId
())
{
"
id
"
:
command
.
getDocId
()
priv
.
doJob
(
command
,
"
0123456789
"
);
}
else
{
priv
.
doJob
(
command
,
{
"
_id
"
:
command
.
getDocId
(),
"
title
"
:
'
Title of
'
+
command
.
getDocId
()
});
}
};
// end get
that
.
allDocs
=
function
(
command
)
{
window
.
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
"
});
});
});
}
};
// end allDocs
},
100
);
// 100 ms, for jiotests simple job waiting
that
.
remove
=
function
(
command
)
{
};
// end remove
if
(
command
.
getAttachmentId
())
{
priv
.
doJob
(
command
,
{
return
that
;
"
ok
"
:
true
,
},
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
// end Dummy Storage All Not Found
command
.
getAttachmentId
()
////////////////////////////////////////////////////////////////////////////
});
}
else
{
// add key to storageObjectType of global jio
priv
.
doJob
(
command
,
{
jIO
.
addStorageType
(
'
dummyallok
'
,
newDummyStorageAllOk
);
"
ok
"
:
true
,
jIO
.
addStorageType
(
'
dummyallfail
'
,
newDummyStorageAllFail
);
"
id
"
:
command
.
getDocId
()
jIO
.
addStorageType
(
'
dummyallnotfound
'
,
newDummyStorageAllNotFound
);
});
jIO
.
addStorageType
(
'
dummyall3tries
'
,
newDummyStorageAll3Tries
);
}
jIO
.
addStorageType
(
'
dummyalldocs
'
,
newDummyStorageAllDocs
);
};
// end remove
jIO
.
addStorageType
(
'
dummyallfound
'
,
newDummyStorageAllFound
);
return
that
;
},
};
// end Dummy Storage All 3 Tries
/////////////////////////////////////////////////////////////////
if
(
window
.
requirejs
)
{
define
(
'
JIODummyStorages
'
,[
'
jIO
'
],
jioDummyStorageLoader
);
/////////////////////////////////////////////////////////////////
}
else
{
// Dummy Storage 5 : all docs
jioDummyStorageLoader
(
jIO
);
newDummyStorageAllDocs
=
function
(
spec
,
my
)
{
}
var
that
=
my
.
basicStorage
(
spec
,
my
);
that
.
specToStore
=
function
()
{
}());
return
{
"
username
"
:
spec
.
username
};
};
that
.
post
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end post
that
.
put
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end put
that
.
putAttachment
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end putAttachment
that
.
get
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
if
(
command
.
getAttachmentId
())
{
return
that
.
success
(
'
0123456789
'
);
}
that
.
success
({
"
_id
"
:
command
.
getDocId
(),
"
title
"
:
"
get_title
"
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end get
that
.
allDocs
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
var
addRow
,
o
=
{
"
total_rows
"
:
0
,
"
rows
"
:
[]
};
addRow
=
function
(
id
,
key
,
doc
)
{
var
row
=
{
"
id
"
:
"
file
"
,
"
key
"
:
"
file
"
,
"
value
"
:
{}
};
if
(
command
.
getOption
(
"
include_docs
"
))
{
row
.
doc
=
doc
;
}
o
.
rows
.
push
(
row
);
o
.
total_rows
+=
1
;
};
addRow
(
"
file
"
,
"
file
"
,
{
"
_id
"
:
"
file
"
,
"
Title
"
:
"
myFile
"
});
addRow
(
"
mylongtitledfilethatidontliketowriteby
"
+
"
handonablackboard
"
,
"
mylongtialias1
"
,
{
"
_id
"
:
"
mylongtitledfilethatidontlike
"
+
"
towritebyhandonablackboard
"
,
"
Title
"
:
"
myLongFile
"
});
that
.
success
(
o
);
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
if
(
command
.
getAttachmentId
())
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
}
else
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
}
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end remove
return
that
;
},
// end Dummy Storage All Docs
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Dummy Storage 6 : all found
newDummyStorageAllFound
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
);
that
.
post
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
error
({
"
status
"
:
409
,
"
statusText
"
:
"
Conflicts
"
,
"
error
"
:
"
conflicts
"
,
"
message
"
:
"
Cannot create a new document
"
,
"
reason
"
:
"
Document already exists
"
});
},
100
);
};
// end post
that
.
put
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
};
// end put
that
.
putAttachment
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
},
100
);
};
// end put
that
.
get
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
if
(
command
.
getAttachmentId
())
{
return
that
.
success
(
'
0123456789
'
);
}
that
.
success
({
"
_id
"
:
command
.
getDocId
(),
"
title
"
:
'
get_title
'
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end get
that
.
allDocs
=
function
(
command
)
{
window
.
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
"
});
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
window
.
setTimeout
(
function
()
{
if
(
command
.
getAttachmentId
())
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
}
else
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
}
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end remove
return
that
;
};
// end Dummy Storage All Not Found
/////////////////////////////////////////////////////////////////
// add key to storageObjectType of global jio
jIO
.
addStorageType
(
'
dummyallok
'
,
newDummyStorageAllOk
);
jIO
.
addStorageType
(
'
dummyallfail
'
,
newDummyStorageAllFail
);
jIO
.
addStorageType
(
'
dummyallnotfound
'
,
newDummyStorageAllNotFound
);
jIO
.
addStorageType
(
'
dummyall3tries
'
,
newDummyStorageAll3Tries
);
jIO
.
addStorageType
(
'
dummyalldocs
'
,
newDummyStorageAllDocs
);
jIO
.
addStorageType
(
'
dummyallfound
'
,
newDummyStorageAllFound
);
};
if
(
window
.
requirejs
)
{
define
(
'
JIODummyStorages
'
,
[
'
jIO
'
],
jioDummyStorageLoader
);
}
else
{
jioDummyStorageLoader
(
jIO
);
}
}());
\ No newline at end of file
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