⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.js

📁 launchpad msp430官方示例
💻 JS
📖 第 1 页 / 共 2 页
字号:
// 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: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",  1: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",  2: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"};var indexSectionNames ={  0: "all",  1: "files",  2: "functions"};function convertToId(search){  var result = '';  for (i=0;i<search.length;i++)  {    var c = search.charAt(i);    var cn = c.charCodeAt(0);    if (c.match(/[a-z0-9]/))    {      result+=c;    }    else if (cn<16)     {      result+="_0"+cn.toString(16);    }    else     {      result+="_"+cn.toString(16);    }  }  return result;}function getXPos(item){  var x = 0;  if (item.offsetWidth)  {    while (item && item!=document.body)    {      x   += item.offsetLeft;      item = item.offsetParent;    }  }  return x;}function getYPos(item){  var y = 0;  if (item.offsetWidth)  {     while (item && item!=document.body)     {       y   += item.offsetTop;       item = item.offsetParent;     }  }  return y;}/* A class handling everything associated with the search panel.   Parameters:   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;  this.keyTimeout            = 0;  this.keyTimeoutLength      = 500;  this.closeSelectionTimeout = 300;  this.lastSearchValue       = "";  this.lastResultsPage       = "";  this.hideTimeout           = 0;  this.searchIndex           = 0;  this.searchActive          = false;  this.insideFrame           = inFrame;  this.searchLabel           = label;  // ----------- DOM Elements  this.DOMSearchField = function()  {  return document.getElementById("MSearchField");  }  this.DOMSearchSelect = function()  {  return document.getElementById("MSearchSelect");  }  this.DOMSearchSelectWindow = function()  {  return document.getElementById("MSearchSelectWindow");  }  this.DOMPopupSearchResults = function()  {  return document.getElementById("MSearchResults");  }  this.DOMPopupSearchResultsWindow = function()  {  return document.getElementById("MSearchResultsWindow");  }  this.DOMSearchClose = function()  {  return document.getElementById("MSearchClose"); }  this.DOMSearchBox = function()  {  return document.getElementById("MSearchBox");  }  // ------------ Event Handlers  // Called when focus is added or removed from the search field.  this.OnSearchFieldFocus = function(isActive)  {    this.Activate(isActive);  }  this.OnSearchSelectShow = function()  {    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;      // 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';    }    // stop selection hide timer    if (this.hideTimeout)     {      clearTimeout(this.hideTimeout);      this.hideTimeout=0;    }    return false; // to avoid "image drag" default event  }  this.OnSearchSelectHide = function()  {    this.hideTimeout = setTimeout(this.name +".CloseSelectionWindow()",                                  this.closeSelectionTimeout);  }  // Called when the content of the search field is changed.  this.OnSearchFieldChange = function(evt)  {    if (this.keyTimeout) // kill running timer    {      clearTimeout(this.keyTimeout);      this.keyTimeout = 0;    }    var e  = (evt) ? evt : window.event; // for IE    if (e.keyCode==40 || e.keyCode==13)    {      if (e.shiftKey==1)      {        this.OnSearchSelectShow();        var win=this.DOMSearchSelectWindow();         for (i=0;i<win.childNodes.length;i++)        {          var child = win.childNodes[i]; // get span within a          if (child.className=='SelectItem')          {            child.focus();            return;          }        }        return;      }      else if (window.frames.MSearchResults.searchResults)      {        var elem = window.frames.MSearchResults.searchResults.NavNext(0);        if (elem) elem.focus();      }    }    else if (e.keyCode==27) // Escape out of the search field    {      this.DOMSearchField().blur();      this.DOMPopupSearchResultsWindow().style.display = 'none';      this.DOMSearchClose().style.display = 'none';      this.lastSearchValue = '';      this.Activate(false);      return;    }    // strip whitespaces    var searchValue = this.DOMSearchField().value.replace(/ +/g, "");    if (searchValue != this.lastSearchValue) // search value has changed    {      if (searchValue != "") // non-empty search      {        // set timer for search update        this.keyTimeout = setTimeout(this.name + '.Search()',                                     this.keyTimeoutLength);      }      else // empty search field      {        this.DOMPopupSearchResultsWindow().style.display = 'none';        this.DOMSearchClose().style.display = 'none';        this.lastSearchValue = '';      }    }  }  this.SelectItemCount = function(id)  {    var count=0;    var win=this.DOMSearchSelectWindow();     for (i=0;i<win.childNodes.length;i++)    {      var child = win.childNodes[i]; // get span within a      if (child.className=='SelectItem')      {        count++;      }    }    return count;  }  this.SelectItemSet = function(id)  {    var i,j=0;    var win=this.DOMSearchSelectWindow();     for (i=0;i<win.childNodes.length;i++)    {      var child = win.childNodes[i]; // get span within a      if (child.className=='SelectItem')      {        var node = child.firstChild;        if (j==id)        {          node.innerHTML='&bull;';        }        else        {          node.innerHTML='&#160;';        }        j++;      }    }  }  // Called when an search filter selection is made.  // set item with index id as the active item  this.OnSelectItem = function(id)  {    this.searchIndex = id;    this.SelectItemSet(id);    var searchValue = this.DOMSearchField().value.replace(/ +/g, "");    if (searchValue!="" && this.searchActive) // something was found -> do a search    {      this.Search();    }  }  this.OnSearchSelectKey = function(evt)  {    var e = (evt) ? evt : window.event; // for IE    if (e.keyCode==40 && this.searchIndex<this.SelectItemCount()) // Down    {      this.searchIndex++;      this.OnSelectItem(this.searchIndex);    }    else if (e.keyCode==38 && this.searchIndex>0) // Up    {      this.searchIndex--;      this.OnSelectItem(this.searchIndex);    }    else if (e.keyCode==13 || e.keyCode==27)    {      this.OnSelectItem(this.searchIndex);      this.CloseSelectionWindow();      this.DOMSearchField().focus();    }    return false;  }  // --------- Actions  // Closes the results window.  this.CloseResultsWindow = function()  {    this.DOMPopupSearchResultsWindow().style.display = 'none';    this.DOMSearchClose().style.display = 'none';    this.Activate(false);  }  this.CloseSelectionWindow = function()  {    this.DOMSearchSelectWindow().style.display = 'none';  }  // Performs a search.  this.Search = function()  {    this.keyTimeout = 0;    // strip leading whitespace    var searchValue = this.DOMSearchField().value.replace(/^ +/, "");    var code = searchValue.toLowerCase().charCodeAt(0);    var hexCode;    if (code<16)     {      hexCode="0"+code.toString(16);    }    else     {      hexCode=code.toString(16);    }    var resultsPage;    var resultsPageWithSearch;    var hasResultsPage;    if (indexSectionsWithContent[this.searchIndex].charAt(code) == '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;    }    window.frames.MSearchResults.location.href = resultsPageWithSearch;      var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();    if (domPopupSearchResultsWindow.style.display!='block')    {       var domSearchBox = this.DOMSearchBox();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -