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
Kirill Smelkov
jio
Commits
f1940cd1
Commit
f1940cd1
authored
Dec 26, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localstorage.js post method improved
parent
447c8c4d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+16
-4
No files found.
src/jio.storage/localstorage.js
View file @
f1940cd1
...
@@ -95,9 +95,19 @@ var newLocalStorage = function (spec, my) {
...
@@ -95,9 +95,19 @@ var newLocalStorage = function (spec, my) {
*/
*/
that
.
post
=
function
(
command
)
{
that
.
post
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
var
doc
;
var
doc
=
command
.
getDocId
();
if
(
!
(
typeof
doc
===
"
string
"
&&
doc
!==
""
))
{
that
.
error
({
"
status
"
:
405
,
"
statusText
"
:
"
Method Not Allowed
"
,
"
error
"
:
"
method_not_allowed
"
,
"
message
"
:
"
Cannot create document which id is undefined
"
,
"
reason
"
:
"
Document id is undefined
"
});
return
;
}
doc
=
localstorage
.
getItem
(
doc
=
localstorage
.
getItem
(
priv
.
localpath
+
"
/
"
+
command
.
getDocId
()
);
priv
.
localpath
+
"
/
"
+
doc
);
if
(
doc
===
null
)
{
if
(
doc
===
null
)
{
// the document does not exists
// the document does not exists
localstorage
.
setItem
(
localstorage
.
setItem
(
...
@@ -247,7 +257,8 @@ var newLocalStorage = function (spec, my) {
...
@@ -247,7 +257,8 @@ var newLocalStorage = function (spec, my) {
priv
.
localpath
+
"
/
"
+
command
.
getDocId
()
+
"
/
"
+
priv
.
localpath
+
"
/
"
+
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
());
command
.
getAttachmentId
());
// remove attachment from document
// remove attachment from document
if
(
typeof
doc
[
"
_attachments
"
]
===
"
object
"
)
{
if
(
doc
!==
null
&&
typeof
doc
===
"
object
"
&&
typeof
doc
[
"
_attachments
"
]
===
"
object
"
)
{
delete
doc
[
"
_attachments
"
][
command
.
getAttachmentId
()];
delete
doc
[
"
_attachments
"
][
command
.
getAttachmentId
()];
if
(
priv
.
objectIsEmpty
(
doc
[
"
_attachments
"
]))
{
if
(
priv
.
objectIsEmpty
(
doc
[
"
_attachments
"
]))
{
delete
doc
[
"
_attachments
"
];
delete
doc
[
"
_attachments
"
];
...
@@ -263,7 +274,8 @@ var newLocalStorage = function (spec, my) {
...
@@ -263,7 +274,8 @@ var newLocalStorage = function (spec, my) {
}
else
{
}
else
{
// seeking for a document
// seeking for a document
var
attachment_list
=
[],
i
;
var
attachment_list
=
[],
i
;
if
(
typeof
doc
[
"
_attachments
"
]
===
"
object
"
)
{
if
(
doc
!==
null
&&
typeof
doc
===
"
object
"
&&
typeof
doc
[
"
_attachments
"
]
===
"
object
"
)
{
// prepare list of attachments
// prepare list of attachments
for
(
i
in
doc
[
"
_attachments
"
])
{
for
(
i
in
doc
[
"
_attachments
"
])
{
attachment_list
.
push
(
i
);
attachment_list
.
push
(
i
);
...
...
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