diff --git a/data/search-index.js b/data/search-index.js index f2888f16c..e3fa05773 100644 --- a/data/search-index.js +++ b/data/search-index.js @@ -42,6 +42,7 @@ // }); exports.BattleSearchIndex = [ +"abomasnow", "abra", "absol", "absorb", @@ -1747,6 +1748,7 @@ exports.BattleSearchIndex = [ exports.BattleSearchIndexType = [ "pokemon", "pokemon", +"pokemon", "move", "item", "pokemon", @@ -3451,6 +3453,7 @@ exports.BattleSearchIndexOffset = [ "", "", "", +"", "0000001111", "", "", diff --git a/js/search.js b/js/search.js index 2408579df..e7343a0b8 100644 --- a/js/search.js +++ b/js/search.js @@ -24,32 +24,36 @@ // Search functions // - Search.prototype.q = ''; + Search.prototype.q = null; var typeTable = { pokemon: 0, - move: 1, - item: 2, - ability: 3 + type: 1, + move: 2, + item: 3, + ability: 4, + category: 5 }; var typeName = { pokemon: 'Pokemon', + type: 'Type', move: 'Moves', item: 'Items', - ability: 'Abilities' + ability: 'Abilities', + category: 'Category' }; Search.prototype.find = function(query) { query = toId(query); if (query === this.q) { - return; + return false; } this.q = query; if (!query) { - this.$el.html(''); - return; + this.el.innerHTML = ''; + return true; } - var i = this.getClosest(query); + var i = Search.getClosest(query); if (!BattleSearchIndex[i]) i--; var bufs = ['','','','']; @@ -59,19 +63,21 @@ var type = BattleSearchIndexType[i+j]; var matchLength = query.length; + if (!id) break; if (id.substr(0,query.length) !== query) { if (j) break; matchLength = 0; } if (!bufs[typeTable[type]]) bufs[typeTable[type]] = '