mercurial/templates/static/mercurial.js
author Alexander Plavin <alexander@plav.in>
Fri, 06 Sep 2013 13:30:58 +0400
changeset 19754 c35e8805cf53
parent 19746 9ad7dd9574a9
child 19755 00b9f6aab761
permissions -rw-r--r--
hgweb: show a message when there are no more entries in the list
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
     1
// mercurial.js - JavaScript utility functions
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
     2
//
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
     3
// Rendering of branch DAGs on the client side
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
     4
// Display of elapsed time
14571
17c0cb1045e5 paper, coal: display diffstat on the changeset page
Steven Brown <StevenGBrown@gmail.com>
parents: 14046
diff changeset
     5
// Show or hide diffstat
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
     6
//
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
     7
// Copyright 2008 Dirkjan Ochtman <dirkjan AT ochtman DOT nl>
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
     8
// Copyright 2006 Alexander Schremmer <alex AT alexanderweb DOT de>
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
     9
//
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    10
// derived from code written by Scott James Remnant <scott@ubuntu.com>
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    11
// Copyright 2005 Canonical Ltd.
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    12
//
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    13
// This software may be used and distributed according to the terms
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    14
// of the GNU General Public License, incorporated herein by reference.
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    15
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    16
var colors = [
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    17
	[ 1.0, 0.0, 0.0 ],
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    18
	[ 1.0, 1.0, 0.0 ],
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    19
	[ 0.0, 1.0, 0.0 ],
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    20
	[ 0.0, 1.0, 1.0 ],
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    21
	[ 0.0, 0.0, 1.0 ],
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    22
	[ 1.0, 0.0, 1.0 ]
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    23
];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    24
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    25
function Graph() {
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
    26
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    27
	this.canvas = document.getElementById('graph');
17694
fa714f3ed298 hgweb: change IE canvas test (issue3639)
Matt Mackall <mpm@selenic.com>
parents: 16138
diff changeset
    28
	if (window.G_vmlCanvasManager) this.canvas = window.G_vmlCanvasManager.initElement(this.canvas);
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    29
	this.ctx = this.canvas.getContext('2d');
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    30
	this.ctx.strokeStyle = 'rgb(0, 0, 0)';
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    31
	this.ctx.fillStyle = 'rgb(0, 0, 0)';
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    32
	this.cur = [0, 0];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    33
	this.line_width = 3;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    34
	this.bg = [0, 4];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    35
	this.cell = [2, 0];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    36
	this.columns = 0;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    37
	this.revlink = '';
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
    38
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    39
	this.scale = function(height) {
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    40
		this.bg_height = height;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    41
		this.box_size = Math.floor(this.bg_height / 1.2);
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    42
		this.cell_height = this.box_size;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    43
	}
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
    44
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    45
	function colorPart(num) {
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    46
		num *= 255
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    47
		num = num < 0 ? 0 : num;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    48
		num = num > 255 ? 255 : num;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    49
		var digits = Math.round(num).toString(16);
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    50
		if (num < 16) {
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    51
			return '0' + digits;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    52
		} else {
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    53
			return digits;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    54
		}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    55
	}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    56
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    57
	this.setColor = function(color, bg, fg) {
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
    58
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    59
		// Set the colour.
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    60
		//
16138
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    61
		// If color is a string, expect an hexadecimal RGB
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    62
		// value and apply it unchanged. If color is a number,
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    63
		// pick a distinct colour based on an internal wheel;
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    64
		// the bg parameter provides the value that should be
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    65
		// assigned to the 'zero' colours and the fg parameter
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    66
		// provides the multiplier that should be applied to
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    67
		// the foreground colours.
16130
33f702e52906 graph: in hgrc specify line color for main branch
Constantine Linnick <theaspect@gmail.com>
parents: 16129
diff changeset
    68
		var s;
16138
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    69
		if(typeof color == "string") {
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    70
			s = "#" + color;
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    71
		} else { //typeof color == "number"
16130
33f702e52906 graph: in hgrc specify line color for main branch
Constantine Linnick <theaspect@gmail.com>
parents: 16129
diff changeset
    72
			color %= colors.length;
33f702e52906 graph: in hgrc specify line color for main branch
Constantine Linnick <theaspect@gmail.com>
parents: 16129
diff changeset
    73
			var red = (colors[color][0] * fg) || bg;
33f702e52906 graph: in hgrc specify line color for main branch
Constantine Linnick <theaspect@gmail.com>
parents: 16129
diff changeset
    74
			var green = (colors[color][1] * fg) || bg;
33f702e52906 graph: in hgrc specify line color for main branch
Constantine Linnick <theaspect@gmail.com>
parents: 16129
diff changeset
    75
			var blue = (colors[color][2] * fg) || bg;
33f702e52906 graph: in hgrc specify line color for main branch
Constantine Linnick <theaspect@gmail.com>
parents: 16129
diff changeset
    76
			red = Math.round(red * 255);
33f702e52906 graph: in hgrc specify line color for main branch
Constantine Linnick <theaspect@gmail.com>
parents: 16129
diff changeset
    77
			green = Math.round(green * 255);
33f702e52906 graph: in hgrc specify line color for main branch
Constantine Linnick <theaspect@gmail.com>
parents: 16129
diff changeset
    78
			blue = Math.round(blue * 255);
33f702e52906 graph: in hgrc specify line color for main branch
Constantine Linnick <theaspect@gmail.com>
parents: 16129
diff changeset
    79
			s = 'rgb(' + red + ', ' + green + ', ' + blue + ')';
33f702e52906 graph: in hgrc specify line color for main branch
Constantine Linnick <theaspect@gmail.com>
parents: 16129
diff changeset
    80
		}
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    81
		this.ctx.strokeStyle = s;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    82
		this.ctx.fillStyle = s;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    83
		return s;
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
    84
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    85
	}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    86
16138
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    87
	this.edge = function(x0, y0, x1, y1, color, width) {
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
    88
16137
8fd18eb8aab7 templates: move Graph.edge() implementation in mercurial.js
Patrick Mezard <patrick@mezard.eu>
parents: 16130
diff changeset
    89
		this.setColor(color, 0.0, 0.65);
16138
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    90
		if(width >= 0)
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
    91
			 this.ctx.lineWidth = width;
16137
8fd18eb8aab7 templates: move Graph.edge() implementation in mercurial.js
Patrick Mezard <patrick@mezard.eu>
parents: 16130
diff changeset
    92
		this.ctx.beginPath();
8fd18eb8aab7 templates: move Graph.edge() implementation in mercurial.js
Patrick Mezard <patrick@mezard.eu>
parents: 16130
diff changeset
    93
		this.ctx.moveTo(x0, y0);
8fd18eb8aab7 templates: move Graph.edge() implementation in mercurial.js
Patrick Mezard <patrick@mezard.eu>
parents: 16130
diff changeset
    94
		this.ctx.lineTo(x1, y1);
8fd18eb8aab7 templates: move Graph.edge() implementation in mercurial.js
Patrick Mezard <patrick@mezard.eu>
parents: 16130
diff changeset
    95
		this.ctx.stroke();
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
    96
16137
8fd18eb8aab7 templates: move Graph.edge() implementation in mercurial.js
Patrick Mezard <patrick@mezard.eu>
parents: 16130
diff changeset
    97
	}
8fd18eb8aab7 templates: move Graph.edge() implementation in mercurial.js
Patrick Mezard <patrick@mezard.eu>
parents: 16130
diff changeset
    98
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
    99
	this.render = function(data) {
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   100
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   101
		var backgrounds = '';
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   102
		var nodedata = '';
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   103
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   104
		for (var i in data) {
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   105
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   106
			var parity = i % 2;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   107
			this.cell[1] += this.bg_height;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   108
			this.bg[1] += this.bg_height;
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   109
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   110
			var cur = data[i];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   111
			var node = cur[1];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   112
			var edges = cur[2];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   113
			var fold = false;
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   114
16138
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
   115
			var prevWidth = this.ctx.lineWidth;
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   116
			for (var j in edges) {
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   117
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   118
				line = edges[j];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   119
				start = line[0];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   120
				end = line[1];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   121
				color = line[2];
16138
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
   122
				var width = line[3];
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
   123
				if(width < 0)
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
   124
					 width = prevWidth;
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
   125
				var branchcolor = line[4];
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
   126
				if(branchcolor)
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
   127
					color = branchcolor;
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   128
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   129
				if (end > this.columns || start > this.columns) {
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   130
					this.columns += 1;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   131
				}
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   132
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   133
				if (start == this.columns && start > end) {
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   134
					var fold = true;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   135
				}
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   136
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   137
				x0 = this.cell[0] + this.box_size * start + this.box_size / 2;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   138
				y0 = this.bg[1] - this.bg_height / 2;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   139
				x1 = this.cell[0] + this.box_size * end + this.box_size / 2;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   140
				y1 = this.bg[1] + this.bg_height / 2;
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   141
16138
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
   142
				this.edge(x0, y0, x1, y1, color, width);
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   143
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   144
			}
16138
6e4de55a41a4 hgweb: refactor graph customization javascript
Patrick Mezard <patrick@mezard.eu>
parents: 16137
diff changeset
   145
			this.ctx.lineWidth = prevWidth;
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   146
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   147
			// Draw the revision node in the right column
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   148
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   149
			column = node[0]
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   150
			color = node[1]
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   151
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   152
			radius = this.box_size / 8;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   153
			x = this.cell[0] + this.box_size * column + this.box_size / 2;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   154
			y = this.bg[1] - this.bg_height / 2;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   155
			var add = this.vertex(x, y, color, parity, cur);
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   156
			backgrounds += add[0];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   157
			nodedata += add[1];
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   158
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   159
			if (fold) this.columns -= 1;
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   160
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   161
		}
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   162
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   163
		document.getElementById('nodebgs').innerHTML += backgrounds;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   164
		document.getElementById('graphnodes').innerHTML += nodedata;
19530
a63d3ff0d765 hgweb: remove trailing whitespace in mercurial.js
Kevin Bullock <kbullock@ringworld.org>
parents: 19430
diff changeset
   165
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   166
	}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   167
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   168
}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   169
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   170
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   171
process_dates = (function(document, RegExp, Math, isNaN, Date, _false, _true){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   172
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   173
	// derived from code from mercurial/templatefilter.py
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   174
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   175
	var scales = {
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   176
		'year':  365 * 24 * 60 * 60,
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   177
		'month':  30 * 24 * 60 * 60,
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   178
		'week':    7 * 24 * 60 * 60,
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   179
		'day':    24 * 60 * 60,
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   180
		'hour':   60 * 60,
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   181
		'minute': 60,
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   182
		'second': 1
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   183
	};
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   184
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   185
	function format(count, string){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   186
		var ret = count + ' ' + string;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   187
		if (count > 1){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   188
			ret = ret + 's';
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   189
		}
14881
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   190
 		return ret;
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   191
 	}
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   192
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   193
	function shortdate(date){
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   194
		var ret = date.getFullYear() + '-';
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   195
		// getMonth() gives a 0-11 result
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   196
		var month = date.getMonth() + 1;
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   197
		if (month <= 9){
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   198
			ret += '0' + month;
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   199
		} else {
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   200
			ret += month;
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   201
		}
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   202
		ret += '-';
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   203
		var day = date.getDate();
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   204
		if (day <= 9){
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   205
			ret += '0' + day;
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   206
		} else {
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   207
			ret += day;
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   208
		}
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   209
		return ret;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   210
	}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   211
14881
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   212
 	function age(datestr){
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   213
 		var now = new Date();
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   214
 		var once = new Date(datestr);
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   215
		if (isNaN(once.getTime())){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   216
			// parsing error
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   217
			return datestr;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   218
		}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   219
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   220
		var delta = Math.floor((now.getTime() - once.getTime()) / 1000);
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   221
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   222
		var future = _false;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   223
		if (delta < 0){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   224
			future = _true;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   225
			delta = -delta;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   226
			if (delta > (30 * scales.year)){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   227
				return "in the distant future";
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   228
			}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   229
		}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   230
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   231
		if (delta > (2 * scales.year)){
14881
2e54387976d4 web: Output a correct date in short format (issue2902)
Benoit Allard <benoit@aeteurope.nl>
parents: 14571
diff changeset
   232
			return shortdate(once);
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   233
		}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   234
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   235
		for (unit in scales){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   236
			var s = scales[unit];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   237
			var n = Math.floor(delta / s);
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   238
			if ((n >= 2) || (s == 1)){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   239
				if (future){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   240
					return format(n, unit) + ' from now';
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   241
				} else {
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   242
					return format(n, unit) + ' ago';
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   243
				}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   244
			}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   245
		}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   246
	}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   247
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   248
	return function(){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   249
		var nodes = document.getElementsByTagName('*');
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   250
		var ageclass = new RegExp('\\bage\\b');
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   251
		var dateclass = new RegExp('\\bdate\\b');
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   252
		for (var i=0; i<nodes.length; ++i){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   253
			var node = nodes[i];
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   254
			var classes = node.className;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   255
			if (ageclass.test(classes)){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   256
				var agevalue = age(node.textContent);
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   257
				if (dateclass.test(classes)){
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   258
					// We want both: date + (age)
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   259
					node.textContent += ' ('+agevalue+')';
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   260
				} else {
19531
26943a6394d4 hgweb: show full date in rfc822 format in tooltips at shortlog page
Alexander Plavin <alexander@plav.in>
parents: 19530
diff changeset
   261
					node.title = node.textContent;
14046
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   262
					node.textContent = agevalue;
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   263
				}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   264
			}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   265
		}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   266
	}
b24e5a708fad web: Made elapsed time calculation dynamic (javascript).
Benoit Allard <benoit@aeteurope.nl>
parents:
diff changeset
   267
})(document, RegExp, Math, isNaN, Date, false, true)
14571
17c0cb1045e5 paper, coal: display diffstat on the changeset page
Steven Brown <StevenGBrown@gmail.com>
parents: 14046
diff changeset
   268
19428
c3cdba6e5d7f hgweb: toggleDiffstat function instead of showDiffstat and hideDiffstat
Alexander Plavin <me@aplavin.ru>
parents: 17694
diff changeset
   269
function toggleDiffstat() {
c3cdba6e5d7f hgweb: toggleDiffstat function instead of showDiffstat and hideDiffstat
Alexander Plavin <me@aplavin.ru>
parents: 17694
diff changeset
   270
    var curdetails = document.getElementById('diffstatdetails').style.display;
c3cdba6e5d7f hgweb: toggleDiffstat function instead of showDiffstat and hideDiffstat
Alexander Plavin <me@aplavin.ru>
parents: 17694
diff changeset
   271
    var curexpand = curdetails == 'none' ? 'inline' : 'none';
c3cdba6e5d7f hgweb: toggleDiffstat function instead of showDiffstat and hideDiffstat
Alexander Plavin <me@aplavin.ru>
parents: 17694
diff changeset
   272
    document.getElementById('diffstatdetails').style.display = curexpand;
c3cdba6e5d7f hgweb: toggleDiffstat function instead of showDiffstat and hideDiffstat
Alexander Plavin <me@aplavin.ru>
parents: 17694
diff changeset
   273
    document.getElementById('diffstatexpand').style.display = curdetails;
14571
17c0cb1045e5 paper, coal: display diffstat on the changeset page
Steven Brown <StevenGBrown@gmail.com>
parents: 14046
diff changeset
   274
}
19430
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   275
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   276
function toggleLinewrap() {
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   277
    function getLinewrap() {
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   278
        var nodes = document.getElementsByClassName('sourcelines');
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   279
        // if there are no such nodes, error is thrown here
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   280
        return nodes[0].classList.contains('wrap');
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   281
    }
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   282
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   283
    function setLinewrap(enable) {
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   284
        var nodes = document.getElementsByClassName('sourcelines');
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   285
        for (var i = 0; i < nodes.length; i++) {
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   286
            if (enable) {
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   287
                nodes[i].classList.add('wrap');
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   288
            } else {
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   289
                nodes[i].classList.remove('wrap');
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   290
            }
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   291
        }
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   292
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   293
        var links = document.getElementsByClassName('linewraplink');
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   294
        for (var i = 0; i < links.length; i++) {
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   295
            links[i].innerHTML = enable ? 'on' : 'off';
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   296
        }
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   297
    }
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   298
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   299
    setLinewrap(!getLinewrap());
5ec5097b4c0f hgweb: add line wrapping switch to file source view
Alexander Plavin <me@aplavin.ru>
parents: 19428
diff changeset
   300
}
19739
5bdc179e58c1 hgweb: add format javascript function
Alexander Plavin <alexander@plav.in>
parents: 19531
diff changeset
   301
5bdc179e58c1 hgweb: add format javascript function
Alexander Plavin <alexander@plav.in>
parents: 19531
diff changeset
   302
function format(str, replacements) {
5bdc179e58c1 hgweb: add format javascript function
Alexander Plavin <alexander@plav.in>
parents: 19531
diff changeset
   303
    return str.replace(/%(\w+)%/g, function(match, p1) {
5bdc179e58c1 hgweb: add format javascript function
Alexander Plavin <alexander@plav.in>
parents: 19531
diff changeset
   304
        return String(replacements[p1]);
5bdc179e58c1 hgweb: add format javascript function
Alexander Plavin <alexander@plav.in>
parents: 19531
diff changeset
   305
    });
5bdc179e58c1 hgweb: add format javascript function
Alexander Plavin <alexander@plav.in>
parents: 19531
diff changeset
   306
}
19740
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   307
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   308
function makeRequest(url, method, onstart, onsuccess, onerror, oncomplete) {
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   309
    xfr = new XMLHttpRequest();
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   310
    xfr.onreadystatechange = function() {
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   311
        if (xfr.readyState === 4) {
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   312
            try {
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   313
                if (xfr.status === 200) {
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   314
                    onsuccess(xfr.responseText);
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   315
                } else {
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   316
                    throw 'server error';
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   317
                }
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   318
            } catch (e) {
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   319
                onerror(e);
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   320
            } finally {
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   321
                oncomplete();
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   322
            }
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   323
        }
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   324
    };
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   325
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   326
    xfr.open(method, url);
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   327
    xfr.send();
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   328
    onstart();
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   329
    return xfr;
2228bd109706 hgweb: add makeRequest javascript function
Alexander Plavin <alexander@plav.in>
parents: 19739
diff changeset
   330
}
19741
2a9a21e1e1db hgweb: add docFromHTML javascript function
Alexander Plavin <alexander@plav.in>
parents: 19740
diff changeset
   331
19742
ac68009c31a4 hgweb: add removeByClassName javascript function
Alexander Plavin <alexander@plav.in>
parents: 19741
diff changeset
   332
function removeByClassName(className) {
ac68009c31a4 hgweb: add removeByClassName javascript function
Alexander Plavin <alexander@plav.in>
parents: 19741
diff changeset
   333
    var nodes = document.getElementsByClassName(className);
ac68009c31a4 hgweb: add removeByClassName javascript function
Alexander Plavin <alexander@plav.in>
parents: 19741
diff changeset
   334
    while (nodes.length) {
ac68009c31a4 hgweb: add removeByClassName javascript function
Alexander Plavin <alexander@plav.in>
parents: 19741
diff changeset
   335
        nodes[0].parentNode.removeChild(nodes[0]);
ac68009c31a4 hgweb: add removeByClassName javascript function
Alexander Plavin <alexander@plav.in>
parents: 19741
diff changeset
   336
    }
ac68009c31a4 hgweb: add removeByClassName javascript function
Alexander Plavin <alexander@plav.in>
parents: 19741
diff changeset
   337
}
ac68009c31a4 hgweb: add removeByClassName javascript function
Alexander Plavin <alexander@plav.in>
parents: 19741
diff changeset
   338
19741
2a9a21e1e1db hgweb: add docFromHTML javascript function
Alexander Plavin <alexander@plav.in>
parents: 19740
diff changeset
   339
function docFromHTML(html) {
2a9a21e1e1db hgweb: add docFromHTML javascript function
Alexander Plavin <alexander@plav.in>
parents: 19740
diff changeset
   340
    var doc = document.implementation.createHTMLDocument('');
2a9a21e1e1db hgweb: add docFromHTML javascript function
Alexander Plavin <alexander@plav.in>
parents: 19740
diff changeset
   341
    doc.documentElement.innerHTML = html;
2a9a21e1e1db hgweb: add docFromHTML javascript function
Alexander Plavin <alexander@plav.in>
parents: 19740
diff changeset
   342
    return doc;
2a9a21e1e1db hgweb: add docFromHTML javascript function
Alexander Plavin <alexander@plav.in>
parents: 19740
diff changeset
   343
}
19743
fdd41257def8 hgweb: add appendFormatHTML javascript function
Alexander Plavin <alexander@plav.in>
parents: 19742
diff changeset
   344
fdd41257def8 hgweb: add appendFormatHTML javascript function
Alexander Plavin <alexander@plav.in>
parents: 19742
diff changeset
   345
function appendFormatHTML(element, formatStr, replacements) {
fdd41257def8 hgweb: add appendFormatHTML javascript function
Alexander Plavin <alexander@plav.in>
parents: 19742
diff changeset
   346
    element.insertAdjacentHTML('beforeend', format(formatStr, replacements));
fdd41257def8 hgweb: add appendFormatHTML javascript function
Alexander Plavin <alexander@plav.in>
parents: 19742
diff changeset
   347
}
19746
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   348
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   349
function ajaxScrollInit(urlFormat,
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   350
                        nextHash,
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   351
                        nextHashRegex,
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   352
                        containerSelector,
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   353
                        messageFormat) {
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   354
    updateInitiated = false;
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   355
    container = document.querySelector(containerSelector);
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   356
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   357
    function scrollHandler() {
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   358
        if (updateInitiated) {
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   359
            return;
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   360
        }
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   361
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   362
        var scrollHeight = document.documentElement.scrollHeight;
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   363
        var clientHeight = document.documentElement.clientHeight;
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   364
        var scrollTop = document.body.scrollTop
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   365
            || document.documentElement.scrollTop;
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   366
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   367
        if (scrollHeight - (scrollTop + clientHeight) < 50) {
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   368
            updateInitiated = true;
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   369
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   370
            if (!nextHash) {
19754
c35e8805cf53 hgweb: show a message when there are no more entries in the list
Alexander Plavin <alexander@plav.in>
parents: 19746
diff changeset
   371
                var message = {
c35e8805cf53 hgweb: show a message when there are no more entries in the list
Alexander Plavin <alexander@plav.in>
parents: 19746
diff changeset
   372
                    class: 'scroll-loading-info',
c35e8805cf53 hgweb: show a message when there are no more entries in the list
Alexander Plavin <alexander@plav.in>
parents: 19746
diff changeset
   373
                    text: 'No more entries'
c35e8805cf53 hgweb: show a message when there are no more entries in the list
Alexander Plavin <alexander@plav.in>
parents: 19746
diff changeset
   374
                };
c35e8805cf53 hgweb: show a message when there are no more entries in the list
Alexander Plavin <alexander@plav.in>
parents: 19746
diff changeset
   375
                appendFormatHTML(container, messageFormat, message);
19746
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   376
                return;
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   377
            }
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   378
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   379
            makeRequest(
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   380
                format(urlFormat, {hash: nextHash}),
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   381
                'GET',
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   382
                function onstart() {
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   383
                },
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   384
                function onsuccess(htmlText) {
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   385
                    var m = htmlText.match(nextHashRegex);
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   386
                    nextHash = m ? m[1] : null;
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   387
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   388
                    var doc = docFromHTML(htmlText);
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   389
                    var nodes = doc.querySelector(containerSelector).children;
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   390
                    while (nodes.length) {
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   391
                        var node = nodes[0];
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   392
                        node = document.adoptNode(node);
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   393
                        container.appendChild(node);
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   394
                    }
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   395
                    process_dates();
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   396
                },
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   397
                function onerror(errorText) {
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   398
                },
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   399
                function oncomplete() {
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   400
                    updateInitiated = false;
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   401
                    scrollHandler();
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   402
                }
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   403
            );
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   404
        }
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   405
    }
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   406
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   407
    window.addEventListener('scroll', scrollHandler);
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   408
    window.addEventListener('resize', scrollHandler);
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   409
    scrollHandler();
9ad7dd9574a9 hgweb: add ajaxScrollInit function, which does the ajax requests and processing
Alexander Plavin <alexander@plav.in>
parents: 19743
diff changeset
   410
}