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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
jio
Commits
1136a97c
Commit
1136a97c
authored
Nov 23, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localstorage.js put method now modifies revisions history
parent
cc8c320f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+15
-6
No files found.
src/jio.storage/localstorage.js
View file @
1136a97c
...
...
@@ -38,11 +38,11 @@ var newLocalStorage = function ( spec, my ) {
* @methode generateNextRev
* @param {string} previous_revision The previous revision
* @param {string} string String to help generate hash code
* @return {
string} The next revision
* @return {
array} 0:The next revision number and 1:the hash code
*/
priv
.
generateNextRev
=
function
(
previous_revision
,
string
)
{
return
(
parseInt
(
previous_revision
.
split
(
'
-
'
)[
0
],
10
)
+
1
)
+
'
-
'
+
priv
.
hashCode
(
previous_revision
+
string
)
;
return
[
parseInt
(
previous_revision
.
split
(
'
-
'
)[
0
],
10
)
+
1
,
priv
.
hashCode
(
previous_revision
+
string
)]
;
};
/**
...
...
@@ -312,7 +312,7 @@ var newLocalStorage = function ( spec, my ) {
var
now
=
Date
.
now
();
// wait a little in order to simulate asynchronous saving
setTimeout
(
function
()
{
var
docid
,
doc
,
docpath
,
attmtid
,
attmt
,
attmtpath
,
prev_rev
;
var
docid
,
doc
,
docpath
,
attmtid
,
attmt
,
attmtpath
,
prev_rev
,
rev
;
docid
=
command
.
getDocId
();
prev_rev
=
command
.
getDocInfo
(
'
_rev
'
);
docpath
=
'
jio/local/
'
+
priv
.
secured_username
+
'
/
'
+
...
...
@@ -360,11 +360,20 @@ var newLocalStorage = function ( spec, my ) {
// update document metadata
priv
.
documentObjectUpdate
(
doc
,
command
.
cloneDoc
());
}
doc
.
_rev
=
priv
.
generateNextRev
(
prev_rev
,
''
+
doc
+
'
'
+
now
+
''
);
// rev = [number, hash]
rev
=
priv
.
generateNextRev
(
prev_rev
,
''
+
doc
+
'
'
+
now
+
''
);
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
"
});
localstorage
.
setItem
(
docpath
,
doc
);
that
.
success
(
priv
.
manageOptions
(
{
ok
:
true
,
id
:
docid
,
rev
:
doc
.
_rev
},
{
"
ok
"
:
true
,
"
id
"
:
docid
,
"
rev
"
:
doc
.
_rev
},
command
,
doc
)
...
...
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