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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaohe Cao
jio
Commits
bca52a01
Commit
bca52a01
authored
Oct 03, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localstorage description creator redesigned
parent
09252852
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
11 deletions
+35
-11
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+35
-11
No files found.
src/jio.storage/localstorage.js
View file @
bca52a01
...
...
@@ -671,26 +671,49 @@
//////////////////////////////////////////////////////////////////////
// Tools
function
createLocalDescription
(
username
,
application_name
)
{
if
(
typeof
username
!==
'
string
'
)
{
throw
new
TypeError
(
"
LocalStorage username must be a string
"
);
}
var
description
=
{
"
type
"
:
"
local
"
,
"
username
"
:
username
};
if
(
typeof
application_name
===
'
string
'
)
{
description
.
application_name
=
application_name
;
}
return
description
;
}
function
createMemoryDescription
(
username
,
application_name
)
{
var
description
=
createLocalDescription
(
username
,
application_name
);
description
.
mode
=
"
memory
"
;
return
description
;
}
/**
* Tool to help users to create local storage description for JIO
*
* @param {String} username The username
* @param {String} [application_name] The application_name
* @param {String} [mode="localStorage"] Use localStorage or memory
* @return {Object} The storage description
*/
function
createDescription
(
username
,
application_name
)
{
var
description
=
{
"
type
"
:
"
local
"
,
"
username
"
:
username
.
toString
()
};
if
(
application_name
!==
undefined
)
{
description
.
application_name
=
application_name
.
toString
();
function
createDescription
(
username
,
application_name
,
mode
)
{
if
(
mode
===
undefined
||
mode
.
toString
()
===
'
localStorage
'
)
{
return
createLocalDescription
(
username
,
application_name
);
}
return
description
;
if
(
mode
.
toString
()
===
'
memory
'
)
{
return
createMemoryDescription
(
username
,
application_name
);
}
throw
new
TypeError
(
"
Unknown LocalStorage '
"
+
mode
.
toString
()
+
"
' mode
"
);
}
exports
.
createDescription
=
createDescription
;
exports
.
createLocalDescription
=
createLocalDescription
;
exports
.
createMemoryDescription
=
createMemoryDescription
;
function
clear
()
{
function
clear
LocalStorage
()
{
var
k
;
for
(
k
in
localStorage
)
{
if
(
localStorage
.
hasOwnProperty
(
k
))
{
...
...
@@ -700,12 +723,13 @@
}
}
}
exports
.
clear
=
clear
;
exports
.
clearLocalStorage
=
clear
;
function
clearMemoryStorage
()
{
jIO
.
util
.
dictClear
(
ram
);
}
exports
.
clear
=
clearLocalStorage
;
exports
.
clearLocalStorage
=
clearLocalStorage
;
exports
.
clearMemoryStorage
=
clearMemoryStorage
;
}));
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