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
Aurélien Vermylen
jio
Commits
7145f976
Commit
7145f976
authored
Aug 08, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
useless storage removed
parent
4d4cb2fd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
638 deletions
+0
-638
src/jio.dummystorages.js
src/jio.dummystorages.js
+0
-559
src/jio.waitstorage.js
src/jio.waitstorage.js
+0
-79
No files found.
src/jio.dummystorages.js
deleted
100644 → 0
View file @
4d4cb2fd
/*jslint indent: 2, maxlen: 80, sloppy: true */
/*global setTimeout: true, window: true, define: true, jIO: true */
// Adds 5 dummy storages to JIO
// type:
// - dummyallok
// - dummyallfail
// - dummyallnotfound
// - dummyall3tries
// - dummyalldocs
// - dummyallfound
(
function
()
{
'
use strict
'
;
var
jioDummyStorageLoader
=
function
(
jIO
)
{
/////////////////////////////////////////////////////////////////
// Dummy Storage 1 : all ok
var
newDummyStorageAllOk
=
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
(),
"
attachment
"
:
command
.
getAttachmentId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end putAttachment
that
.
get
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
_id
"
:
command
.
getDocId
(),
"
title
"
:
'
get_title
'
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end get
that
.
getAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
(
'
0123456789
'
);
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end putAttachment
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
"
:
"
Dummystorage forbids AllDocs command executions
"
});
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end remove
that
.
removeAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
(),
"
attachment
"
:
command
.
getAttachmentId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end putAttachment
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
()
{
priv
.
error
();
};
// end post
that
.
put
=
function
()
{
priv
.
error
();
};
// end put
that
.
putAttachment
=
function
()
{
priv
.
error
();
};
// end put
that
.
get
=
function
()
{
priv
.
error
();
};
// end get
that
.
getAttachment
=
function
()
{
priv
.
error
();
};
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
"
});
});
};
// end allDocs
that
.
remove
=
function
()
{
priv
.
error
();
};
// end remove
that
.
removeAttachment
=
function
()
{
priv
.
error
();
};
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
(),
"
attachment
"
:
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
.
getAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
"
Attachment not found
"
,
"
reason
"
:
"
Document '
"
+
command
.
getDocId
()
+
"
'does not exist
"
});
},
100
);
};
// end get
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
"
:
"
Dummystorage forbids AllDocs command executions
"
});
});
};
// end allDocs
that
.
remove
=
function
()
{
setTimeout
(
function
()
{
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
"
Cannot remove an inexistent document
"
,
"
reason
"
:
"
missing
"
// or deleted
});
},
100
);
};
// end remove
that
.
removeAttachment
=
function
()
{
setTimeout
(
function
()
{
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
"
Cannot remove an inexistent attachment
"
,
"
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
};
};
priv
.
doJob
=
function
(
command
,
if_ok_return
)
{
// wait a little to simulate asynchronous operation
setTimeout
(
function
()
{
priv
.
Try3OKElseFail
(
command
.
getTried
(),
if_ok_return
);
},
100
);
};
priv
.
Try3OKElseFail
=
function
(
tries
,
if_ok_return
)
{
if
(
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
:
'
Now
'
+
(
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
()
{
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
)
{
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
()
{
var
addRow
,
o
=
{
"
total_rows
"
:
0
,
"
rows
"
:
[]
};
addRow
=
function
(
id
,
key
,
doc
)
{
var
row
=
{
"
id
"
:
id
,
"
key
"
:
key
,
"
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
)
{
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
()
{
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
(),
"
attachment
"
:
command
.
getAttachmentId
()
});
},
100
);
};
// end putAttachment
that
.
get
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
_id
"
:
command
.
getDocId
(),
"
title
"
:
'
get_title
'
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end get
that
.
getAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
(
'
0123456789
'
);
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end getAttachment
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
"
:
"
Dummystorage forbids AllDocs command executions
"
});
});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end remove
that
.
removeAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
command
.
getDocId
(),
"
attachment
"
:
command
.
getAttachmentId
()
});
},
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
);
}
}());
src/jio.waitstorage.js
deleted
100644 → 0
View file @
4d4cb2fd
/*jslint indent: 2, maxlen: 80, sloppy: true */
/*global setTimeout: true, window: true, define: true, jIO: true */
(
function
()
{
'
use strict
'
;
var
jioWaitStorageLoader
=
function
(
jIO
)
{
var
newWaitStorage
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{},
validatestate_sub_storage
=
spec
.
storage
||
false
;
priv
.
sub_storage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
priv
.
delay
=
spec
.
delay
||
5000
;
priv
.
save
=
spec
.
save
||
true
;
priv
.
load
=
spec
.
load
||
false
;
priv
.
getlist
=
spec
.
getlist
||
false
;
priv
.
remove
=
spec
.
remove
||
false
;
that
.
validateState
=
function
()
{
if
(
!
validatestate_sub_storage
)
{
return
'
Need at least one parameter: "storage"
'
+
'
containing storage specifications.
'
;
}
return
''
;
};
that
.
specToStore
=
function
()
{
var
o
=
{};
o
.
delay
=
priv
.
delay
;
o
.
storage
=
priv
.
sub_storage_spec
;
o
.
save
=
priv
.
save
;
o
.
load
=
priv
.
load
;
o
.
getlist
=
priv
.
getlist
;
o
.
remove
=
priv
.
remove
;
return
o
;
};
priv
.
doJob
=
function
(
command
,
timeout_or_not_timeout
)
{
var
delay
=
0
;
if
(
timeout_or_not_timeout
)
{
delay
=
priv
.
delay
;
}
setTimeout
(
function
()
{
that
.
addJob
(
that
.
newStorage
(
priv
.
sub_storage_spec
),
command
);
that
.
end
();
},
delay
);
};
that
.
saveDocument
=
function
(
command
)
{
priv
.
doJob
(
command
,
priv
.
save
);
};
// end saveDocument
that
.
loadDocument
=
function
(
command
)
{
priv
.
doJob
(
command
,
priv
.
load
);
};
// end loadDocument
that
.
getDocumentList
=
function
(
command
)
{
priv
.
doJob
(
command
,
priv
.
getlist
);
};
// end getDocumentList
that
.
removeDocument
=
function
(
command
)
{
priv
.
doJob
(
command
,
priv
.
remove
);
};
// end removeDocument
return
that
;
};
jIO
.
addStorageType
(
'
wait
'
,
newWaitStorage
);
};
if
(
window
.
requirejs
)
{
define
(
'
JIOWaitStorages
'
,
[
'
jIO
'
],
jioWaitStorageLoader
);
}
else
{
jioWaitStorageLoader
(
jIO
);
}
}
());
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