Skip to content

Commit

Permalink
Convert teambuilder from utilichart.js to search.js
Browse files Browse the repository at this point in the history
The teambuilder is now running on search.js! Not all new features I'd
like to be in are in, but we've now reached feature parity, and most
of the bugs I found during testing have been fixed.

New in search.js is on-demand DOM loading, which basically means
much faster performance because instead of trying to load every single
row of e.g. the pokemon list at once, we just load the part that's
visible, and load the rest only when you scroll it into view.

Also new in search.js is a dexsearch-like feature, replacing the old
details-search system. The new filter system is simpler and more powerful
and has the same API as /dexsearch, although not all the more advanced
dexsearch features are supported.

On-demand DOM loading makes teambuilder loading pretty much completely
instantaneous. There are other small differences in how selection of
pokemon/items/abilities/moves works, but it should overall make more
sense.
  • Loading branch information
Zarel committed Dec 22, 2015
1 parent 02f0c8e commit 7fa72c1
Show file tree
Hide file tree
Showing 9 changed files with 464 additions and 252 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ module.exports = {
"BattleAbilities": false, "BattleAliases": false, "BattleBackdrops": false, "BattleBackdropsFour": false, "BattleBackdropsThree": false, "BattleEffects": false,
"BattleFormats": false, "BattleFormatsData": false, "BattleLearnsets": false, "BattleItems": false, "BattleMoveAnims": false, "BattleMovedex": false, "BattleNatures": false,
"BattleOtherAnims": false, "BattlePokedex": false,"BattlePokemonSprites": false, "BattlePokemonSpritesBW": false, "BattleSearchCountIndex": false, "BattleSearchIndex": false,
"BattleSearchIndexOffset": false, "BattleSearchIndexType": false, "BattleStatIDs": false, "BattleStatNames": false, "BattleStats": false, "BattleStatusAnims": false, "BattleStatuses": false,
"BattleSearchIndexOffset": false, "BattleSearchIndexType": false, "BattleStatIDs": false, "BattleStatNames": false, "BattleStats": false, "BattleStatusAnims": false, "BattleStatuses": false, "BattleTeambuilderTable": false,

// Generic global variables
"Config": false, "Chart": false, "soundManager": false, "Storage": false, "Tools": false,
"Config": false, "BattleSearch": false, "soundManager": false, "Storage": false, "Tools": false,
"app": false, "toId": false, "toRoomid": false, "toUserid": false, "toName": false, "hashColor": false, "MD5": false,
"ChatHistory": false, "Topbar": false, "UserList": false,

Expand Down
48 changes: 48 additions & 0 deletions githooks/build-indexes
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,51 @@ const fs = require("fs");
}

console.log("DONE");

/*********************************************************
* Build teambuilder-tables.js
*********************************************************/

process.stdout.write("Building `data/teambuilder-tables.js`... ");

{
const BattleTeambuilderTable = {};

let buf = '// automatically built with githooks/build-indexes\n\n';

const pokemon = Object.keys(Tools.data.Pokedex);
pokemon.sort();
const tierTable = {};
for (const id of pokemon) {
const tier = Tools.getTemplate(id).tier;

if (!tierTable[tier]) tierTable[tier] = [];
tierTable[tier].push(id);
}

const tiers = BattleTeambuilderTable.tiers = [];
const formatSlices = BattleTeambuilderTable.formatSlices = {};

const tierOrder = ["Uber", "OU", "BL", "(OU)", "UU", "BL2", "RU", "BL3", "NU", "BL4", "PU", "NFE", "LC Uber", "LC"];

for (const tier of tierOrder) {
if (tier === "OU" || tier === "Uber" || tier === "UU" || tier === "RU" || tier === "NU" || tier === "PU" || tier === "LC") {
formatSlices[tier] = tiers.length;
}
if (!tierTable[tier]) continue;
if (tier.charAt(0) === '(') {
tiers.push(['header', tier.slice(1, -1) + " by technicality"]);
} else if (tier === "NFE") {
tiers.push(['header', "NFEs not in a higher tier"]);
} else {
tiers.push(['header', tier]);
}
tiers.push(...tierTable[tier]);
}

buf += 'exports.BattleTeambuilderTable = ' + JSON.stringify(BattleTeambuilderTable) + ';\n\n';

fs.writeFileSync('data/teambuilder-tables.js', buf);
}

console.log("DONE");
4 changes: 3 additions & 1 deletion index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ <h3><button class="closebutton" tabindex="-1"><i class="fa fa-times-circle"></i>
<script src="//play.pokemonshowdown.com/data/items.js?"></script>
<script src="//play.pokemonshowdown.com/data/abilities.js?"></script>

<script src="//play.pokemonshowdown.com/js/utilichart.js?"></script>
<script src="//play.pokemonshowdown.com/data/search-index.js?"></script>
<script src="//play.pokemonshowdown.com/data/teambuilder-tables.js?"></script>
<script src="//play.pokemonshowdown.com/js/search.js?"></script>

<script src="//play.pokemonshowdown.com/data/aliases.js?" async="async"></script>

Expand Down
8 changes: 4 additions & 4 deletions js/battledata.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,16 @@ var Tools = {
return '<div class="chat chatmessage-' + toId(name) + hlClass + mineClass + '">' + timestamp + '<strong style="' + color + '">' + clickableName + ':</strong> <span class="message-announce">' + Tools.parseMessage(target) + '</span></div>';
case 'data-pokemon':
if (!window.Chart) return '';
return '<div class="message"><ul class="utilichart">' + Chart.pokemonRow(Tools.getTemplate(target), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>';
return '<div class="message"><ul class="utilichart">' + BattleSearch.renderPokemonRow(Tools.getTemplate(target), 0, 0) + '<li style=\"clear:both\"></li></ul></div>';
case 'data-item':
if (!window.Chart) return '';
return '<div class="message"><ul class="utilichart">' + Chart.itemRow(Tools.getItem(target), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>';
return '<div class="message"><ul class="utilichart">' + BattleSearch.renderItemRow(Tools.getItem(target), 0, 0) + '<li style=\"clear:both\"></li></ul></div>';
case 'data-ability':
if (!window.Chart) return '';
return '<div class="message"><ul class="utilichart">' + Chart.abilityRow(Tools.getAbility(target), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>';
return '<div class="message"><ul class="utilichart">' + BattleSearch.renderAbilityRow(Tools.getAbility(target), 0, 0) + '<li style=\"clear:both\"></li></ul></div>';
case 'data-move':
if (!window.Chart) return '';
return '<div class="message"><ul class="utilichart">' + Chart.moveRow(Tools.getMove(target), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>';
return '<div class="message"><ul class="utilichart">' + BattleSearch.renderMoveRow(Tools.getMove(target), 0, 0) + '<li style=\"clear:both\"></li></ul></div>';
case 'text':
return '<div class="chat">' + Tools.escapeHTML(target) + '</div>';
case 'error':
Expand Down
Loading

0 comments on commit 7fa72c1

Please sign in to comment.