Skip to content

Commit

Permalink
Update custom.js: add default Pokémon to "Hide Pokémon". (#2471)
Browse files Browse the repository at this point in the history
* Expanded 'custom.js' with another example.

A lot of people have been asking on how to exclude some Pokémon by default, so having it in the wiki is a good idea.

* Updated to Sebby's request.

* Tiny mistake fix
  • Loading branch information
Widdin authored and sebastienvercammen committed Feb 15, 2018
1 parent c604179 commit e08d082
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions docs/extras/custom-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Place your custom code into 'custom.js' in the folder 'static/js'. *Examples are
Examples for a MOTD, google analytics and disabling scaling icons by rarity are included in custom.js.example!
The example below is how to set default options usually done by editing core files.

**Set a new map style by default.**
* **Set a new map style by default.**
First we set a variable for it and pick which style we want as default.
```
const map_style = 'satellite'
Expand All @@ -22,9 +22,31 @@ Next we have to tell the script to store the value to set it.
```
Store.set('map_style', map_style)
```

Whenever you edit custom.js you will have to run `npm run build` to set the changes.
When you load the map it will be set to satellite as default.

Setting options in this way forces that setting on page load, so even if a user changes the setting it will revert back to what you have set in custom.js every time, keep this in mind when forcing settings.
Setting options in this way forces that setting on page load, so even if a user changes the setting it will revert back to what you have set in custom.js every time, keep this in mind when forcing settings.

If you don't want to revert back to what you have set in custom.js every time, you can do it like in the example below.

* **Add default Pokémon to "Hide Pokémon".**
First we need to retrieve what has already been set so we don't overwrite anything excluded in the interface. Then add the Pokémon we want to hide by default **by adding the Pokémon IDs to the excludedPokemon-array, e.g. [13, 16] as shown in the example below**. Finally we have to tell the script to store the value to set it.

```
const totalExcluded = Store.get('remember_select_exclude') // Retrieve what has already been set.
const excludedPokemon = [13, 16] // Add Pokémon IDs separated by commas (e.g. [1, 2, 3])
// If the new default Pokémon doesn't exist then add it to the list.
excludedPokemon.forEach((id) => {
if (totalExcluded.indexOf(id) === -1) {
totalExcluded.push(id)
}
})
Store.set('remember_select_exclude', totalExcluded) // Tell the script to store the value to set it.
```
When you load the map Weedle and Pidgey will be hidden as default.

See 'custom.js.example' for more information.

0 comments on commit e08d082

Please sign in to comment.