Skip to content

Commit cd335e9

Browse files
versxTurtIeSocks
andauthored
Hide Individual Quests (#336)
* Hide individual quests * Update static/js/index.js Co-authored-by: Derick M. <58572875+TurtIeSocks@users.noreply.github.com> * Make it more clear what's being excluded for pokestops Co-authored-by: Derick M. <58572875+TurtIeSocks@users.noreply.github.com>
1 parent 5398248 commit cd335e9

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

static/css/popups.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
padding: 5px;
66
}
77

8-
.exclude {
8+
.exclude, .hide {
99
text-align: center;
1010
font-size: small;
1111
font-weight: bold;

static/js/index.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ let settingsNew = {};
5959

6060
const hiddenPokemonIds = [];
6161
const pokemonWithTimers = [];
62+
const hiddenQuestIds = [];
6263

6364
let openedPokemon;
6465
let openedPokestop;
@@ -2286,7 +2287,7 @@ function loadData () {
22862287
ts = Math.round((new Date()).getTime() / 1000);
22872288
$.each(pokestops, function (index, pokestop) {
22882289
if (showPokestops ||
2289-
(showQuests && pokestop.quest_type !== null) ||
2290+
(showQuests && pokestop.quest_type !== null && !hiddenQuestIds.includes(pokestop.id)) ||
22902291
(showInvasions && pokestop.incident_expire_timestamp > ts)
22912292
) {
22922293
if (pokestop.updated > lastUpdateServer) {
@@ -2366,6 +2367,9 @@ function loadData () {
23662367
setDespawnTimer(oldPokestop);
23672368
}
23682369
}
2370+
if (hiddenQuestIds.includes(oldPokestop.id)) {
2371+
map.removeLayer(oldPokestop.marker);
2372+
}
23692373
}
23702374
}
23712375
});
@@ -3255,7 +3259,7 @@ const getPokemonPopupContent = (pokemon) => {
32553259
<table class="table-fourth-row">
32563260
<tr>
32573261
<td><a id="h${pokemon.id}" title="Show Despawn Timer" href="#" onclick="addPokemonTimer('${pokemon.id}');return false;"><b>[Timer]</b></a></td>
3258-
<td><a id="h${pokemon.id}" title="Hide Pokemon" href="#" onclick="setIndividualPokemonHidden('${pokemon.id}');return false;"><b>[Hide]</b></a></td>
3262+
<td><a id="h${pokemon.id}" title="Hide Pokemon" href="#" onclick="setPokemonMarkerHidden('${pokemon.id}');return false;"><b>[Hide]</b></a></td>
32593263
<td><a title="Filter Pokemon" href="#" onclick="addPokemonFilter(${pokemon.pokemon_id}, ${pokemon.form}, false);return false;"><b>[Exclude]</b></a></td>
32603264
</tr>
32613265
</table>
@@ -3303,21 +3307,33 @@ const getPokemonPopupContent = (pokemon) => {
33033307
}
33043308

33053309
// eslint-disable-next-line no-unused-vars
3306-
function setIndividualPokemonHidden (id) {
3310+
function setPokemonMarkerHidden (id) {
33073311
if (id > 0 && !hiddenPokemonIds.includes(id)) {
33083312
hiddenPokemonIds.push(id);
33093313
const pokemonMarker = pokemonMarkers.find(function (value) {
33103314
return id === value.id;
33113315
});
33123316

33133317
if (pokemonMarker === null) {
3314-
console.log('Failed to find pokemon marker', id);
3318+
console.error('Failed to find pokemon marker', id);
33153319
} else {
33163320
map.removeLayer(pokemonMarker.marker);
33173321
}
33183322
}
33193323
}
33203324

3325+
function setQuestPokestopMarkerHidden (id) {
3326+
hiddenQuestIds.push(id);
3327+
const pokestopMarker = pokestopMarkers.find(function (value) {
3328+
return id === value.id;
3329+
});
3330+
if (pokestopMarker === null) {
3331+
console.error('Failed to find pokestop marker', id);
3332+
} else {
3333+
map.removeLayer(pokestopMarker.marker);
3334+
}
3335+
}
3336+
33213337
const addPokemonTimer = (id) => {
33223338
const ts = new Date() / 1000;
33233339
if (id > 0 && !pokemonWithTimers.includes(id)) {
@@ -3467,7 +3483,16 @@ function getPokestopPopupContent (pokestop) {
34673483

34683484
const questReward = pokestop.quest_rewards ? pokestop.quest_rewards[0] : {};
34693485
if (pokestop.quest_type !== null) {
3470-
content += `<a title="Filter Quest" href="#" onclick='addQuestFilter(${JSON.stringify(questReward.info)}, false);return false;'><div class="exclude">[Exclude]</div></a>`;
3486+
content += `
3487+
<div class="pokemon-timer-hide-exclude">
3488+
<table class="table-fourth-row">
3489+
<tr>
3490+
<td><a title="Filter Quest" href="#" onclick='addQuestFilter(${JSON.stringify(questReward.info)}, false);return false;'><b>[Exclude Quest]</b></a></td>
3491+
<td><a title="Hide Quest" href="#" onclick="setQuestPokestopMarkerHidden('${pokestop.id}');return false;"><b>[Hide Quest]</b></a></td>
3492+
</tr>
3493+
</table>
3494+
</div>
3495+
`;
34713496
}
34723497
content += getNavigation(pokestop);
34733498
return content;

0 commit comments

Comments
 (0)