Skip to content

Commit

Permalink
Merge pull request #46 from versx/quest-filter-popup
Browse files Browse the repository at this point in the history
Filter Quest via Marker Popup
  • Loading branch information
versx authored Aug 19, 2020
2 parents d7ffe2e + 509c598 commit 4b16f2f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
}
},
"discord": {
"enabled": true,
"enabled": false,
"status": "Map Status: Online",
"botToken": "",
"clientId": "",
Expand Down
26 changes: 26 additions & 0 deletions src/views/index-js.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,25 @@ function addPokemonFilter (pokemonId, formId, show) {
});
}

function addQuestFilter (pokemonId, itemId, show) {
if (pokemonId > 0) {
questFilter['p' + pokemonId].show = show;
}
if (itemId > 0) {
questFilter['i' + itemId].show = show;
}
store('quest_filter', JSON.stringify(questFilter));

$.each(pokestopMarkers, function (index, pokestop) {
const reward = pokestop.quest_rewards ? pokestop.quest_rewards[0] : {};
const rewardPokemonId = reward.info.pokemon_id || 0;
const rewardItemId = reward.info.item_id || 0;
if (rewardPokemonId === pokemonId && rewardItemId === itemId) {
map.removeLayer(pokestop.marker);
}
});
}

function getPokestopPopupContent (pokestop) {
const now = new Date();
const lureExpireDate = new Date(pokestop.lure_expire_timestamp * 1000);
Expand Down Expand Up @@ -3113,9 +3132,16 @@ function getPokestopPopupContent (pokestop) {
content += '<small><b>Last Updated:</b> ' + updatedDate.toLocaleDateString() + ' ' + updatedDate.toLocaleTimeString() + ' (' + getTimeSince(updatedDate) + ')<br></small>';
}

const questReward = pokestop.quest_rewards ? pokestop.quest_rewards[0] : {};
content +=
'<br>';
if (pokestop.quest_type !== null) {
content += '<center><a title="Filter Quest" href="#" onclick="addQuestFilter(' + ((questReward.info || {}).pokemon_id || 0) + ', ' + ((questReward.info || {}).item_id || 0) + ', false);return false;"><b>[Exclude]</b></a></center>';
}
content +=
'<br>' +
'<div class="row text-center">' +
'<br>' +
'<div class="col">' +
'<a href="https://www.google.com/maps/place/' + pokestop.lat + ',' + pokestop.lon + '" title="Open in Google Maps">' +
`<img src="${availableIconStyles[selectedIconStyle]}/navigation/gmaps.png" height="32" width="32">` +
Expand Down

0 comments on commit 4b16f2f

Please sign in to comment.