diff doc/html/search/search.js @ 117:ca2d83d29814 tip master

Merge branch 'release/1.0.5'
author Adam Stark <adamstark.uk@gmail.com>
date Fri, 18 Aug 2023 20:07:33 +0200
parents d6d9df2db3e1
children
line wrap: on
line diff
--- a/doc/html/search/search.js	Sat Jun 18 10:50:06 2016 +0100
+++ b/doc/html/search/search.js	Fri Aug 18 20:07:33 2023 +0200
@@ -1,30 +1,27 @@
-// Search script generated by doxygen
-// Copyright (C) 2009 by Dimitri van Heesch.
+/*
+ @licstart  The following is the entire license notice for the JavaScript code in this file.
 
-// The code in this file is loosly based on main.js, part of Natural Docs,
-// which is Copyright (C) 2003-2008 Greg Valure
-// Natural Docs is licensed under the GPL.
+ The MIT License (MIT)
 
-var indexSectionsWithContent =
-{
-  0: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011101101000001100101010000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
-  1: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
-  2: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
-  3: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011101101000001100101000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
-  4: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
-  5: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
-};
+ Copyright (C) 1997-2020 by Dimitri van Heesch
 
-var indexSectionNames =
-{
-  0: "all",
-  1: "classes",
-  2: "files",
-  3: "functions",
-  4: "enums",
-  5: "pages"
-};
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ and associated documentation files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
 
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ @licend  The above is the entire license notice for the JavaScript code in this file
+ */
 function convertToId(search)
 {
   var result = '';
@@ -32,15 +29,15 @@
   {
     var c = search.charAt(i);
     var cn = c.charCodeAt(0);
-    if (c.match(/[a-z0-9]/))
+    if (c.match(/[a-z0-9\u0080-\uFFFF]/))
     {
       result+=c;
     }
-    else if (cn<16) 
+    else if (cn<16)
     {
       result+="_0"+cn.toString(16);
     }
-    else 
+    else
     {
       result+="_"+cn.toString(16);
     }
@@ -76,17 +73,20 @@
   return y;
 }
 
+var searchResults = new SearchResults("searchResults");
+
 /* A class handling everything associated with the search panel.
 
    Parameters:
-   name - The name of the global variable that will be 
+   name - The name of the global variable that will be
           storing this instance.  Is needed to be able to set timeouts.
    resultPath - path to use for external files
 */
-function SearchBox(name, resultsPath, inFrame, label)
+function SearchBox(name, resultsPath, extension)
 {
   if (!name || !resultsPath) {  alert("Missing parameters to SearchBox."); }
-   
+  if (!extension || extension == "") { extension = ".html"; }
+
   // ---------- Instance variables
   this.name                  = name;
   this.resultsPath           = resultsPath;
@@ -98,8 +98,7 @@
   this.hideTimeout           = 0;
   this.searchIndex           = 0;
   this.searchActive          = false;
-  this.insideFrame           = inFrame;
-  this.searchLabel           = label;
+  this.extension             = extension;
 
   // ----------- DOM Elements
 
@@ -137,33 +136,17 @@
     var searchSelectWindow = this.DOMSearchSelectWindow();
     var searchField        = this.DOMSearchSelect();
 
-    if (this.insideFrame)
-    {
-      var left = getXPos(searchField);
-      var top  = getYPos(searchField);
-      left += searchField.offsetWidth + 6;
-      top += searchField.offsetHeight;
+    var left = getXPos(searchField);
+    var top  = getYPos(searchField);
+    top += searchField.offsetHeight;
 
-      // show search selection popup
-      searchSelectWindow.style.display='block';
-      left -= searchSelectWindow.offsetWidth;
-      searchSelectWindow.style.left =  left + 'px';
-      searchSelectWindow.style.top  =  top  + 'px';
-    }
-    else
-    {
-      var left = getXPos(searchField);
-      var top  = getYPos(searchField);
-      top += searchField.offsetHeight;
-
-      // show search selection popup
-      searchSelectWindow.style.display='block';
-      searchSelectWindow.style.left =  left + 'px';
-      searchSelectWindow.style.top  =  top  + 'px';
-    }
+    // show search selection popup
+    searchSelectWindow.style.display='block';
+    searchSelectWindow.style.left =  left + 'px';
+    searchSelectWindow.style.top  =  top  + 'px';
 
     // stop selection hide timer
-    if (this.hideTimeout) 
+    if (this.hideTimeout)
     {
       clearTimeout(this.hideTimeout);
       this.hideTimeout=0;
@@ -173,7 +156,7 @@
 
   this.OnSearchSelectHide = function()
   {
-    this.hideTimeout = setTimeout(this.name +".CloseSelectionWindow()",
+    this.hideTimeout = setTimeout(this.CloseSelectionWindow.bind(this),
                                   this.closeSelectionTimeout);
   }
 
@@ -192,7 +175,7 @@
       if (e.shiftKey==1)
       {
         this.OnSearchSelectShow();
-        var win=this.DOMSearchSelectWindow(); 
+        var win=this.DOMSearchSelectWindow();
         for (i=0;i<win.childNodes.length;i++)
         {
           var child = win.childNodes[i]; // get span within a
@@ -204,9 +187,9 @@
         }
         return;
       }
-      else if (window.frames.MSearchResults.searchResults)
+      else
       {
-        var elem = window.frames.MSearchResults.searchResults.NavNext(0);
+        var elem = searchResults.NavNext(0);
         if (elem) elem.focus();
       }
     }
@@ -228,7 +211,7 @@
       if (searchValue != "") // non-empty search
       {
         // set timer for search update
-        this.keyTimeout = setTimeout(this.name + '.Search()',
+        this.keyTimeout = setTimeout(this.Search.bind(this),
                                      this.keyTimeoutLength);
       }
       else // empty search field
@@ -243,7 +226,7 @@
   this.SelectItemCount = function(id)
   {
     var count=0;
-    var win=this.DOMSearchSelectWindow(); 
+    var win=this.DOMSearchSelectWindow();
     for (i=0;i<win.childNodes.length;i++)
     {
       var child = win.childNodes[i]; // get span within a
@@ -258,7 +241,7 @@
   this.SelectItemSet = function(id)
   {
     var i,j=0;
-    var win=this.DOMSearchSelectWindow(); 
+    var win=this.DOMSearchSelectWindow();
     for (i=0;i<win.childNodes.length;i++)
     {
       var child = win.childNodes[i]; // get span within a
@@ -337,92 +320,98 @@
     var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
 
     var code = searchValue.toLowerCase().charCodeAt(0);
-    var hexCode;
-    if (code<16) 
+    var idxChar = searchValue.substr(0, 1).toLowerCase();
+    if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair
     {
-      hexCode="0"+code.toString(16);
-    }
-    else 
-    {
-      hexCode=code.toString(16);
+      idxChar = searchValue.substr(0, 2);
     }
 
-    var resultsPage;
-    var resultsPageWithSearch;
-    var hasResultsPage;
+    var jsFile;
 
-    if (indexSectionsWithContent[this.searchIndex].charAt(code) == '1')
+    var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
+    if (idx!=-1)
     {
-       resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html';
-       resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
-       hasResultsPage = true;
-    }
-    else // nothing available for this search term
-    {
-       resultsPage = this.resultsPath + '/nomatches.html';
-       resultsPageWithSearch = resultsPage;
-       hasResultsPage = false;
+       var hexCode=idx.toString(16);
+       jsFile = this.resultsPath + indexSectionNames[this.searchIndex] + '_' + hexCode + '.js';
     }
 
-    window.frames.MSearchResults.location = resultsPageWithSearch;  
+    var loadJS = function(url, impl, loc){
+      var scriptTag = document.createElement('script');
+      scriptTag.src = url;
+      scriptTag.onload = impl;
+      scriptTag.onreadystatechange = impl;
+      loc.appendChild(scriptTag);
+    }
+
     var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
+    var domSearchBox = this.DOMSearchBox();
+    var domPopupSearchResults = this.DOMPopupSearchResults();
+    var domSearchClose = this.DOMSearchClose();
+    var resultsPath = this.resultsPath;
 
-    if (domPopupSearchResultsWindow.style.display!='block')
-    {
-       var domSearchBox = this.DOMSearchBox();
-       this.DOMSearchClose().style.display = 'inline';
-       if (this.insideFrame)
-       {
-         var domPopupSearchResults = this.DOMPopupSearchResults();
-         domPopupSearchResultsWindow.style.position = 'relative';
-         domPopupSearchResultsWindow.style.display  = 'block';
-         var width = document.body.clientWidth - 8; // the -8 is for IE :-(
-         domPopupSearchResultsWindow.style.width    = width + 'px';
-         domPopupSearchResults.style.width          = width + 'px';
-       }
-       else
-       {
-         var domPopupSearchResults = this.DOMPopupSearchResults();
-         var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth;
-         var top  = getYPos(domSearchBox) + 20;  // domSearchBox.offsetHeight + 1;
-         domPopupSearchResultsWindow.style.display = 'block';
-         left -= domPopupSearchResults.offsetWidth;
-         domPopupSearchResultsWindow.style.top     = top  + 'px';
-         domPopupSearchResultsWindow.style.left    = left + 'px';
-       }
+    var handleResults = function() {
+      document.getElementById("Loading").style.display="none";
+      if (typeof searchData !== 'undefined') {
+        createResults(resultsPath);
+        document.getElementById("NoMatches").style.display="none";
+      }
+ 
+      if (idx!=-1) {
+        searchResults.Search(searchValue);
+      } else { // no file with search results => force empty search results
+        searchResults.Search('====');
+      }
+
+      if (domPopupSearchResultsWindow.style.display!='block')
+      {
+        domSearchClose.style.display = 'inline-block';
+        var left = getXPos(domSearchBox) + 150;
+        var top  = getYPos(domSearchBox) + 20;
+        domPopupSearchResultsWindow.style.display = 'block';
+        left -= domPopupSearchResults.offsetWidth;
+        var maxWidth  = document.body.clientWidth;
+        var maxHeight = document.body.clientHeight;
+        var width = 300;
+        if (left<10) left=10;
+        if (width+left+8>maxWidth) width=maxWidth-left-8;
+        var height = 400;
+        if (height+top+8>maxHeight) height=maxHeight-top-8;
+        domPopupSearchResultsWindow.style.top     = top  + 'px';
+        domPopupSearchResultsWindow.style.left    = left + 'px';
+        domPopupSearchResultsWindow.style.width   = width + 'px';
+        domPopupSearchResultsWindow.style.height  = height + 'px';
+      }
+    }
+
+    if (jsFile) {
+      loadJS(jsFile, handleResults, this.DOMPopupSearchResultsWindow());
+    } else {
+      handleResults();
     }
 
     this.lastSearchValue = searchValue;
-    this.lastResultsPage = resultsPage;
   }
 
   // -------- Activation Functions
 
-  // Activates or deactivates the search panel, resetting things to 
-  // their default values if necessary. 
+  // Activates or deactivates the search panel, resetting things to
+  // their default values if necessary.
   this.Activate = function(isActive)
   {
     if (isActive || // open it
-        this.DOMPopupSearchResultsWindow().style.display == 'block' 
+        this.DOMPopupSearchResultsWindow().style.display == 'block'
        )
     {
       this.DOMSearchBox().className = 'MSearchBoxActive';
-
-      var searchField = this.DOMSearchField();
-
-      if (searchField.value == this.searchLabel) // clear "Search" term upon entry
-      {  
-        searchField.value = '';  
-        this.searchActive = true;
-      }
+      this.searchActive = true;
     }
     else if (!isActive) // directly remove the panel
     {
       this.DOMSearchBox().className = 'MSearchBoxInactive';
-      this.DOMSearchField().value   = this.searchLabel;
       this.searchActive             = false;
       this.lastSearchValue          = ''
       this.lastResultsPage          = '';
+      this.DOMSearchField().value   = '';
     }
   }
 }
@@ -445,18 +434,18 @@
 
       while (element && element!=parentElement)
       {
-        if (element.nodeName == 'DIV' && element.className == 'SRChildren')
+        if (element.nodeName.toLowerCase() == 'div' && element.className == 'SRChildren')
         {
           return element;
         }
 
-        if (element.nodeName == 'DIV' && element.hasChildNodes())
-        {  
-           element = element.firstChild;  
+        if (element.nodeName.toLowerCase() == 'div' && element.hasChildNodes())
+        {
+           element = element.firstChild;
         }
         else if (element.nextSibling)
-        {  
-           element = element.nextSibling;  
+        {
+           element = element.nextSibling;
         }
         else
         {
@@ -467,8 +456,8 @@
           while (element && element!=parentElement && !element.nextSibling);
 
           if (element && element!=parentElement)
-          {  
-            element = element.nextSibling;  
+          {
+            element = element.nextSibling;
           }
         }
       }
@@ -521,7 +510,7 @@
           var rowMatchName = row.id.toLowerCase();
           rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_'
 
-          if (search.length<=rowMatchName.length && 
+          if (search.length<=rowMatchName.length &&
              rowMatchName.substr(0, search.length)==search)
           {
             row.style.display = 'block';
@@ -592,7 +581,7 @@
 
     this.ProcessKeys = function(e)
     {
-      if (e.type == "keydown") 
+      if (e.type == "keydown")
       {
         this.repeatOn = false;
         this.lastKey = e.keyCode;
@@ -613,7 +602,7 @@
       return this.lastKey!=0;
     }
 
-    this.Nav = function(evt,itemIndex) 
+    this.Nav = function(evt,itemIndex)
     {
       var e  = (evt) ? evt : window.event; // for IE
       if (e.keyCode==13) return true;
@@ -627,7 +616,7 @@
         {
           var child = this.FindChildElement(focusItem.parentNode.parentNode.id);
           if (child && child.style.display == 'block') // children visible
-          { 
+          {
             var n=0;
             var tmpElem;
             while (1) // search for last child
@@ -651,7 +640,7 @@
         }
         else // return focus to search field
         {
-           parent.document.getElementById("MSearchField").focus();
+           document.getElementById("MSearchField").focus();
         }
       }
       else if (this.lastKey==40) // Down
@@ -681,8 +670,8 @@
       }
       else if (this.lastKey==27) // Escape
       {
-        parent.searchBox.CloseResultsWindow();
-        parent.document.getElementById("MSearchField").focus();
+        searchBox.CloseResultsWindow();
+        document.getElementById("MSearchField").focus();
       }
       else if (this.lastKey==13) // Enter
       {
@@ -720,12 +709,12 @@
         if (elem)
         {
           elem.focus();
-        } 
+        }
       }
       else if (this.lastKey==27) // Escape
       {
-        parent.searchBox.CloseResultsWindow();
-        parent.document.getElementById("MSearchField").focus();
+        searchBox.CloseResultsWindow();
+        document.getElementById("MSearchField").focus();
       }
       else if (this.lastKey==13) // Enter
       {
@@ -748,9 +737,10 @@
   elem.setAttribute('className',attr);
 }
 
-function createResults()
+function createResults(resultsPath)
 {
   var results = document.getElementById("SRResults");
+  results.innerHTML = '';
   for (var e=0; e<searchData.length; e++)
   {
     var id = searchData[e][0];
@@ -767,11 +757,16 @@
     srEntry.appendChild(srLink);
     if (searchData[e][1].length==2) // single result
     {
-      srLink.setAttribute('href',searchData[e][1][1][0]);
+      srLink.setAttribute('href',resultsPath+searchData[e][1][1][0]);
+      srLink.setAttribute('onclick','searchBox.CloseResultsWindow()');
       if (searchData[e][1][1][1])
       {
        srLink.setAttribute('target','_parent');
       }
+      else
+      {
+       srLink.setAttribute('target','_blank');
+      }
       var srScope = document.createElement('span');
       setClassAttr(srScope,'SRScope');
       srScope.innerHTML = searchData[e][1][1][2];
@@ -788,11 +783,16 @@
         srChild.setAttribute('id','Item'+e+'_c'+c);
         setKeyActions(srChild,'return searchResults.NavChild(event,'+e+','+c+')');
         setClassAttr(srChild,'SRScope');
-        srChild.setAttribute('href',searchData[e][1][c+1][0]);
+        srChild.setAttribute('href',resultsPath+searchData[e][1][c+1][0]);
+        srChild.setAttribute('onclick','searchBox.CloseResultsWindow()');
         if (searchData[e][1][c+1][1])
         {
          srChild.setAttribute('target','_parent');
         }
+        else
+        {
+         srChild.setAttribute('target','_blank');
+        }
         srChild.innerHTML = searchData[e][1][c+1][2];
         srChildren.appendChild(srChild);
       }
@@ -803,3 +803,18 @@
   }
 }
 
+function init_search()
+{
+  var results = document.getElementById("MSearchSelectWindow");
+  for (var key in indexSectionLabels)
+  {
+    var link = document.createElement('a');
+    link.setAttribute('class','SelectItem');
+    link.setAttribute('onclick','searchBox.OnSelectItem('+key+')');
+    link.href='javascript:void(0)';
+    link.innerHTML='<span class="SelectionMark">&#160;</span>'+indexSectionLabels[key];
+    results.appendChild(link);
+  }
+  searchBox.OnSelectItem(0);
+}
+/* @license-end */