Definition in search results (#2712)

This commit is contained in:
Misty Stanley-Jones
2017-04-10 17:27:08 -07:00
committed by John Mulhausen
parent 874fb27d35
commit 1f31104630
2 changed files with 32 additions and 5 deletions

View File

@@ -239,10 +239,21 @@ function renderTopicsByTagTable(tagToLookup,divID)
}
function renderTagsPage()
{
if(window.location.pathname.indexOf("/glossary/")>-1)
if(window.location.pathname.indexOf("/glossary/")>-1 || window.location.pathname.indexOf("/search/")>-1)
{
var tagToLookup = decodeURI(queryString().term);
$("#keyword").html(tagToLookup);
var tagToLookup;
if (window.location.pathname.indexOf("/glossary/")>-1)
{
// Get ?term=<value>
tagToLookup = decodeURI(queryString().term);
$("#keyword").html(tagToLookup);
}
else
{
// Get ?q=<value>
tagToLookup = decodeURI(queryString().q);
}
// Get the term and definition
for (i=0;i<glossary.terms.length;i++)
{
if (glossary.terms[i].term.toLowerCase()==tagToLookup.toLowerCase())

View File

@@ -3,7 +3,7 @@ description: Docker documentation search results
keywords: Search, Docker, documentation, manual, guide, reference, api
noratings: true
notoc: true
title: Docs search
title: "Docs search <span id='searchTerm'></span>"
tree: false
---
@@ -21,6 +21,9 @@ tree: false
.gsc-control-cse, .gsc-control-cse-en { padding: 0px !important; }
.gsc-result-info { padding-bottom: 0px !important; }
</style>
<div id="glossaryMatch"></div>
<div id="my-cse1">
<script>
(function() {
@@ -33,5 +36,18 @@ tree: false
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
<gcse:searchresults-only></gcse:searchresults-only>
</div>
<script defer>
setTimeout(function(){
$(document).ready(function() {
if (decodeURI(queryString().q) != "undefined" && decodeURI(queryString().q) && decodeURI(queryString().q).length > 0) {
$("#st-search-input").val(decodeURI(queryString().q));
$("#st-search-input").focus();
$("#searchTerm").html("results for: " + decodeURI(queryString().q))
}
});
}, 1);
</script>