comparison mercurial/templates/gitweb/graph.tmpl @ 35255:ad0de63e1d6a

hgweb: move common vertex code to Graph.prototype Just to give some context to the return values: vertex() needs to return two HTML elements as strings, <li> to be used as a background and a <li> to be shown in foreground. The latter was made obsolete recently when changesets started to be rendered server-side, but background elements are still useful for now.
author Anton Shestakov <av6@dwimlabs.net>
date Wed, 06 Dec 2017 12:10:16 +0800
parents dc623009e0b0
children 27ab3150cd50
comparison
equal deleted inserted replaced
35254:9c99541e3d56 35255:ad0de63e1d6a
48 var data = {jsdata|json}; 48 var data = {jsdata|json};
49 var graph = new Graph(); 49 var graph = new Graph();
50 graph.scale({bg_height}); 50 graph.scale({bg_height});
51 51
52 graph.vertex = function(x, y, radius, color, parity, cur) \{ 52 graph.vertex = function(x, y, radius, color, parity, cur) \{
53 53 Graph.prototype.vertex.apply(this, arguments);
54 this.ctx.beginPath(); 54 return ['<li class="bg parity' + parity + '"></li>', ''];
55 color = this.setColor(color, 0.25, 0.75);
56 this.ctx.arc(x, y, radius, 0, Math.PI * 2, true);
57 this.ctx.fill();
58
59 var bg = '<li class="bg parity' + parity + '"></li>';
60 var left = (this.bg_height - this.box_size) + (this.columns + 1) * this.box_size;
61
62 var item = document.querySelector('[data-node="' + cur.node + '"]');
63 if (item) \{
64 item.style.paddingLeft = left + 'px';
65 }
66
67 return [bg, ''];
68
69 } 55 }
70 56
71 graph.render(data); 57 graph.render(data);
72 58
73 // stop hiding script --> 59 // stop hiding script -->