Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Notify on 0 iv toggle switch #52

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"notifyPokemon": true,
"notifyRarity": true,
"notifyIv": true,
"notifyIvZero": true,
"notifyLevel": true,
"notifyRaid": true,
"enableRaids": true,
Expand Down
3 changes: 3 additions & 0 deletions config/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
$noNotifyIv = false; // true/false
$notifyIv = '""'; // "" for empty or a number

$noNotifyIvZero = false; // true/false
$notifyIvZero = 'false'; // true/false

$noNotifyLevel = false; // true/false
$notifyLevel = '""'; // "" for empty or a number

Expand Down
3 changes: 3 additions & 0 deletions config/example.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
$noNotifyIv = false; // true/false
$notifyIv = '""'; // "" for empty or a number

$noNotifyIvZero = false; // true/false
$notifyIvZero = 'false'; // true/false

$noNotifyLevel = false; // true/false
$notifyLevel = '""'; // "" for empty or a number

Expand Down
15 changes: 15 additions & 0 deletions pre-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,20 @@ class="onoffswitch-checkbox"/>
}
?>
<?php
if (!$noNotifyIvZero) {
echo '<div class="form-control switch-container">
<h3>Notify on 0 iv</h3>
<div class="onoffswitch">
<input id="notifyivzero-switch" type="checkbox" name="notifyivzero-switch" class="onoffswitch-checkbox"
checked>
<label class="onoffswitch-label" for="notifyivzero-switch">
<span class="switch-label" data-on="On" data-off="Off"></span>
<span class="switch-handle"></span>
</label>
</div></div>';
}
?>
<?php
if (!$noNotifyLevel) {
echo '<div class="form-control">
<label for="notify-level">
Expand Down Expand Up @@ -686,6 +700,7 @@ class="onoffswitch-checkbox"/>
var notifyPokemon = <?php echo $noNotifyPokemon ? '[]' : $notifyPokemon ?>;
var notifyRarity = <?php echo $noNotifyRarity ? '[]' : $notifyRarity ?>;
var notifyIv = <?php echo $noNotifyIv ? '""' : $notifyIv ?>;
var notifyIvZero = <?php echo $noNotifyIvZero ? 'false' : $notifyIvZero ?>;
var notifyLevel = <?php echo $noNotifyLevel ? '""' : $notifyLevel ?>;
var notifyRaid = <?php echo $noNotifyRaid ? 0 : $notifyRaid ?>;
var enableRaids = <?php echo $noRaids ? 'false' : $enableRaids ?>;
Expand Down
5 changes: 5 additions & 0 deletions static/js/map.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ var StoreOptions = {
default: notifyIv,
type: StoreTypes.Number
},
'remember_show_ivzero':
{
default: notifyIvZero,
type: StoreTypes.Boolean
},
'remember_text_level_notify':
{
default: notifyLevel,
Expand Down
16 changes: 16 additions & 0 deletions static/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var $selectPokemonNotify
var $selectRarityNotify
var $textPerfectionNotify
var $textLevelNotify
var $selectNotifyIvZero
var $raidNotify
var $selectStyle
var $selectIconSize
Expand Down Expand Up @@ -322,6 +323,7 @@ function initSidebar() {
$('#spawnpoints-switch').prop('checked', Store.get('showSpawnpoints'))
$('#ranges-switch').prop('checked', Store.get('showRanges'))
$('#sound-switch').prop('checked', Store.get('playSound'))
$('#notifyivzero-switch').prop('checked', Store.get('remember_show_ivzero'))
$('#cries-switch').prop('checked', Store.get('playCries'))
$('#cries-switch-wrapper').toggle(Store.get('playSound'))
$('#cries-type-filter-wrapper').toggle(Store.get('playCries'))
Expand Down Expand Up @@ -840,6 +842,15 @@ function customizePokemonMarker(marker, item, skipNotification) {
marker.setAnimation(google.maps.Animation.BOUNCE)
}
}
if ($selectNotifyIvZero && perfection === 0) {
if (!skipNotification) {
checkAndCreateSound(item['pokemon_id'])
sendNotification(getNotifyText(item).fav_title, getNotifyText(item).fav_text, iconpath + item['pokemon_id'] + '.png', item['latitude'], item['longitude'])
}
if (marker.animationDisabled !== true) {
marker.setAnimation(google.maps.Animation.BOUNCE)
}
}
}

if (item['level'] != null) {
Expand Down Expand Up @@ -2500,6 +2511,7 @@ $(function () {
$selectRarityNotify = $('#notify-rarity')
$textPerfectionNotify = $('#notify-perfection')
$textLevelNotify = $('#notify-level')
$selectNotifyIvZero = $('#notifyivzero-switch')
$raidNotify = $('#notify-raid')
var numberOfPokemon = 386

Expand Down Expand Up @@ -2601,6 +2613,7 @@ $(function () {
$selectPokemonNotify.val(Store.get('remember_select_notify')).trigger('change')
$selectRarityNotify.val(Store.get('remember_select_rarity_notify')).trigger('change')
$textPerfectionNotify.val(Store.get('remember_text_perfection_notify')).trigger('change')
$selectNotifyIvZero.val(Store.get('remember_show_ivzero')).trigger('change')
$textLevelNotify.val(Store.get('remember_text_level_notify')).trigger('change')
$raidNotify.val(Store.get('remember_raid_notify')).trigger('change')

Expand Down Expand Up @@ -2720,6 +2733,9 @@ $(function () {
}
return buildSwitchChangeListener(mapData, ['pokestops'], 'showPokestops').bind(this)()
})
$('#notifyivzero-switch').change(function () {
Store.set('remember_show_ivzero', this.checked)
})

$('#sound-switch').change(function () {
Store.set('playSound', this.checked)
Expand Down