this.Search = function()

in workshop/static/en/api-reference/search/search.js [313:369]


  this.Search = function()
  {
    this.keyTimeout = 0;

    // strip leading whitespace
    var searchValue = this.DOMSearchField().value.replace(/^ +/, "");

    var code = searchValue.toLowerCase().charCodeAt(0);
    var idxChar = searchValue.substr(0, 1).toLowerCase();
    if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair
    {
      idxChar = searchValue.substr(0, 2);
    }

    var resultsPage;
    var resultsPageWithSearch;
    var hasResultsPage;

    var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
    if (idx!=-1)
    {
       var hexCode=idx.toString(16);
       resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + this.extension;
       resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
       hasResultsPage = true;
    }
    else // nothing available for this search term
    {
       resultsPage = this.resultsPath + '/nomatches' + this.extension;
       resultsPageWithSearch = resultsPage;
       hasResultsPage = false;
    }

    window.frames.MSearchResults.location = resultsPageWithSearch;
    var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();

    if (domPopupSearchResultsWindow.style.display!='block')
    {
       var domSearchBox = this.DOMSearchBox();
       this.DOMSearchClose().style.display = 'inline-block';
       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;
       var maxWidth = document.body.clientWidth;
       var width = 400;
       if (left<10) left=10;
       if (width+left+8>maxWidth) width=maxWidth-left-8;
       domPopupSearchResultsWindow.style.top     = top  + 'px';
       domPopupSearchResultsWindow.style.left    = left + 'px';
       domPopupSearchResultsWindow.style.width   = width + 'px';
    }

    this.lastSearchValue = searchValue;
    this.lastResultsPage = resultsPage;
  }