diff --git a/js/search.js b/js/search.js index e67506f8a..c8b5ec151 100644 --- a/js/search.js +++ b/js/search.js @@ -61,6 +61,8 @@ var bufs = ['','','','']; var topbufIndex = -1; + var nearMatch = (BattleSearchIndex[i].substr(0,query.length) !== query); + if (nearMatch && i) i--; for (var j=0; j<15; j++) { var id = BattleSearchIndex[i+j]; var type = BattleSearchIndexType[i+j]; @@ -68,7 +70,7 @@ if (!id) break; if (id.substr(0,query.length) !== query) { - if (j) break; + if (!(nearMatch && j<=1)) break; matchLength = 0; } if (j === 0 && this.exactMatch) { @@ -76,7 +78,6 @@ } if (!bufs[typeTable[type]]) bufs[typeTable[type]] = '
  • '+typeName[type]+'

  • '; - if (!matchLength) bufs[typeTable[type]] = '
  • No exact match found. The next match alphabetically is:
  • '+bufs[typeTable[type]]; bufs[typeTable[type]] += Search.renderRow(id, type, 0, matchLength + (BattleSearchIndexOffset[i+j][matchLength-1]||'0').charCodeAt(0)-48); } @@ -86,6 +87,8 @@ bufs[topbufIndex] = ''; } + if (nearMatch) topbuf = '
  • No exact match found. The closest matches alphabetically are:
  • '+topbuf; + this.el.innerHTML = ''; return true; };