Skip to content

Commit

Permalink
Merge branch 'albert-github-feature/issue_10351'
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Oct 28, 2023
2 parents 708920a + 390499d commit f023089
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion templates/html/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
@licend The above is the entire license notice for the JavaScript code in this file
*/
var cookie_namespace = 'doxygen';
var cookie_name = '_search_grp';

function convertToId(search)
{
var result = '';
Expand Down Expand Up @@ -239,6 +242,25 @@ function SearchBox(name, resultsPath, extension)
return count;
}

this.GetSelectionIdByName = function(name)
{
var i=0,j=0;
var win=this.DOMSearchSelectWindow();
for (i=0;i<win.childNodes.length;i++)
{
var child = win.childNodes[i];
if (child.className=='SelectItem')
{
if (child.childNodes[1].nodeValue==name)
{
return j;
}
j++;
}
}
return 0;
}

this.SelectItemSet = function(id)
{
var i,j=0;
Expand All @@ -252,6 +274,7 @@ function SearchBox(name, resultsPath, extension)
if (j==id)
{
node.innerHTML='&#8226;';
writeSetting(cookie_name, child.childNodes[1].nodeValue)
}
else
{
Expand Down Expand Up @@ -807,9 +830,45 @@ function createResults(resultsPath)
}
}

function writeSetting(cookie, val)
{
if (window.chrome) {
localStorage.setItem(cookie_namespace+cookie,val);
} else {
var date = new Date();
date.setTime(date.getTime()+(1*60*60*1000)); // default expiration is one hour
expiration = date.toGMTString();
document.cookie = cookie_namespace + cookie + "=" + val + "; SameSite=Lax; expires=" + expiration+"; path=/";
}
}

function init_search()
{
var results = document.getElementById("MSearchSelectWindow");

function readSetting(cookie)
{
if (window.chrome) {
var val = localStorage.getItem(cookie_namespace+cookie);
if (val) return val;
} else {
var myCookie = cookie_namespace+cookie+"=";
if (document.cookie) {
var index = document.cookie.indexOf(myCookie);
if (index != -1) {
var valStart = index + myCookie.length;
var valEnd = document.cookie.indexOf(";", valStart);
if (valEnd == -1) {
valEnd = document.cookie.length;
}
var val = document.cookie.substring(valStart, valEnd);
return val;
}
}
}
return 0;
}

results.tabIndex=0;
for (var key in indexSectionLabels)
{
Expand All @@ -820,7 +879,6 @@ function init_search()
link.innerHTML='<span class="SelectionMark">&#160;</span>'+indexSectionLabels[key];
results.appendChild(link);
}
searchBox.OnSelectItem(0);

var input = document.getElementById("MSearchSelect");
var searchSelectWindow = document.getElementById("MSearchSelectWindow");
Expand All @@ -836,5 +894,8 @@ function init_search()
}
}
});
var name = readSetting(cookie_name);
var id = searchBox.GetSelectionIdByName(name);
searchBox.OnSelectItem(id);
}
/* @license-end */

0 comments on commit f023089

Please sign in to comment.