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
ff313c6c
Commit
ff313c6c
authored
Apr 23, 2018
by
Mukul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RandomStorage] Adds random storage in jio
parent
d963b0a5
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
577 additions
and
1 deletion
+577
-1
Gruntfile.js
Gruntfile.js
+2
-1
src/jio.storage/randomstorage.js
src/jio.storage/randomstorage.js
+73
-0
test/jio.storage/randomstorage.tests.js
test/jio.storage/randomstorage.tests.js
+501
-0
test/tests.html
test/tests.html
+1
-0
No files found.
Gruntfile.js
View file @
ff313c6c
...
...
@@ -182,7 +182,8 @@ module.exports = function (grunt) {
'
src/jio.storage/indexeddbstorage.js
'
,
'
src/jio.storage/cryptstorage.js
'
,
'
src/jio.storage/websqlstorage.js
'
,
'
src/jio.storage/fbstorage.js
'
'
src/jio.storage/fbstorage.js
'
,
'
src/jio.storage/randomstorage.js
'
],
dest
:
'
dist/<%= pkg.name %>-<%= pkg.version %>.js
'
// dest: 'jio.js'
...
...
src/jio.storage/randomstorage.js
0 → 100644
View file @
ff313c6c
/*jslint nomen: true*/
(
function
(
jIO
)
{
"
use strict
"
;
/**
* The jIO RandomStorage extension
*
* @class RandomStorage
* @constructor
*/
function
RandomStorage
(
spec
)
{
this
.
_sub_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
}
RandomStorage
.
prototype
.
get
=
function
()
{
return
this
.
_sub_storage
.
get
.
apply
(
this
.
_sub_storage
,
arguments
);
};
RandomStorage
.
prototype
.
allAttachments
=
function
()
{
return
this
.
_sub_storage
.
allAttachments
.
apply
(
this
.
_sub_storage
,
arguments
);
};
RandomStorage
.
prototype
.
post
=
function
()
{
return
this
.
_sub_storage
.
post
.
apply
(
this
.
_sub_storage
,
arguments
);
};
RandomStorage
.
prototype
.
put
=
function
()
{
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
);
};
RandomStorage
.
prototype
.
remove
=
function
()
{
return
this
.
_sub_storage
.
remove
.
apply
(
this
.
_sub_storage
,
arguments
);
};
RandomStorage
.
prototype
.
getAttachment
=
function
()
{
return
this
.
_sub_storage
.
getAttachment
.
apply
(
this
.
_sub_storage
,
arguments
);
};
RandomStorage
.
prototype
.
putAttachment
=
function
()
{
return
this
.
_sub_storage
.
putAttachment
.
apply
(
this
.
_sub_storage
,
arguments
);
};
RandomStorage
.
prototype
.
removeAttachment
=
function
()
{
return
this
.
_sub_storage
.
removeAttachment
.
apply
(
this
.
_sub_storage
,
arguments
);
};
RandomStorage
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
this
.
_sub_storage
.
hasCapacity
(
name
);
};
RandomStorage
.
prototype
.
buildQuery
=
function
(
options
)
{
var
limit
;
if
(
options
.
sort_on
[
0
][
0
]
===
'
random
'
)
{
limit
=
options
.
limit
;
delete
options
.
limit
;
}
return
this
.
_sub_storage
.
buildQuery
.
apply
(
this
.
_sub_storage
,
arguments
)
.
push
(
function
(
result
)
{
// Random shuffle the result when random is present in the options.
if
(
options
.
sort_on
[
0
][
0
]
===
'
random
'
)
{
var
final_result
=
[],
random_number
;
while
(
limit
[
1
]
&&
result
.
length
-
limit
[
0
])
{
random_number
=
Math
.
floor
(
Math
.
random
()
*
result
.
length
);
random_number
=
random_number
===
result
.
length
?
result
.
length
-
1
:
random_number
;
final_result
.
push
(
result
.
splice
(
random_number
,
1
)[
0
]);
limit
[
1
]
-=
1
;
}
return
final_result
;
}
return
result
;
});
};
jIO
.
addStorage
(
'
random
'
,
RandomStorage
);
}(
jIO
));
test/jio.storage/randomstorage.tests.js
0 → 100644
View file @
ff313c6c
This diff is collapsed.
Click to expand it.
test/tests.html
View file @
ff313c6c
...
...
@@ -56,6 +56,7 @@
<script
src=
"jio.storage/websqlstorage.tests.js"
></script>
<script
src=
"jio.storage/fbstorage.tests.js"
></script>
<script
src=
"jio.storage/httpstorage.tests.js"
></script>
<script
src=
"jio.storage/randomstorage.tests.js"
></script>
<!--script src="../lib/jquery/jquery.min.js"></script>
<script src="../src/jio.storage/xwikistorage.js"></script>
<script src="jio.storage/xwikistorage.tests.js"></script-->
...
...
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