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
Labels
Merge Requests
18
Merge Requests
18
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
jio
Commits
e56e94fe
Commit
e56e94fe
authored
Nov 23, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add localstorage wrapper function into localstorage.js
parent
7f891a96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+23
-7
No files found.
src/jio.storage/localstorage.js
View file @
e56e94fe
...
...
@@ -6,6 +6,22 @@ var newLocalStorage = function ( spec, my ) {
spec
=
spec
||
{};
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
/*
* Wrapper for the localStorage used to simplify instion of any kind of
* values
*/
var
localstorage
=
{
getItem
:
function
(
item
)
{
return
JSON
.
parse
(
localStorage
.
getItem
(
item
));
},
setItem
:
function
(
item
,
value
)
{
return
localStorage
.
setItem
(
item
,
JSON
.
stringify
(
value
));
},
deleteItem
:
function
(
item
)
{
delete
localStorage
[
item
];
}
};
priv
.
secureDocId
=
function
(
string
)
{
var
split
=
string
.
split
(
'
/
'
),
i
;
if
(
split
[
0
]
===
''
)
{
...
...
@@ -54,7 +70,7 @@ var newLocalStorage = function ( spec, my ) {
* @return {array} The list of users.
*/
priv
.
getUserArray
=
function
()
{
return
local
S
torage
.
getItem
(
storage_user_array_name
)
||
[];
return
local
s
torage
.
getItem
(
storage_user_array_name
)
||
[];
};
/**
...
...
@@ -65,7 +81,7 @@ var newLocalStorage = function ( spec, my ) {
priv
.
addUser
=
function
(
user_name
)
{
var
user_array
=
priv
.
getUserArray
();
user_array
.
push
(
user_name
);
local
S
torage
.
setItem
(
storage_user_array_name
,
user_array
);
local
s
torage
.
setItem
(
storage_user_array_name
,
user_array
);
};
/**
...
...
@@ -90,7 +106,7 @@ var newLocalStorage = function ( spec, my ) {
* @return {array} All the existing file paths.
*/
priv
.
getFileNameArray
=
function
()
{
return
local
S
torage
.
getItem
(
storage_file_array_name
)
||
[];
return
local
s
torage
.
getItem
(
storage_file_array_name
)
||
[];
};
/**
...
...
@@ -101,7 +117,7 @@ var newLocalStorage = function ( spec, my ) {
priv
.
addFileName
=
function
(
file_name
)
{
var
file_name_array
=
priv
.
getFileNameArray
();
file_name_array
.
push
(
file_name
);
local
S
torage
.
setItem
(
storage_file_array_name
,
file_name_array
);
local
s
torage
.
setItem
(
storage_file_array_name
,
file_name_array
);
};
/**
...
...
@@ -116,7 +132,7 @@ var newLocalStorage = function ( spec, my ) {
new_array
.
push
(
array
[
i
]);
}
}
local
S
torage
.
setItem
(
storage_file_array_name
,
new_array
);
local
s
torage
.
setItem
(
storage_file_array_name
,
new_array
);
};
priv
.
checkSecuredDocId
=
function
(
secured_docid
,
docid
,
method
)
{
...
...
@@ -228,7 +244,7 @@ var newLocalStorage = function ( spec, my ) {
array
=
priv
.
getFileNameArray
();
for
(
i
=
0
,
l
=
array
.
length
;
i
<
l
;
i
+=
1
)
{
file_object
=
local
S
torage
.
getItem
(
path
+
'
/
'
+
array
[
i
]);
local
s
torage
.
getItem
(
path
+
'
/
'
+
array
[
i
]);
if
(
file_object
)
{
if
(
command
.
getOption
(
'
metadata_only
'
))
{
new_array
.
push
({
...
...
@@ -263,7 +279,7 @@ var newLocalStorage = function ( spec, my ) {
if
(
!
priv
.
checkSecuredDocId
(
secured_docid
,
command
.
getDocId
(),
'
remove
'
))
{
return
;}
// deleting
delete
localStorage
[
path
]
;
localstorage
.
deleteItem
(
path
)
;
priv
.
removeFileName
(
secured_docid
);
that
.
success
({
ok
:
true
,
id
:
command
.
getDocId
()});
});
...
...
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