comparison tests/test-hgweb-commands.t @ 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 4a6c51f5ae4d
children 27ab3150cd50
comparison
equal deleted inserted replaced
35254:9c99541e3d56 35255:ad0de63e1d6a
1819 var data = [{"edges": [[0, 0, 1, 3, "FF0000"]], "node": "cad8025a2e87", "vertex": [0, 1]}, {"edges": [[0, 0, 1, 3, ""]], "node": "1d22e65f027e", "vertex": [0, 1]}, {"edges": [[0, 0, 1, 3, ""]], "node": "a4f92ed23982", "vertex": [0, 1]}, {"edges": [], "node": "2ef0ac749a14", "vertex": [0, 1]}]; 1819 var data = [{"edges": [[0, 0, 1, 3, "FF0000"]], "node": "cad8025a2e87", "vertex": [0, 1]}, {"edges": [[0, 0, 1, 3, ""]], "node": "1d22e65f027e", "vertex": [0, 1]}, {"edges": [[0, 0, 1, 3, ""]], "node": "a4f92ed23982", "vertex": [0, 1]}, {"edges": [], "node": "2ef0ac749a14", "vertex": [0, 1]}];
1820 var graph = new Graph(); 1820 var graph = new Graph();
1821 graph.scale(39); 1821 graph.scale(39);
1822 1822
1823 graph.vertex = function(x, y, radius, color, parity, cur) { 1823 graph.vertex = function(x, y, radius, color, parity, cur) {
1824 1824 Graph.prototype.vertex.apply(this, arguments);
1825 this.ctx.beginPath(); 1825 return ['<li class="bg parity' + parity + '"></li>', ''];
1826 color = this.setColor(color, 0.25, 0.75);
1827 this.ctx.arc(x, y, radius, 0, Math.PI * 2, true);
1828 this.ctx.fill();
1829
1830 var bg = '<li class="bg parity' + parity + '"></li>';
1831 var left = (this.bg_height - this.box_size) + (this.columns + 1) * this.box_size;
1832
1833 var item = document.querySelector('[data-node="' + cur.node + '"]');
1834 if (item) {
1835 item.style.paddingLeft = left + 'px';
1836 }
1837
1838 return [bg, ''];
1839
1840 } 1826 }
1841 1827
1842 graph.render(data); 1828 graph.render(data);
1843 1829
1844 // stop hiding script --> 1830 // stop hiding script -->