update v1.0.x docs
[m6w6/ext-propro] / v1.0.x / search / search.js
index 68068168937138708ac6c53b633b44a11b825643..dedce3bf093890b8693ec9b110414855542fb79b 100644 (file)
@@ -1,30 +1,3 @@
-// Search script generated by doxygen
-// Copyright (C) 2009 by Dimitri van Heesch.
-
-// 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.
-
-var indexSectionsWithContent =
-{
-  0: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000100100000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
-  1: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
-  2: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
-  3: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
-  4: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000100100000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
-  5: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
-};
-
-var indexSectionNames =
-{
-  0: "all",
-  1: "classes",
-  2: "files",
-  3: "functions",
-  4: "variables",
-  5: "typedefs"
-};
-
 function convertToId(search)
 {
   var result = '';
@@ -32,15 +5,15 @@ function convertToId(search)
   {
     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);
     }
@@ -79,14 +52,14 @@ function getYPos(item)
 /* 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)
 {
   if (!name || !resultsPath) {  alert("Missing parameters to SearchBox."); }
-   
+
   // ---------- Instance variables
   this.name                  = name;
   this.resultsPath           = resultsPath;
@@ -163,7 +136,7 @@ function SearchBox(name, resultsPath, inFrame, label)
     }
 
     // stop selection hide timer
-    if (this.hideTimeout) 
+    if (this.hideTimeout)
     {
       clearTimeout(this.hideTimeout);
       this.hideTimeout=0;
@@ -192,7 +165,7 @@ function SearchBox(name, resultsPath, inFrame, label)
       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
@@ -243,7 +216,7 @@ function SearchBox(name, resultsPath, inFrame, label)
   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 +231,7 @@ function SearchBox(name, resultsPath, inFrame, label)
   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,22 +310,20 @@ function SearchBox(name, resultsPath, inFrame, label)
     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;
 
-    if (indexSectionsWithContent[this.searchIndex].charAt(code) == '1')
+    var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
+    if (idx!=-1)
     {
+       var hexCode=idx.toString(16);
        resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html';
        resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
        hasResultsPage = true;
@@ -364,7 +335,7 @@ function SearchBox(name, resultsPath, inFrame, label)
        hasResultsPage = false;
     }
 
-    window.frames.MSearchResults.location = resultsPageWithSearch;  
+    window.frames.MSearchResults.location = resultsPageWithSearch;
     var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
 
     if (domPopupSearchResultsWindow.style.display!='block')
@@ -398,12 +369,12 @@ function SearchBox(name, resultsPath, inFrame, label)
 
   // -------- 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';
@@ -411,8 +382,8 @@ function SearchBox(name, resultsPath, inFrame, label)
       var searchField = this.DOMSearchField();
 
       if (searchField.value == this.searchLabel) // clear "Search" term upon entry
-      {  
-        searchField.value = '';  
+      {
+        searchField.value = '';
         this.searchActive = true;
       }
     }
@@ -451,12 +422,12 @@ function SearchResults(name)
         }
 
         if (element.nodeName == 'DIV' && element.hasChildNodes())
-        {  
-           element = element.firstChild;  
+        {
+           element = element.firstChild;
         }
         else if (element.nextSibling)
-        {  
-           element = element.nextSibling;  
+        {
+           element = element.nextSibling;
         }
         else
         {
@@ -467,8 +438,8 @@ function SearchResults(name)
           while (element && element!=parentElement && !element.nextSibling);
 
           if (element && element!=parentElement)
-          {  
-            element = element.nextSibling;  
+          {
+            element = element.nextSibling;
           }
         }
       }
@@ -521,7 +492,7 @@ function SearchResults(name)
           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 +563,7 @@ function SearchResults(name)
 
     this.ProcessKeys = function(e)
     {
-      if (e.type == "keydown") 
+      if (e.type == "keydown")
       {
         this.repeatOn = false;
         this.lastKey = e.keyCode;
@@ -613,7 +584,7 @@ function SearchResults(name)
       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 +598,7 @@ function SearchResults(name)
         {
           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
@@ -720,7 +691,7 @@ function SearchResults(name)
         if (elem)
         {
           elem.focus();
-        } 
+        }
       }
       else if (this.lastKey==27) // Escape
       {
@@ -803,3 +774,18 @@ function createResults()
   }
 }
 
+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);
+}
+