[PATCH 1 of 4] hgweb: eliminate extra complexity in process_dates definition
Kevin Bullock
kbullock+mercurial at ringworld.org
Tue Sep 24 23:09:47 CDT 2013
On 24 Sep 2013, at 2:39 PM, Alexander Plavin wrote:
> # HG changeset patch
> # User Alexander Plavin <alexander at plav.in>
> # Date 1378459858 -14400
> # Fri Sep 06 13:30:58 2013 +0400
> # Node ID c3e2dd350a17ce393b36fbfb546a2d7707f2b5d7
> # Parent 8c01d533c6f20a0883c22a14b324c90cde9efdaf
> hgweb: eliminate extra complexity in process_dates definition
>
> There was an extra anonymous outer function, called immediately. It is removed
> in this patch.
>
> diff -r 8c01d533c6f2 -r c3e2dd350a17 mercurial/templates/static/mercurial.js
> --- a/mercurial/templates/static/mercurial.js Sun Sep 22 14:19:57 2013 +0400
> +++ b/mercurial/templates/static/mercurial.js Fri Sep 06 13:30:58 2013 +0400
> @@ -176,7 +176,7 @@
> }
>
>
> -process_dates = (function(document, RegExp, Math, isNaN, Date, _false, _true){
> +function process_dates(){
>
> // derived from code from mercurial/templatefilter.py
>
> @@ -227,9 +227,9 @@
>
> var delta = Math.floor((now.getTime() - once.getTime()) / 1000);
>
> - var future = _false;
> + var future = false;
> if (delta < 0){
> - future = _true;
> + future = true;
> delta = -delta;
> if (delta > (30 * scales.year)){
> return "in the distant future";
> @@ -253,26 +253,24 @@
> }
> }
>
> - return function(){
> - var nodes = document.getElementsByTagName('*');
> - var ageclass = new RegExp('\\bage\\b');
> - var dateclass = new RegExp('\\bdate\\b');
> - for (var i=0; i<nodes.length; ++i){
> - var node = nodes[i];
> - var classes = node.className;
> - if (ageclass.test(classes)){
> - var agevalue = age(node.textContent);
> - if (dateclass.test(classes)){
> - // We want both: date + (age)
> - node.textContent += ' ('+agevalue+')';
> - } else {
> - node.title = node.textContent;
> - node.textContent = agevalue;
> - }
> - }
> - }
> - }
> -})(document, RegExp, Math, isNaN, Date, false, true)
> + var nodes = document.getElementsByTagName('*');
You changed the indent width here. Other than that LGTM.
pacem in terris / мир / शान्ति / سَلاَم / 平和
Kevin R. Bullock
More information about the Mercurial-devel
mailing list