comparison tests/test-hgweb-empty.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 5857eb81c1f3
children 27ab3150cd50
comparison
equal deleted inserted replaced
35254:9c99541e3d56 35255:ad0de63e1d6a
305 var data = []; 305 var data = [];
306 var graph = new Graph(); 306 var graph = new Graph();
307 graph.scale(39); 307 graph.scale(39);
308 308
309 graph.vertex = function(x, y, radius, color, parity, cur) { 309 graph.vertex = function(x, y, radius, color, parity, cur) {
310 310 Graph.prototype.vertex.apply(this, arguments);
311 this.ctx.beginPath(); 311 return ['<li class="bg"></li>', ''];
312 color = this.setColor(color, 0.25, 0.75);
313 this.ctx.arc(x, y, radius, 0, Math.PI * 2, true);
314 this.ctx.fill();
315
316 var bg = '<li class="bg"></li>';
317 var left = (this.bg_height - this.box_size) + (this.columns + 1) * this.box_size;
318
319 var item = document.querySelector('[data-node="' + cur.node + '"]');
320 if (item) {
321 item.style.paddingLeft = left + 'px';
322 }
323
324 return [bg, ''];
325
326 } 312 }
327 313
328 graph.render(data); 314 graph.render(data);
329 315
330 // stop hiding script --> 316 // stop hiding script -->