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
Aurélien Vermylen
jio
Commits
8d6a1755
Commit
8d6a1755
authored
Dec 20, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getLeavesOnTree and getActiveLeaf replaced by getLeavesFromDocumentTree
parent
fb26b7e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
44 deletions
+22
-44
src/jio.storage/intro.js
src/jio.storage/intro.js
+22
-44
No files found.
src/jio.storage/intro.js
View file @
8d6a1755
...
@@ -440,53 +440,31 @@ var utilities = {
...
@@ -440,53 +440,31 @@ var utilities = {
return
result
.
rev
;
return
result
.
rev
;
},
},
getActiveLeaves
:
function
(
docTreeNode
)
{
var
activeLeaves
=
utilities
.
getLeavesOnTree
(
docTreeNode
);
activeLeaves
=
typeof
activeLeaves
===
"
string
"
?
[
activeLeaves
]
:
activeLeaves
;
return
activeLeaves
;
},
/**
/**
*
@method getLeavesOnTree - finds all leaves on a
tree
*
Gets an array of leaves revisions from document
tree
* @
param {docTree} string - the tree for this document
* @
method getLeavesFromDocumentTree
* @
returns {leaves} object - array with all leaves
* @
param {object} document_tree The document tree
* @
info - find active (status = available ) leave
s
* @
return {array} The array of leaves revision
s
*/
*/
getLeavesOnTree
:
function
(
docTreeNode
){
getLeavesFromDocumentTree
:
function
(
document_tree
)
{
var
revisions
=
[],
var
i
,
result
,
search
;
type
=
docTreeNode
[
'
type
'
],
result
=
[];
status
=
docTreeNode
[
'
status
'
],
// search method fills [result] with the winner revision
kids
=
docTreeNode
[
'
kids
'
],
search
=
function
(
document_tree
)
{
rev
=
docTreeNode
[
'
rev
'
],
var
i
;
addLeaf
,
addLeaves
,
numberOfKids
,
i
,
key
;
if
(
document_tree
.
children
.
length
===
0
)
{
// This node is a leaf
for
(
key
in
docTreeNode
){
result
.
push
(
document_tree
.
rev
);
if
(
key
===
"
type
"
){
return
;
// node is a leaf, then it will have no kids!
if
(
type
===
'
leaf
'
&&
status
!==
'
deleted
'
){
addLeaf
=
docTreeNode
[
'
rev
'
];
}
// node has kid(s), must be a branch
if
(
utilities
.
isObjectEmpty
(
kids
)
===
false
){
numberOfKids
=
utilities
.
isObjectSize
(
kids
);
for
(
i
=
0
;
i
<
numberOfKids
;
i
+=
1
){
// recurse
addLeaves
=
utilities
.
getLeavesOnTree
(
kids
[
i
]
);
// single kid returns string 1-1234... = unshift
// multiple kids array [1-1234...,3-3412...] = concat
revisions
=
addLeaves
===
'
string
'
?
revisions
.
unshift
[
addLeaves
]
:
revisions
.
concat
(
addLeaves
);
}
}
}
}
}
// This node has children
// for recursiveness:
for
(
i
=
0
;
i
<
document_tree
.
children
.
length
;
i
+=
1
)
{
// no kids = passback string, multiple kids, pass back array
// searching deeper to find the deeper leaf
return
(
addLeaf
===
undefined
?
revisions
:
addLeaf
);
search
(
document_tree
.
children
[
i
]);
}
};
search
(
document_tree
);
return
result
;
},
},
/**
/**
...
...
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