git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

docs/doxygen_search_override.js

      1 
      2 
      3 // This file gets appended to the doxygen search.js to override and improve the search functions
      4 
      5 
      6 // //////////////////
      7 
      8 // Replacing a function in an existing object (function)
      9 
     10 // var oldClass = mynamespace.myclass; // Copy original before overwriting
     11 // mynamespace.myclass = function () {
     12 //     // Apply the original constructor on this object
     13 //     oldClass.apply(this, arguments);
     14 //     // Now overwrite the target function after construction
     15 //     this.myfunction = function () { alert("Overwritten"); };
     16 // };
     17 // mynamespace.prototype = oldClass.prototype; // Same prototype
     18 
     19 // //////////////////
     20 
     21 
     22 var oldSearchBox = SearchBox; // Copy original before overwriting
     23 SearchBox = function () {
     24   // Apply the original constructor on this object
     25   oldSearchBox.apply(this, arguments);
     26 
     27   this.Search = function()
     28   {
     29     this.keyTimeout = 0;
     30 
     31     // strip leading whitespace
     32     var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
     33 
     34     // var code = searchValue.toLowerCase().charCodeAt(0);
     35     // var idxChar = searchValue.substr(0, 1).toLowerCase();
     36     // if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair
     37     // {
     38     //   idxChar = searchValue.substr(0, 2);
     39     // }
     40 
     41     // var resultsPage;
     42     // var resultsPageWithSearch;
     43     // var hasResultsPage;
     44 
     45     // var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
     46     // if (idx!=-1)
     47     // {
     48     //    var hexCode=idx.toString(16);
     49     //    resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + this.extension;
     50     //    resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
     51     //    hasResultsPage = true;
     52     // }
     53     // else // nothing available for this search term
     54     // {
     55     //    resultsPage = this.resultsPath + '/nomatches' + this.extension;
     56     //    resultsPageWithSearch = resultsPage;
     57     //    hasResultsPage = false;
     58     // }
     59     // CHANGED START
     60     var resultsPage;
     61     var resultsPageWithSearch;
     62     var hasResultsPage;
     63 
     64     resultsPage = this.resultsPath + '/' + 'combined.html';
     65     resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
     66     hasResultsPage = true;
     67     // CHANGED END
     68 
     69     window.frames.MSearchResults.location = resultsPageWithSearch;
     70     var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
     71 
     72     if (domPopupSearchResultsWindow.style.display!='block')
     73     {
     74        var domSearchBox = this.DOMSearchBox();
     75        this.DOMSearchClose().style.display = 'inline-block';
     76        if (this.insideFrame)
     77        {
     78          var domPopupSearchResults = this.DOMPopupSearchResults();
     79          domPopupSearchResultsWindow.style.position = 'relative';
     80          domPopupSearchResultsWindow.style.display  = 'block';
     81          var width = document.body.clientWidth - 8; // the -8 is for IE :-(
     82          domPopupSearchResultsWindow.style.width    = width + 'px';
     83          domPopupSearchResults.style.width          = width + 'px';
     84        }
     85        else
     86        {
     87          var domPopupSearchResults = this.DOMPopupSearchResults();
     88          var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth;
     89          var top  = getYPos(domSearchBox) + 20;  // domSearchBox.offsetHeight + 1;
     90          domPopupSearchResultsWindow.style.display = 'block';
     91          left -= domPopupSearchResults.offsetWidth;
     92          domPopupSearchResultsWindow.style.top     = top  + 'px';
     93          domPopupSearchResultsWindow.style.left    = left + 'px';
     94        }
     95     }
     96 
     97     this.lastSearchValue = searchValue;
     98     this.lastResultsPage = resultsPage;
     99   }
    100 };
    101 SearchBox.prototype = oldSearchBox.prototype; // Same prototype
    102 
    103 
    104 
    105 var oldSearchResults = SearchResults; // Copy original before overwriting
    106 SearchResults = function () {
    107   // Apply the original constructor on this object
    108   oldSearchResults.apply(this, arguments);
    109 
    110 
    111     this.Search = function(search)
    112     {
    113       if (!search) // get search word from URL
    114       {
    115         search = window.location.search;
    116         search = search.substring(1);  // Remove the leading '?'
    117         search = unescape(search);
    118       }
    119 
    120       search = search.replace(/^ +/, ""); // strip leading spaces
    121       search = search.replace(/ +$/, ""); // strip trailing spaces
    122       search = search.toLowerCase();
    123       // search = convertToId(search);
    124       // Commented out above (CHANGED START & END)
    125 
    126       var resultRows = document.getElementsByTagName("div");
    127       var matches = 0;
    128 
    129       var i = 0;
    130       while (i < resultRows.length)
    131       {
    132         var row = resultRows.item(i);
    133         if (row.className == "SRResult")
    134         {
    135           var rowMatchName = row.id.toLowerCase();
    136           // rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_'
    137 
    138           // if (search.length<=rowMatchName.length &&
    139           //    rowMatchName.substr(0, search.length)==search)
    140           // {
    141           // CHANGED START
    142           rowMatchName = rowMatchName.replace(/^[sr\d_]*5f_/, ''); // strip 'sr123_5f'
    143           rowMatchName = rowMatchName.replace(/5f/g, ''); // strip '5f' chars
    144           // rowMatchName = rowMatchName.replace(/_/, ' '); // underscores to spaces
    145 
    146           if (rowMatchName.includes(search))
    147           {
    148             // CHANGED END
    149             row.style.display = 'block';
    150             matches++;
    151           }
    152           else
    153           {
    154             row.style.display = 'none';
    155           }
    156         }
    157         i++;
    158       }
    159       document.getElementById("Searching").style.display='none';
    160       if (matches == 0) // no results
    161       {
    162         document.getElementById("NoMatches").style.display='block';
    163       }
    164       else // at least one result
    165       {
    166         document.getElementById("NoMatches").style.display='none';
    167       }
    168       this.lastMatchCount = matches;
    169       return true;
    170     }
    171 };
    172 SearchResults.prototype = oldSearchResults.prototype; // Same prototype
    173 

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.