Skip to content

Commit

Permalink
Merge branch '5.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Dec 27, 2022
2 parents e3472fa + c3384bc commit bcb3d66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
25 changes: 16 additions & 9 deletions docs/js/navbar-search.js
@@ -1,11 +1,18 @@
document.getElementById('search-button-nav').onclick = function() {
var q = document.getElementById('search-input-nav').value;
window.location.href = '/docs/search.html?q=' + encodeURIComponent(q);
};
(function() {
var versionFromUrl = window.location.pathname.match(/^\/docs\/(\d+\.x)/);
var version = versionFromUrl ? versionFromUrl[1] : defaultVersion;

var q = document.getElementById('search-input-nav').onkeyup = function(ev) {
if (ev.keyCode === 13) {
var searchPrefix = versionFromUrl ? '/docs/' + version + '/docs/' : '/docs/';

document.getElementById('search-button-nav').onclick = function() {
var q = document.getElementById('search-input-nav').value;
window.location.href = '/docs/search.html?q=' + encodeURIComponent(q);
}
};
window.location.href = searchPrefix + 'search.html?q=' + encodeURIComponent(q);
};

document.getElementById('search-input-nav').onkeyup = function(ev) {
if (ev.keyCode === 13) {
var q = document.getElementById('search-input-nav').value;
window.location.href = searchPrefix + 'search.html?q=' + encodeURIComponent(q);
}
};
})();
3 changes: 2 additions & 1 deletion docs/js/search.js
Expand Up @@ -9,8 +9,9 @@ for (var i = 0; i < pairs.length; ++i) {
}
}

var defaultVersion = '6.x';
var versionFromUrl = window.location.pathname.match(/^\/docs\/(\d+\.x)/);
var version = versionFromUrl ? versionFromUrl[1] : '6.x';
var version = versionFromUrl ? versionFromUrl[1] : defaultVersion;

if (q != null) {
document.getElementById('search-input').value = decodeURIComponent(q);
Expand Down

0 comments on commit bcb3d66

Please sign in to comment.