# HG changeset patch # User Anton Shestakov # Date 2017-12-06 04:01:07 # Node ID 9c99541e3d56d275bd89e9d2c80645a9385d5f60 # Parent c2e2437f2b2e1140e00802cbb80d0e287bb375db hgweb: create Graph methods using a prototype This way it's possible to call the original methods even if they were overridden. diff --git a/mercurial/templates/static/mercurial.js b/mercurial/templates/static/mercurial.js --- a/mercurial/templates/static/mercurial.js +++ b/mercurial/templates/static/mercurial.js @@ -33,21 +33,24 @@ function Graph() { 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 @@ function Graph() { 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 @@ function Graph() { this.ctx.lineTo(x1, y1); this.ctx.stroke(); - }; + }, - this.render = function(data) { + render: function(data) { var backgrounds = ''; var nodedata = ''; @@ -155,9 +158,9 @@ function Graph() { document.getElementById('nodebgs').innerHTML += backgrounds; document.getElementById('graphnodes').innerHTML += nodedata; - }; + } -} +}; function process_dates(parentSelector){