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
Bryan Kaperick
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
Show 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 ) {
...
@@ -38,11 +38,11 @@ var newLocalStorage = function ( spec, my ) {
* @methode generateNextRev
* @methode generateNextRev
* @param {string} previous_revision The previous revision
* @param {string} previous_revision The previous revision
* @param {string} string String to help generate hash code
* @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
)
{
priv
.
generateNextRev
=
function
(
previous_revision
,
string
)
{
return
(
parseInt
(
previous_revision
.
split
(
'
-
'
)[
0
],
10
)
+
1
)
+
'
-
'
+
return
[
parseInt
(
previous_revision
.
split
(
'
-
'
)[
0
],
10
)
+
1
,
priv
.
hashCode
(
previous_revision
+
string
)
;
priv
.
hashCode
(
previous_revision
+
string
)]
;
};
};
/**
/**
...
@@ -312,7 +312,7 @@ var newLocalStorage = function ( spec, my ) {
...
@@ -312,7 +312,7 @@ var newLocalStorage = function ( spec, my ) {
var
now
=
Date
.
now
();
var
now
=
Date
.
now
();
// wait a little in order to simulate asynchronous saving
// wait a little in order to simulate asynchronous saving
setTimeout
(
function
()
{
setTimeout
(
function
()
{
var
docid
,
doc
,
docpath
,
attmtid
,
attmt
,
attmtpath
,
prev_rev
;
var
docid
,
doc
,
docpath
,
attmtid
,
attmt
,
attmtpath
,
prev_rev
,
rev
;
docid
=
command
.
getDocId
();
docid
=
command
.
getDocId
();
prev_rev
=
command
.
getDocInfo
(
'
_rev
'
);
prev_rev
=
command
.
getDocInfo
(
'
_rev
'
);
docpath
=
'
jio/local/
'
+
priv
.
secured_username
+
'
/
'
+
docpath
=
'
jio/local/
'
+
priv
.
secured_username
+
'
/
'
+
...
@@ -360,11 +360,20 @@ var newLocalStorage = function ( spec, my ) {
...
@@ -360,11 +360,20 @@ var newLocalStorage = function ( spec, my ) {
// update document metadata
// update document metadata
priv
.
documentObjectUpdate
(
doc
,
command
.
cloneDoc
());
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
);
localstorage
.
setItem
(
docpath
,
doc
);
that
.
success
(
that
.
success
(
priv
.
manageOptions
(
priv
.
manageOptions
(
{
ok
:
true
,
id
:
docid
,
rev
:
doc
.
_rev
},
{
"
ok
"
:
true
,
"
id
"
:
docid
,
"
rev
"
:
doc
.
_rev
},
command
,
command
,
doc
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