Mercurial > hg-stable
changeset 35263:9c99541e3d56
hgweb: create Graph methods using a prototype
This way it's possible to call the original methods even if they were
overridden.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 06 Dec 2017 12:01:07 +0800 |
parents | c2e2437f2b2e |
children | ad0de63e1d6a |
files | mercurial/templates/static/mercurial.js |
diffstat | 1 files changed, 14 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templates/static/mercurial.js Wed Dec 06 11:59:19 2017 +0800 +++ b/mercurial/templates/static/mercurial.js Wed Dec 06 12:01:07 2017 +0800 @@ -33,21 +33,24 @@ this.cell = [2, 0]; this.columns = 0; - this.reset = function() { +} + +Graph.prototype = { + reset: function() { this.bg = [0, 4]; this.cell = [2, 0]; this.columns = 0; document.getElementById('nodebgs').innerHTML = ''; document.getElementById('graphnodes').innerHTML = ''; - }; + }, - this.scale = function(height) { + scale: function(height) { this.bg_height = height; this.box_size = Math.floor(this.bg_height / 1.2); this.cell_height = this.box_size; - }; + }, - this.setColor = function(color, bg, fg) { + setColor: function(color, bg, fg) { // Set the colour. // @@ -75,9 +78,9 @@ this.ctx.fillStyle = s; return s; - }; + }, - this.edge = function(x0, y0, x1, y1, color, width) { + edge: function(x0, y0, x1, y1, color, width) { this.setColor(color, 0.0, 0.65); if(width >= 0) @@ -87,9 +90,9 @@ this.ctx.lineTo(x1, y1); this.ctx.stroke(); - }; + }, - this.render = function(data) { + render: function(data) { var backgrounds = ''; var nodedata = ''; @@ -155,9 +158,9 @@ document.getElementById('nodebgs').innerHTML += backgrounds; document.getElementById('graphnodes').innerHTML += nodedata; - }; + } -} +}; function process_dates(parentSelector){