Mercurial > hg
annotate mercurial/templates/monoblue/graph.tmpl @ 35160:69a865dc2ada
hgweb: define locally used variables as actually local in mercurial.js
Variables that are used or assigned without any declaration using var (or let,
or const) are considered global. In many cases this is inadvertent and actually
causes a variable leaking to a broader scope, such as a temporary variable used
inside a loop suddenly being accessible in global scope. (This corresponds to
"undef" option of jshint).
So this patch limits the scope of variables that don't need to be global. There
are a lot of helper variables in Graph.render() used in a loop, I've declared
them all on one line to reduce patch size. "radius" is special because it
wasn't passed to graph.vertex, but was used there (it worked because this
variable leaked to global scope). "window.graph" is created by an inline script
in graph.tmpl so that it can be used in ajaxScrollInit() function, this patch
makes this fact explicit by assigning window.graph to a local variable.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 22 Nov 2017 21:49:36 +0800 |
parents | 265196cd7d7f |
children | 75f9f366e5cc |
rev | line source |
---|---|
8430
8b47efdf40ee
monoblue: use newer template syntax everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8355
diff
changeset
|
1 {header} |
8b47efdf40ee
monoblue: use newer template syntax everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8355
diff
changeset
|
2 <title>{repo|escape}: graph</title> |
18526
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18258
diff
changeset
|
3 <link rel="alternate" type="application/atom+xml" href="{url|urlescape}atom-log" title="Atom feed for {repo|escape}"/> |
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18258
diff
changeset
|
4 <link rel="alternate" type="application/rss+xml" href="{url|urlescape}rss-log" title="RSS feed for {repo|escape}"/> |
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18258
diff
changeset
|
5 <!--[if IE]><script type="text/javascript" src="{staticurl|urlescape}excanvas.js"></script><![endif]--> |
7111 | 6 </head> |
7 | |
8 <body> | |
9 <div id="container"> | |
10 <div class="page-header"> | |
18258
bebb05a7e249
hgweb: add a "URL breadcrumb" to the index and repository pages
Angel Ezquerra <angel.ezquerra at gmail.com>
parents:
17580
diff
changeset
|
11 <h1 class="breadcrumb"><a href="/">Mercurial</a> {pathdef%breadcrumb} / graph</h1> |
7111 | 12 |
32759
265196cd7d7f
hgweb: consolidate search form for monoblue
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30766
diff
changeset
|
13 {searchform} |
7111 | 14 |
15 <ul class="page-nav"> | |
18526
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18258
diff
changeset
|
16 <li><a href="{url|urlescape}summary{sessionvars%urlparameter}">summary</a></li> |
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18258
diff
changeset
|
17 <li><a href="{url|urlescape}shortlog{sessionvars%urlparameter}">shortlog</a></li> |
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18258
diff
changeset
|
18 <li><a href="{url|urlescape}changelog{sessionvars%urlparameter}">changelog</a></li> |
7111 | 19 <li class="current">graph</li> |
18526
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18258
diff
changeset
|
20 <li><a href="{url|urlescape}tags{sessionvars%urlparameter}">tags</a></li> |
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18258
diff
changeset
|
21 <li><a href="{url|urlescape}bookmarks{sessionvars%urlparameter}">bookmarks</a></li> |
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18258
diff
changeset
|
22 <li><a href="{url|urlescape}branches{sessionvars%urlparameter}">branches</a></li> |
25604
0cdcbc477cac
hgweb: don't dereference symbolic revision in monoblue style
Anton Shestakov <av6@dwimlabs.net>
parents:
24129
diff
changeset
|
23 <li><a href="{url|urlescape}file/{symrev}{sessionvars%urlparameter}">files</a></li> |
24129
3fc86f1c39d8
hgweb: don't mix tabs and spaces in monoblue templates
Anton Shestakov <engored@ya.ru>
parents:
20255
diff
changeset
|
24 <li><a href="{url|urlescape}help{sessionvars%urlparameter}">help</a></li> |
7111 | 25 </ul> |
26 </div> | |
27 | |
28 <h2 class="no-link no-border">graph</h2> | |
29 | |
30 <div id="noscript">The revision graph only works with JavaScript-enabled browsers.</div> | |
31 <div id="wrapper"> | |
32 <ul id="nodebgs"></ul> | |
27913
91ac8cb79125
templates: use canvaswidth instead of fixed width for canvas (issue2683)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25604
diff
changeset
|
33 <canvas id="graph" width="{canvaswidth}" height="{canvasheight}"></canvas> |
7111 | 34 <ul id="graphnodes"></ul> |
35 </div> | |
36 | |
30766
d7bf7d2bd5ab
hgweb: support Content Security Policy
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27913
diff
changeset
|
37 <script{if(nonce, ' nonce="{nonce}"')}> |
7111 | 38 <!-- hide script content |
39 | |
40 document.getElementById('noscript').style.display = 'none'; | |
41 | |
42 var data = {jsdata|json}; | |
43 var graph = new Graph(); | |
44 graph.scale({bg_height}); | |
45 | |
35160
69a865dc2ada
hgweb: define locally used variables as actually local in mercurial.js
Anton Shestakov <av6@dwimlabs.net>
parents:
32759
diff
changeset
|
46 graph.vertex = function(x, y, radius, color, parity, cur) \{ |
7111 | 47 |
48 this.ctx.beginPath(); | |
49 color = this.setColor(color, 0.25, 0.75); | |
50 this.ctx.arc(x, y, radius, 0, Math.PI * 2, true); | |
51 this.ctx.fill(); | |
52 | |
53 var bg = '<li class="bg parity' + parity + '"></li>'; | |
17580
ffe3630cb243
hgweb: fix incorrect graph padding calculation (issue3626)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
17421
diff
changeset
|
54 var left = (this.bg_height - this.box_size) + (this.columns + 1) * this.box_size; |
7111 | 55 var nstyle = 'padding-left: ' + left + 'px;'; |
56 | |
7408
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
57 var tagspan = ''; |
13794
5c18a0bca26f
hgweb: add bookmark labels to monoblue theme (based on 270f57d35525)
Yuya Nishihara <yuya@tcha.org>
parents:
13610
diff
changeset
|
58 if (cur[7].length || cur[8].length || (cur[6][0] != 'default' || cur[6][1])) \{ |
7408
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
59 tagspan = '<span class="logtags">'; |
10856
b07bd417115b
templates: escape javascript braces
Matt Mackall <mpm@selenic.com>
parents:
10575
diff
changeset
|
60 if (cur[6][1]) \{ |
7408
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
61 tagspan += '<span class="branchtag" title="' + cur[6][0] + '">'; |
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
62 tagspan += cur[6][0] + '</span> '; |
10856
b07bd417115b
templates: escape javascript braces
Matt Mackall <mpm@selenic.com>
parents:
10575
diff
changeset
|
63 } else if (!cur[6][1] && cur[6][0] != 'default') \{ |
7408
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
64 tagspan += '<span class="inbranchtag" title="' + cur[6][0] + '">'; |
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
65 tagspan += cur[6][0] + '</span> '; |
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
66 } |
10856
b07bd417115b
templates: escape javascript braces
Matt Mackall <mpm@selenic.com>
parents:
10575
diff
changeset
|
67 if (cur[7].length) \{ |
b07bd417115b
templates: escape javascript braces
Matt Mackall <mpm@selenic.com>
parents:
10575
diff
changeset
|
68 for (var t in cur[7]) \{ |
7408
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
69 var tag = cur[7][t]; |
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
70 tagspan += '<span class="tagtag">' + tag + '</span> '; |
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
71 } |
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
72 } |
13794
5c18a0bca26f
hgweb: add bookmark labels to monoblue theme (based on 270f57d35525)
Yuya Nishihara <yuya@tcha.org>
parents:
13610
diff
changeset
|
73 if (cur[8].length) \{ |
5c18a0bca26f
hgweb: add bookmark labels to monoblue theme (based on 270f57d35525)
Yuya Nishihara <yuya@tcha.org>
parents:
13610
diff
changeset
|
74 for (var t in cur[8]) \{ |
5c18a0bca26f
hgweb: add bookmark labels to monoblue theme (based on 270f57d35525)
Yuya Nishihara <yuya@tcha.org>
parents:
13610
diff
changeset
|
75 var bookmark = cur[8][t]; |
5c18a0bca26f
hgweb: add bookmark labels to monoblue theme (based on 270f57d35525)
Yuya Nishihara <yuya@tcha.org>
parents:
13610
diff
changeset
|
76 tagspan += '<span class="bookmarktag">' + bookmark + '</span> '; |
5c18a0bca26f
hgweb: add bookmark labels to monoblue theme (based on 270f57d35525)
Yuya Nishihara <yuya@tcha.org>
parents:
13610
diff
changeset
|
77 } |
5c18a0bca26f
hgweb: add bookmark labels to monoblue theme (based on 270f57d35525)
Yuya Nishihara <yuya@tcha.org>
parents:
13610
diff
changeset
|
78 } |
7408
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
79 tagspan += '</span>'; |
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
80 } |
f031a12dfc31
coal/paper/monoblue: show branch names in hgweb graph
Benoit Allard <benoit@aeteurope.nl>
parents:
7111
diff
changeset
|
81 |
17421
3eb85477c0d9
hgweb: avoid bad $$ processing in graph (issue3601)
Mads Kiilerich <mads@kiilerich.com>
parents:
16137
diff
changeset
|
82 var item = '<li style="' + nstyle + '"><span class="desc">'; |
18526
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18258
diff
changeset
|
83 item += '<a href="{url|urlescape}rev/' + cur[0] + '{sessionvars%urlparameter}" title="' + cur[0] + '">' + cur[3] + '</a>'; |
17421
3eb85477c0d9
hgweb: avoid bad $$ processing in graph (issue3601)
Mads Kiilerich <mads@kiilerich.com>
parents:
16137
diff
changeset
|
84 item += '</span>' + tagspan + '<span class="info">' + cur[5] + ', by ' + cur[4] + '</span></li>'; |
3eb85477c0d9
hgweb: avoid bad $$ processing in graph (issue3601)
Mads Kiilerich <mads@kiilerich.com>
parents:
16137
diff
changeset
|
85 |
7111 | 86 return [bg, item]; |
87 | |
88 } | |
89 | |
90 graph.render(data); | |
91 | |
92 // stop hiding script --> | |
93 </script> | |
94 | |
95 <div class="page-path"> | |
25604
0cdcbc477cac
hgweb: don't dereference symbolic revision in monoblue style
Anton Shestakov <av6@dwimlabs.net>
parents:
24129
diff
changeset
|
96 <a href="{url|urlescape}graph/{symrev}{lessvars%urlparameter}">less</a> |
0cdcbc477cac
hgweb: don't dereference symbolic revision in monoblue style
Anton Shestakov <av6@dwimlabs.net>
parents:
24129
diff
changeset
|
97 <a href="{url|urlescape}graph/{symrev}{morevars%urlparameter}">more</a> |
10254
8d5de52431f2
hgweb: changenav: separate pages before and after the current position
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9999
diff
changeset
|
98 | {changenav%navgraph} |
7111 | 99 </div> |
100 | |
30766
d7bf7d2bd5ab
hgweb: support Content Security Policy
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27913
diff
changeset
|
101 <script type="text/javascript"{if(nonce, ' nonce="{nonce}"')}> |
20255
b1d65cb8c759
hgweb: infinite scroll support for monoblue style
Takumi IINO <trot.thunder@gmail.com>
parents:
18526
diff
changeset
|
102 ajaxScrollInit( |
b1d65cb8c759
hgweb: infinite scroll support for monoblue style
Takumi IINO <trot.thunder@gmail.com>
parents:
18526
diff
changeset
|
103 '{url|urlescape}graph/{rev}?revcount=%next%&style={style}', |
b1d65cb8c759
hgweb: infinite scroll support for monoblue style
Takumi IINO <trot.thunder@gmail.com>
parents:
18526
diff
changeset
|
104 {revcount}+60, |
b1d65cb8c759
hgweb: infinite scroll support for monoblue style
Takumi IINO <trot.thunder@gmail.com>
parents:
18526
diff
changeset
|
105 function (htmlText, previousVal) \{ return previousVal + 60; }, |
b1d65cb8c759
hgweb: infinite scroll support for monoblue style
Takumi IINO <trot.thunder@gmail.com>
parents:
18526
diff
changeset
|
106 '#wrapper', |
b1d65cb8c759
hgweb: infinite scroll support for monoblue style
Takumi IINO <trot.thunder@gmail.com>
parents:
18526
diff
changeset
|
107 '<div class="%class%" style="text-align: center;">%text%</div>', |
b1d65cb8c759
hgweb: infinite scroll support for monoblue style
Takumi IINO <trot.thunder@gmail.com>
parents:
18526
diff
changeset
|
108 'graph' |
b1d65cb8c759
hgweb: infinite scroll support for monoblue style
Takumi IINO <trot.thunder@gmail.com>
parents:
18526
diff
changeset
|
109 ); |
b1d65cb8c759
hgweb: infinite scroll support for monoblue style
Takumi IINO <trot.thunder@gmail.com>
parents:
18526
diff
changeset
|
110 </script> |
b1d65cb8c759
hgweb: infinite scroll support for monoblue style
Takumi IINO <trot.thunder@gmail.com>
parents:
18526
diff
changeset
|
111 |
8430
8b47efdf40ee
monoblue: use newer template syntax everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8355
diff
changeset
|
112 {footer} |