diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-10-01 22:46:49 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-10-01 22:46:49 (GMT) |
commit | f25dabe1ec01d8547de06dd73c59afde3370c216 (patch) | |
tree | 637aabd9181a13f33573a08dd2bf93ca8016ac88 /Doc/tools | |
parent | 621ef3d84f842a10dc9cb2af5ab9555b1663b79e (diff) | |
parent | 7eb03ddf118c01ef2ae64f013493386f520eb3ec (diff) | |
download | cpython-f25dabe1ec01d8547de06dd73c59afde3370c216.zip cpython-f25dabe1ec01d8547de06dd73c59afde3370c216.tar.gz cpython-f25dabe1ec01d8547de06dd73c59afde3370c216.tar.bz2 |
Merge changelog filtering fixes/improvements with 3.3.
Diffstat (limited to 'Doc/tools')
-rw-r--r-- | Doc/tools/sphinxext/layout.html | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/Doc/tools/sphinxext/layout.html b/Doc/tools/sphinxext/layout.html index b679f3a..3f68a00 100644 --- a/Doc/tools/sphinxext/layout.html +++ b/Doc/tools/sphinxext/layout.html @@ -10,19 +10,59 @@ {% if not embedded %}<script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>{% endif %} {% if pagename == 'whatsnew/changelog' %} <script type="text/javascript"> - function dofilter() { - var el = document.getElementById('searchbox'); - var string = el.value.toLowerCase(); - var litags = document.getElementsByTagName('li') - for (var idx = 0; idx < litags.length; idx++) { - var li = litags[idx]; - if (li.innerHTML.toLowerCase().indexOf(string) >= 0) { - li.style.display = ''; - } else { - li.style.display = 'none'; + $(document).ready(function() { + // add the search form and bind the events + $('h1').after([ + '<p>Filter entries by content:', + '<input type="text" value="" id="searchbox" style="width: 50%">', + '<input type="submit" id="searchbox-submit" value="Filter"></p>' + ].join('\n')); + + function dofilter() { + try { + var query = new RegExp($('#searchbox').val(), 'i'); + } + catch (e) { + return; // not a valid regex (yet) + } + // find headers for the versions (What's new in Python X.Y.Z?) + $('#changelog h2').each(function(index1, h2) { + var h2_parent = $(h2).parent(); + var sections_found = 0; + // find headers for the sections (Core, Library, etc.) + h2_parent.find('h3').each(function(index2, h3) { + var h3_parent = $(h3).parent(); + var entries_found = 0; + // find all the entries + h3_parent.find('li').each(function(index3, li) { + var li = $(li); + // check if the query matches the entry + if (query.test(li.text())) { + li.show(); + entries_found++; + } + else { + li.hide(); + } + }); + // if there are entries, show the section, otherwise hide it + if (entries_found > 0) { + h3_parent.show(); + sections_found++; + } + else { + h3_parent.hide(); + } + }); + if (sections_found > 0) + h2_parent.show(); + else + h2_parent.hide(); + }); } - } - } + $('#searchbox').keyup(dofilter); + $('#searchbox-submit').click(dofilter); + }); </script> {% endif %} {{ super() }} @@ -31,7 +71,7 @@ <div class="footer"> © <a href="{{ pathto('copyright') }}">Copyright</a> {{ copyright|e }}. <br /> - The Python Software Foundation is a non-profit corporation. + The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on {{ last_updated|e }}. |