Hello! I'm making a teambuilding website and I want to share a Javascript + PHP library that I made for it.
It basically gets the current moveset statistics for the selected pokemon, format and ranking from http://www.smogon.com/stats/.
I made this because I want to make something similar to bReakMyTeam with updated data.
How to use?
Why PHP + javascript?
I didn't know if it was possible to download a file via javascript so I used PHP to request the file, save the string into a javascript
variable and then manipulate it with the library.
Download: https://goo.gl/SIdU2T
Website (Shows example): http://teambuild.heliohost.org/popularset/
If anyone has any suggestions for the website or the library I would be more than glad to read them:)
It basically gets the current moveset statistics for the selected pokemon, format and ranking from http://www.smogon.com/stats/.
I made this because I want to make something similar to bReakMyTeam with updated data.
How to use?
Hide
Note: Put the PHP file on THE SAME FOLDER as the HTML file that is using the library.
The javascript file can go anywhere.
Code: Code: Code: When the callback function is executed you can access the requested data this way.
Code: The data is organized like this.
Code:
The javascript file can go anywhere.
- Load the library at the end of the BODY tag in the HTML document.
<script src="your_path/statLib.js" type="text/javascript"></script>- Create a "statistics" object.
Arguments: none.
stats = new statistics();- Use the function "get" to obtain the data.
Arguments: pokemon name as string, tier as string, ranking as string, callback function.
stats.get("infernape", "ou", "1825", function () {
//This gets executed after the data is downloaded and parsed into arrays.
});stats["abilities_array"]["abilities"][0] = "blaze"; //The name of that ability
stats["abilities_array"]["percentage"][0] = 61.82; //The usage of that ability
stats["abilities_array"]["abilities"][1] = "iron fist";
stats["abilities_array"]["percentage"][1] = 38.17;stats["pokemon_name"] - Name of the pokemon.
stats["abilities_array"]["abilities"][index] - Name of the ability.
stats["abilities_array"]["percentage"][index] - Usage of the ability.
stats["items_array"]["items"][index] - Name of the item.
stats["items_array"]["percentage"][index] - Usage of the item.
stats["spreads_array"]["natures"][index] - Name of the nature.
stats["spreads_array"]["spreads"][index][index of stat] - Array of stats (HP/ATK/DEF/SPA/SPD/SPE).
stats["spreads_array"]["percentage"][index] - Usage of the spread.
stats["moves_array"]["moves"][index] - Name of the move.
stats["moves_array"]["percentage"][index] - Usage of the move.
stats["teammates_array"]["teammates"][index] - Name of the team-mate.
stats["teammates_array"]["percentage"][index] - Usage of the team-mate.I didn't know if it was possible to download a file via javascript so I used PHP to request the file, save the string into a javascript
variable and then manipulate it with the library.
Download: https://goo.gl/SIdU2T
Website (Shows example): http://teambuild.heliohost.org/popularset/
If anyone has any suggestions for the website or the library I would be more than glad to read them:)