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
1771adbe
Commit
1771adbe
authored
Dec 21, 2012
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dumb post localstorage
parent
e77cf759
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
32 deletions
+37
-32
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+37
-32
No files found.
src/jio.storage/localstorage.js
View file @
1771adbe
...
@@ -154,27 +154,41 @@ var newLocalStorage = function (spec, my) {
...
@@ -154,27 +154,41 @@ var newLocalStorage = function (spec, my) {
* Create a new document
* Create a new document
* @param {object} command Command object
* @param {object} command Command object
*/
*/
priv
.
runDocumenCreate
=
function
(
docid
,
command
)
{
priv
.
runDocumenCreate
=
function
(
command
)
{
var
doc
I
d
=
command
.
getDocId
(),
var
doc
ument_i
d
=
command
.
getDocId
(),
doc
P
ath
=
'
jio/local/
'
+
priv
.
username
+
'
/
'
+
doc
ument_p
ath
=
'
jio/local/
'
+
priv
.
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
+
doc
I
d
,
priv
.
applicationname
+
'
/
'
+
doc
ument_i
d
,
doc
=
priv
.
createDocument
(
docId
,
docP
ath
);
doc
=
that
.
createDocument
(
document_id
,
document_p
ath
);
// store document
localstorage
.
setItem
(
document_path
,
doc
);
localstorage
.
setItem
(
docPath
+
'
/
'
+
doc
.
_rev
,
doc
);
// add user
if
(
!
priv
.
doesUserExist
(
priv
.
username
))
{
if
(
!
priv
.
doesUserExist
(
priv
.
username
))
{
priv
.
addUser
(
priv
.
username
);
priv
.
addUser
(
priv
.
username
);
}
}
// add fileName
priv
.
addFileName
(
document_id
);
priv
.
addFileName
(
docId
);
// return SUCCESS
return
priv
.
manageOptions
(
return
priv
.
manageOptions
(
{
ok
:
true
,
id
:
docId
,
rev
:
doc
.
_rev
},
command
,
doc
);
{
ok
:
true
,
id
:
document_id
,
rev
:
doc
.
_rev
},
command
,
doc
);
};
/**
* Update a document
* @param {object} command Command object
*/
priv
.
runDocumentUpdate
=
function
(
command
,
doc
)
{
var
document_id
=
command
.
getDocId
(),
document_path
=
'
jio/local/
'
+
priv
.
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
+
document_id
;
priv
.
documentObjectUpdate
(
doc
,
command
.
cloneDoc
());
localstorage
.
setItem
(
document_id
,
command
.
getContent
());
return
priv
.
manageOptions
(
{
ok
:
true
,
id
:
document_id
,
rev
:
doc
.
_rev
},
command
,
doc
);
};
};
// ================== storage overrides =====================
// ================== storage overrides =====================
...
@@ -194,7 +208,6 @@ var newLocalStorage = function (spec, my) {
...
@@ -194,7 +208,6 @@ var newLocalStorage = function (spec, my) {
return
'
Need at least one parameter: "username".
'
;
return
'
Need at least one parameter: "username".
'
;
};
};
// Overriding storage post
/**
/**
* @method _post - Create a document in local storage.
* @method _post - Create a document in local storage.
* @stored - 'jio/local/USR/APP/FILE_NAME/REVISION'.
* @stored - 'jio/local/USR/APP/FILE_NAME/REVISION'.
...
@@ -206,27 +219,13 @@ var newLocalStorage = function (spec, my) {
...
@@ -206,27 +219,13 @@ var newLocalStorage = function (spec, my) {
*
*
*/
*/
that
.
_post
=
function
(
command
)
{
that
.
_post
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
success
(
priv
.
runDocumenCreate
(
command
));
// 403 - no attachments allowed
if
(
command
.
getAttachmentId
())
{
that
.
error
(
that
.
createErrorObject
(
403
,
'
Forbidden
'
,
'
Attachment cannot be added with a POST request
'
)
);
return
;
}
else
{
that
.
success
(
priv
.
runDocumenCreate
(
command
)
);
}
});
});
};
};
// Overriding storage put
/**
/**
* @method put - Create or Update a document in local storage.
* @method
_
put - Create or Update a document in local storage.
* @stored - 'jio/local/USR/APP/FILE_NAME/REVISION'.
* @stored - 'jio/local/USR/APP/FILE_NAME/REVISION'.
*
*
* Available options:
* Available options:
...
@@ -235,14 +234,20 @@ var newLocalStorage = function (spec, my) {
...
@@ -235,14 +234,20 @@ var newLocalStorage = function (spec, my) {
* - {boolean} revs_info - Add revisions informations
* - {boolean} revs_info - Add revisions informations
*/
*/
that
.
_put
=
function
(
command
)
{
that
.
_put
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
var
docid
=
command
.
getDocId
(),
path
=
'
jio/local/
'
+
priv
.
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
+
docid
doc
=
localstorage
.
getItem
(
path
);
if
(
!
doc
)
{
that
.
success
(
priv
.
runDocumenCreate
(
command
));
}
else
{
that
.
success
(
priv
.
runDocumentUpdate
(
command
,
doc
));
}
});
});
};
};
// Overriding storage putAttachment
/**
/**
* @method putAttachment - Saves/updates an attachment of a document
* @method putAttachment - Saves/updates an attachment of a document
* @stored at - 'jio/local/USR/APP/FILE_NAME/REVISION/ATTACHMENTID'.
* @stored at - 'jio/local/USR/APP/FILE_NAME/REVISION/ATTACHMENTID'.
...
...
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