Commit c0d312bebe8ba68b842788e4715c5c8a1612bb29
1 parent
b7e5f455
Exists in
master
and in
4 other branches
Refactor: Removing a if statement, because the nil value is already removed in the view template.
Showing
1 changed file
with
47 additions
and
49 deletions
Show diff stats
app/assets/javascripts/branch-graph.js
... | ... | @@ -118,58 +118,56 @@ |
118 | 118 | for (var j = 0, jj = this.commits[i].parents.length; j < jj; j++) { |
119 | 119 | c = this.preparedCommits[this.commits[i].parents[j][0]]; |
120 | 120 | ps = this.commits[i].parents[j][1]; |
121 | - if (c) { | |
122 | - var cx = offsetX + 20 * c.time | |
123 | - , cy = offsetY + 10 * c.space | |
124 | - , psy = offsetY + 10 * ps; | |
125 | - if (c.space == this.commits[i].space && c.space == ps) { | |
126 | - r.path([ | |
127 | - "M", x, y, | |
128 | - "L", cx, cy | |
129 | - ]).attr({ | |
130 | - stroke: this.colors[c.space], | |
131 | - "stroke-width": 2 | |
132 | - }); | |
121 | + var cx = offsetX + 20 * c.time | |
122 | + , cy = offsetY + 10 * c.space | |
123 | + , psy = offsetY + 10 * ps; | |
124 | + if (c.space == this.commits[i].space && c.space == ps) { | |
125 | + r.path([ | |
126 | + "M", x, y, | |
127 | + "L", cx, cy | |
128 | + ]).attr({ | |
129 | + stroke: this.colors[c.space], | |
130 | + "stroke-width": 2 | |
131 | + }); | |
133 | 132 | |
134 | - } else if (c.space < this.commits[i].space) { | |
135 | - if (y == psy) { | |
136 | - r.path([ | |
137 | - "M", x - 5, y, | |
138 | - "l-5,-2,0,4,5,-2", | |
139 | - "L", x - 10, y, | |
140 | - "L", x - 15, psy, | |
141 | - "L", cx + 5, psy, | |
142 | - "L", cx, cy]) | |
143 | - .attr({ | |
144 | - stroke: this.colors[this.commits[i].space], | |
145 | - "stroke-width": 2 | |
146 | - }); | |
147 | - } else { | |
148 | - r.path([ | |
149 | - "M", x - 3, y - 6, | |
150 | - "l-4,-3,4,-2,0,5", | |
151 | - "L", x - 5, y - 10, | |
152 | - "L", x - 10, psy, | |
153 | - "L", cx + 5, psy, | |
154 | - "L", cx, cy]) | |
155 | - .attr({ | |
156 | - stroke: this.colors[this.commits[i].space], | |
157 | - "stroke-width": 2 | |
158 | - }); | |
159 | - } | |
133 | + } else if (c.space < this.commits[i].space) { | |
134 | + if (y == psy) { | |
135 | + r.path([ | |
136 | + "M", x - 5, y, | |
137 | + "l-5,-2,0,4,5,-2", | |
138 | + "L", x - 10, y, | |
139 | + "L", x - 15, psy, | |
140 | + "L", cx + 5, psy, | |
141 | + "L", cx, cy]) | |
142 | + .attr({ | |
143 | + stroke: this.colors[this.commits[i].space], | |
144 | + "stroke-width": 2 | |
145 | + }); | |
160 | 146 | } else { |
161 | - r.path([ | |
162 | - "M", x - 3, y + 6, | |
163 | - "l-4,3,4,2,0,-5", | |
164 | - "L", x - 5, y + 10, | |
165 | - "L", x - 10, psy, | |
166 | - "L", cx + 5, psy, | |
167 | - "L", cx, cy]) | |
168 | - .attr({ | |
169 | - stroke: this.colors[c.space], | |
170 | - "stroke-width": 2 | |
171 | - }); | |
147 | + r.path([ | |
148 | + "M", x - 3, y - 6, | |
149 | + "l-4,-3,4,-2,0,5", | |
150 | + "L", x - 5, y - 10, | |
151 | + "L", x - 10, psy, | |
152 | + "L", cx + 5, psy, | |
153 | + "L", cx, cy]) | |
154 | + .attr({ | |
155 | + stroke: this.colors[this.commits[i].space], | |
156 | + "stroke-width": 2 | |
157 | + }); | |
172 | 158 | } |
159 | + } else { | |
160 | + r.path([ | |
161 | + "M", x - 3, y + 6, | |
162 | + "l-4,3,4,2,0,-5", | |
163 | + "L", x - 5, y + 10, | |
164 | + "L", x - 10, psy, | |
165 | + "L", cx + 5, psy, | |
166 | + "L", cx, cy]) | |
167 | + .attr({ | |
168 | + stroke: this.colors[c.space], | |
169 | + "stroke-width": 2 | |
170 | + }); | |
173 | 171 | } |
174 | 172 | } |
175 | 173 | ... | ... |