Submitter | Alexander Plavin |
---|---|
Date | Aug. 17, 2013, 10:35 p.m. |
Message ID | <988392ad5f1e39a099a1.1376778919@debian-alexander.dolgopa> |
Download | mbox | patch |
Permalink | /patch/2223/ |
State | Deferred |
Headers | show |
Comments
Alexander Plavin <alexander@plav.in> writes: > # HG changeset patch > # User Alexander Plavin <alexander@plav.in> > # Date 1374681754 -14400 > # Wed Jul 24 20:02:34 2013 +0400 > # Node ID 988392ad5f1e39a099a1b00c4595628420d19991 > # Parent 122061a7a549d6e3faa84a0657699b5ed705f413 > hgweb: add selector argument to process_dates > > Allow specifying elements to process with selector, useful for > incremental page updates. > > diff -r 122061a7a549 -r 988392ad5f1e mercurial/templates/static/mercurial.js > --- a/mercurial/templates/static/mercurial.js Wed Jul 24 20:13:52 2013 +0400 > +++ b/mercurial/templates/static/mercurial.js Wed Jul 24 20:02:34 2013 +0400 > @@ -168,7 +168,7 @@ > } > > > -function process_dates(){ > +function process_dates(selector){ > > // derived from code from mercurial/templatefilter.py > > @@ -245,7 +245,11 @@ > } > } > > - var nodes = document.querySelectorAll('.age'); > + if (typeof selector === 'undefined') { > + selector = ''; > + } > + > + var nodes = document.querySelectorAll(selector + ' .age'); I think parentSelector would be a better name. At first I expected that selector would be a general selector one could use instead of '.age'. But then I saw that it is combined like above, meaning that selector is specifically a parent element seletor for the '.age' elements. Patch looks good otherwise! > var dateclass = new RegExp('\\bdate\\b'); > for (var i=0; i<nodes.length; ++i){ > var node = nodes[i]; > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
Op 18-08-13 00:35, Alexander Plavin schreef: > # HG changeset patch > # User Alexander Plavin <alexander@plav.in> > # Date 1374681754 -14400 > # Wed Jul 24 20:02:34 2013 +0400 > # Node ID 988392ad5f1e39a099a1b00c4595628420d19991 > # Parent 122061a7a549d6e3faa84a0657699b5ed705f413 > hgweb: add selector argument to process_dates > > Allow specifying elements to process with selector, useful for incremental page > updates. > > diff -r 122061a7a549 -r 988392ad5f1e mercurial/templates/static/mercurial.js > --- a/mercurial/templates/static/mercurial.js Wed Jul 24 20:13:52 2013 +0400 > +++ b/mercurial/templates/static/mercurial.js Wed Jul 24 20:02:34 2013 +0400 > @@ -168,7 +168,7 @@ > } > > > -function process_dates(){ > +function process_dates(selector){ > > // derived from code from mercurial/templatefilter.py > > @@ -245,7 +245,11 @@ > } > } > > - var nodes = document.querySelectorAll('.age'); > + if (typeof selector === 'undefined') { > + selector = ''; > + } > + > + var nodes = document.querySelectorAll(selector + ' .age'); Nit: I would simply do (selector || ''). ~Laurens
20.08.2013, 13:59, "Laurens Holst" <laurens.nospam@grauw.nl>: > Op 18-08-13 00:35, Alexander Plavin schreef: > >> # HG changeset patch >> # User Alexander Plavin <alexander@plav.in> >> # Date 1374681754 -14400 >> # Wed Jul 24 20:02:34 2013 +0400 >> # Node ID 988392ad5f1e39a099a1b00c4595628420d19991 >> # Parent 122061a7a549d6e3faa84a0657699b5ed705f413 >> hgweb: add selector argument to process_dates >> >> Allow specifying elements to process with selector, useful for incremental page >> updates. >> >> diff -r 122061a7a549 -r 988392ad5f1e mercurial/templates/static/mercurial.js >> --- a/mercurial/templates/static/mercurial.js Wed Jul 24 20:13:52 2013 +0400 >> +++ b/mercurial/templates/static/mercurial.js Wed Jul 24 20:02:34 2013 +0400 >> @@ -168,7 +168,7 @@ >> } >> >> -function process_dates(){ >> +function process_dates(selector){ >> >> // derived from code from mercurial/templatefilter.py >> >> @@ -245,7 +245,11 @@ >> } >> } >> >> - var nodes = document.querySelectorAll('.age'); >> + if (typeof selector === 'undefined') { >> + selector = ''; >> + } >> + >> + var nodes = document.querySelectorAll(selector + ' .age'); > > Nit: I would simply do (selector || ''). Sure, will change :) At first there was slightly different code where this wouldn't suit, and after a change I didn't notice it can be rewritten better. > > ~Laurens
Patch
diff -r 122061a7a549 -r 988392ad5f1e mercurial/templates/static/mercurial.js --- a/mercurial/templates/static/mercurial.js Wed Jul 24 20:13:52 2013 +0400 +++ b/mercurial/templates/static/mercurial.js Wed Jul 24 20:02:34 2013 +0400 @@ -168,7 +168,7 @@ } -function process_dates(){ +function process_dates(selector){ // derived from code from mercurial/templatefilter.py @@ -245,7 +245,11 @@ } } - var nodes = document.querySelectorAll('.age'); + if (typeof selector === 'undefined') { + selector = ''; + } + + var nodes = document.querySelectorAll(selector + ' .age'); var dateclass = new RegExp('\\bdate\\b'); for (var i=0; i<nodes.length; ++i){ var node = nodes[i];