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
Vincent Bechu
jio
Commits
24e675ce
Commit
24e675ce
authored
Dec 21, 2012
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localstorage putAttachment
parent
abe7251f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
22 deletions
+54
-22
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+54
-22
No files found.
src/jio.storage/localstorage.js
View file @
24e675ce
...
...
@@ -154,12 +154,25 @@ var newLocalStorage = function (spec, my) {
* Create a new document
* @param {object} command Command object
*/
priv
.
runDocumen
Create
=
function
(
command
)
{
priv
.
document
Create
=
function
(
command
)
{
var
document_id
=
command
.
getDocId
(),
var
now
=
Date
.
now
(),
doc
=
{},
hash
=
that
.
hashCode
(
''
+
doc
+
'
'
+
now
+
''
),
document_id
=
command
.
getDocId
(),
document_path
=
'
jio/local/
'
+
priv
.
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
+
document_id
,
doc
=
that
.
createDocument
(
document_id
,
document_path
);
priv
.
applicationname
+
'
/
'
+
document_id
;
doc
.
_id
=
document_id
;
doc
.
_rev
=
'
1-
'
+
hash
;
doc
.
_revisions
=
{
start
:
1
,
ids
:
[
hash
]
};
doc
.
_revs_info
=
[{
rev
:
'
1-
'
+
hash
,
status
:
'
available
'
}];
localstorage
.
setItem
(
document_path
,
doc
);
...
...
@@ -177,15 +190,28 @@ var newLocalStorage = function (spec, my) {
* Update a document
* @param {object} command Command object
*/
priv
.
runD
ocumentUpdate
=
function
(
command
,
doc
)
{
priv
.
d
ocumentUpdate
=
function
(
command
,
doc
)
{
var
document_id
=
command
.
getDocId
(),
var
now
=
Date
.
now
(),
rev
=
that
.
generateNextRevision
(
previousRevision
,
''
+
doc
+
'
'
+
now
+
''
),
document_id
=
command
.
getDocId
(),
document_path
=
'
jio/local/
'
+
priv
.
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
+
document_id
;
priv
.
applicationname
+
'
/
'
+
document_id
,
doc
=
command
.
getDoc
();
doc
.
_rev
=
rev
.
join
(
'
-
'
);
doc
.
_revisions
.
ids
.
unshift
(
rev
[
1
]);
doc
.
_revisions
.
start
=
rev
[
0
];
doc
.
_revs_info
[
0
].
status
=
'
deleted
'
;
doc
.
_revs_info
.
unshift
({
"
rev
"
:
rev
.
join
(
'
-
'
),
"
status
"
:
"
available
"
});
priv
.
documentObjectUpdate
(
doc
,
command
.
cloneDoc
());
localstorage
.
setItem
(
document_
id
,
command
.
getContent
()
);
localstorage
.
setItem
(
document_
path
,
doc
);
return
priv
.
manageOptions
(
{
ok
:
true
,
id
:
document_id
,
rev
:
doc
.
_rev
},
command
,
doc
);
...
...
@@ -209,8 +235,10 @@ var newLocalStorage = function (spec, my) {
};
/**
* @method _post - Create a document in local storage.
* @stored - 'jio/local/USR/APP/FILE_NAME/REVISION'.
* Create a document in local storage.
* Saved at 'jio/local/USR/APP/FILE_NAME/REVISION'.
* @method _post
* @param {object} command The JIO command
*
* Available options:
* - {boolean} conflicts - Add a conflicts object to the response
...
...
@@ -220,49 +248,53 @@ var newLocalStorage = function (spec, my) {
*/
that
.
_post
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
(
priv
.
runDocumen
Create
(
command
));
that
.
success
(
priv
.
document
Create
(
command
));
});
};
/**
* @method _put - Create or Update a document in local storage.
* @stored - 'jio/local/USR/APP/FILE_NAME/REVISION'.
* Create or update a document in local storage.
* Saved at 'jio/local/USR/APP/FILE_NAME/REVISION'.
* @method _put
* @param {object} command The JIO command
*
* Available options:
* - {boolean} conflicts - Add a conflicts object to the response
* - {boolean} revs - Add the revisions history of the document
* - {boolean} revs_info - Add revisions informations
*
*/
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
.
runDocumen
Create
(
command
));
that
.
success
(
priv
.
document
Create
(
command
));
}
else
{
that
.
success
(
priv
.
runD
ocumentUpdate
(
command
,
doc
));
that
.
success
(
priv
.
d
ocumentUpdate
(
command
,
doc
));
}
});
};
/**
* @method putAttachment - Saves/updates an attachment of a document
* @stored at - 'jio/local/USR/APP/FILE_NAME/REVISION/ATTACHMENTID'.
* Add an attachment to a document.
* Saved at 'jio/local/USR/APP/FILE_NAME/REVISION/ATTACHMENTID'.
* @method _putAttachment
* @param {object} command The JIO command
*
* Available options:
* - {boolean} conflicts - Add a conflicts object to the response
* - {boolean} revs - Add the revisions history of the document
* - {boolean} revs_info - Add revisions informations
*
*/
that
.
_putAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
success
(
priv
.
runDocumenUpdate
(
command
));
});
};
// Overriding storage get
...
...
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