Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
docs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
docs
Commits
7fca3b81
Commit
7fca3b81
authored
May 17, 2017
by
Conor Broderick
Committed by
Brian Brazil
May 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated routing-tree-editor (#728)
parent
6ac3790a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
39 deletions
+23
-39
routing-tree.js
static/routing-tree.js
+23
-39
No files found.
static/routing-tree.js
View file @
7fca3b81
...
...
@@ -57,26 +57,20 @@ d3.select(".js-parse-and-draw").on("click", function() {
// Click handler for input labelSet
d3
.
select
(
"
.js-find-match
"
).
on
(
"
click
"
,
function
()
{
labelServiceHandler
();
});
d3
.
select
(
document
).
on
(
"
keyup
"
,
function
(
e
)
{
if
(
d3
.
event
.
keyCode
!=
13
)
{
return
;
}
labelServiceHandler
();
});
function
labelServiceHandler
()
{
var
searchValue
=
document
.
querySelector
(
"
.js-label-set-input
"
).
value
var
searchValue
=
document
.
querySelector
(
"
input
"
).
value
var
labelSet
=
parseSearch
(
searchValue
);
var
matches
=
match
(
root
,
labelSet
)
var
nodes
=
tree
.
nodes
(
root
);
var
idx
=
nodes
.
map
(
function
(
n
)
{
return
n
.
id
}).
indexOf
(
matches
[
0
].
id
)
nodes
.
forEach
(
function
(
n
)
{
n
.
matched
=
false
});
nodes
[
idx
].
matched
=
true
;
var
matchedIds
=
matches
.
map
(
function
(
n
)
{
return
n
.
id
;
});
nodes
.
forEach
(
function
(
n
)
{
if
(
matchedIds
.
indexOf
(
n
.
id
)
>
-
1
)
{
n
.
matched
=
true
;
}
else
{
n
.
matched
=
false
;
}
});
update
(
root
);
}
}
);
// Match does a depth-first left-to-right search through the route tree
// and returns the matching routing nodes.
...
...
@@ -90,12 +84,12 @@ function match(root, labelSet) {
if
(
root
.
children
)
{
for
(
var
j
=
0
;
j
<
root
.
children
.
length
;
j
++
)
{
child
=
root
.
children
[
j
];
matches
=
match
(
child
,
labelSet
)
var
child
=
root
.
children
[
j
];
var
matches
=
match
(
child
,
labelSet
);
all
=
all
.
concat
(
matches
);
if
(
matches
&&
!
child
.
continue
)
{
if
(
matches
.
length
&&
!
child
.
continue
)
{
break
;
}
}
...
...
@@ -147,10 +141,6 @@ function massage(root) {
root
.
children
=
root
.
routes
if
(
root
.
continue
!=
false
)
{
root
.
continue
=
true
;
}
var
matchers
=
[]
if
(
root
.
match
)
{
for
(
var
key
in
root
.
match
)
{
...
...
@@ -188,27 +178,21 @@ function update(root) {
var
nodes
=
tree
.
nodes
(
root
);
var
links
=
tree
.
links
(
nodes
);
var
matchedNode
=
nodes
.
find
(
function
(
n
)
{
return
n
.
matched
})
var
matchedNode
s
=
nodes
.
filter
(
function
(
n
)
{
return
n
.
matched
})
var
highlight
=
[];
if
(
matchedNode
)
{
highlight
=
[
matchedNode
]
while
(
matchedNode
.
parent
)
{
highlight
.
push
(
matchedNode
.
parent
);
matchedNode
=
matchedNode
.
parent
;
if
(
matchedNodes
.
length
)
{
highlight
=
matchedNodes
matchedNodes
.
forEach
(
function
(
n
)
{
var
mn
=
n
while
(
mn
.
parent
)
{
highlight
.
push
(
mn
.
parent
);
mn
=
mn
.
parent
;
}
}
});
}
var
link
=
svg
.
selectAll
(
"
.link
"
).
data
(
links
);
var
drawSimple
=
nodes
.
length
<
3
?
true
:
false
;
if
(
drawSimple
)
{
// Algorithm fails to assign x attributes if nodes.length < 3. For this
// simple case, manually assign values.
nodes
.
forEach
(
function
(
n
,
i
)
{
n
.
x
=
i
*
180
+
90
;
});
}
link
.
enter
().
append
(
"
path
"
)
.
attr
(
"
class
"
,
"
link
"
)
.
attr
(
"
d
"
,
diagonal
);
...
...
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