[PATCH 1 of 4] hgweb: eliminate extra complexity in process_dates definition
Augie Fackler
raf at durin42.com
Mon Sep 30 14:25:54 CDT 2013
On Sun, Sep 29, 2013 at 09:19:10PM +0400, Alexander Plavin wrote:
>
>
> 25.09.2013, 08:09, "Kevin Bullock" <kbullock+mercurial at ringworld.org>:
> > 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.
>
> Yeah, didn't notice that tabs are used here. Btw, probably it's
> better to use spaces all over the js file as well? Or the opposite -
> tabs everywhere in this file (my ajax code there uses spaces)?
I guess I'd be happier with spaces. Can you send a standalone cleanup
to standardize on spaces, then do your followups after that?
>
> >
> > pacem in terris / мир / शान्ति / سَلاَم / 平和
> > Kevin R. Bullock
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list