mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-30607: Use external python-doc-theme (GH-2017)
This commit is contained in:
parent
5da8cfb838
commit
bf63e8d55f
12 changed files with 80 additions and 585 deletions
53
Doc/tools/static/changelog_search.js
Normal file
53
Doc/tools/static/changelog_search.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
$(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);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue