Skip to content

Commit fe1480d

Browse files
committed
Small fixes
1 parent 2805c3a commit fe1480d

File tree

4 files changed

+40
-113
lines changed

4 files changed

+40
-113
lines changed

src/routes/api.js

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ router.post('/search', async (req, res) => {
2929
router.post('/get_template/:name', async (req, res) => {
3030
const template = req.params.name;
3131
const view = req.body.data;
32-
view.error = false;
3332
const templateData = await utils.render(template, view);
3433
res.send(templateData);
3534
});

src/views/index-js.mustache

+16-104
Original file line numberDiff line numberDiff line change
@@ -2424,7 +2424,7 @@ function getPokemonPopupContent (pokemon) {
24242424
//let content = '';
24252425
24262426
let pokemonName;
2427-
if (pokemon.form !== 0 && pokemon.form !== null) {
2427+
if (pokemon.form > 0) {
24282428
pokemonName = getFormName(pokemon.form) + ' ' + getPokemonName(pokemon.pokemon_id);
24292429
} else {
24302430
pokemonName = getPokemonName(pokemon.pokemon_id);
@@ -2439,15 +2439,13 @@ function getPokemonPopupContent (pokemon) {
24392439
const pkmn = masterfile.pokemon[pokemon.pokemon_id];
24402440
let pokemonTypes = [];
24412441
if (pkmn && pkmn.types && pkmn.types.length > 0) {
2442-
if (pkmn) {
2443-
const types = pkmn.types;
2444-
if (types && types.length > 0) {
2445-
if (types.length === 2) {
2446-
pokemonTypes.push(types[0].toLowerCase());
2447-
pokemonTypes.push(types[1].toLowerCase());
2448-
} else {
2449-
pokemonTypes.push(types[0].toLowerCase());
2450-
}
2442+
const types = pkmn.types;
2443+
if (types && types.length > 0) {
2444+
if (types.length === 2) {
2445+
pokemonTypes.push(types[0].toLowerCase());
2446+
pokemonTypes.push(types[1].toLowerCase());
2447+
} else {
2448+
pokemonTypes.push(types[0].toLowerCase());
24512449
}
24522450
}
24532451
}
@@ -2809,7 +2807,7 @@ function getPokestopPopupContent (pokestop) {
28092807
pokestop.time_since = getTimeSince(lastUpdatedDate);
28102808
const templateData = getTemplateData('pokestop', pokestop);
28112809
return templateData;
2812-
2810+
/*
28132811
let content = '<div class="text-center">';
28142812
if (pokestop.name === null || pokestop.name === '') {
28152813
content += '<h6><b>Unknown Pokestop Name</b></h6>';
@@ -2907,12 +2905,15 @@ function getPokestopPopupContent (pokestop) {
29072905
'</div>' +
29082906
'</div>';
29092907
return content;
2908+
*/
29102909
}
29112910

29122911
function getGymPopupContent (gym) {
29132912
const now = new Date();
29142913
const raidBattleDate = new Date(gym.raid_battle_timestamp * 1000);
29152914
const raidEndDate = new Date(gym.raid_end_timestamp * 1000);
2915+
const updatedDate = new Date(gym.updated * 1000);
2916+
const modifiedDate = new Date(gym.last_modified_timestamp * 1000);
29162917
29172918
const isRaid = raidEndDate >= now && parseInt(gym.raid_level) > 0;
29182919
const isRaidBattle = raidBattleDate <= now && isRaid;
@@ -2976,6 +2977,10 @@ function getGymPopupContent (gym) {
29762977
gym.guarding_pokemon_name = getPokemonName(gym.guarding_pokemon_id);
29772978
gym.team_name = getTeamName(gym.team_id);
29782979
gym.icon_path = availableIconStyles[selectedIconStyle];
2980+
gym.time_until_battle = getTimeUntill(raidBattleDate);
2981+
gym.time_until_end = getTimeUntill(raidEndDate);
2982+
gym.time_since_updated = getTimeSince(updatedDate);
2983+
gym.time_since_modified = getTimeSince(modifiedDate);
29792984
const templateData = getTemplateData('gym', gym);
29802985
return templateData;
29812986
/*
@@ -3163,45 +3168,11 @@ function getCellPopupContent (cell) {
31633168
cell.time_since = getTimeSince(new Date(cell.updated * 1000));
31643169
const templateData = getTemplateData('cell', cell);
31653170
return templateData;
3166-
/*
3167-
let content = '<center>';
3168-
content += '<h6><b>Level ' + cell.level + ' S2 Cell</b></h6>';
3169-
content += '<b>Id:</b> ' + cell.id + '<br>';
3170-
3171-
const updatedDate = new Date(cell.updated * 1000);
3172-
3173-
content += '<b>Last Updated:</b> ' + updatedDate.toLocaleTimeString() + ' (' + getTimeSince(updatedDate) + ')';
3174-
content += '</center>';
3175-
return content;
3176-
*/
31773171
}
31783172

31793173
function getSubmissionTypeCellPopupContent (cell) {
31803174
const templateData = getTemplateData('submission_cell', cell);
31813175
return templateData;
3182-
/*
3183-
let content = '<center>';
3184-
content += '<h6><b>Level ' + cell.level + ' S2 Cell</b></h6>';
3185-
content += '<b>Id:</b> ' + cell.id + '<br>';
3186-
content += '<b>Total Count:</b> ' + cell.count + '<br>';
3187-
content += '<b>Pokestop Count:</b> ' + cell.count_pokestops + '<br>';
3188-
content += '<b>Gym Count:</b> ' + cell.count_gyms + '<br>';
3189-
3190-
const gymThreshold = [2, 6, 20];
3191-
3192-
if (cell.count_gyms < 3) {
3193-
content += '<b>Submissions untill Gym:</b> ' + (gymThreshold[cell.count_gyms] - cell.count);
3194-
} else {
3195-
content += '<b>Submissions untill Gym:</b> Never';
3196-
}
3197-
3198-
if ((cell.count === 1 && cell.count_gyms < 1) || (cell.count === 5 && cell.count_gyms < 2) || (cell.count === 19 && cell.count_gyms < 3)) {
3199-
content += '<br><b>Next submission will cause a Gym!';
3200-
}
3201-
3202-
content += '</center>';
3203-
return content;
3204-
*/
32053176
}
32063177

32073178
function degreesToCardinal (d) {
@@ -3218,66 +3189,18 @@ function getWeatherPopupContent (weather) {
32183189
weather.time_since = getTimeSince(new Date(weather.updated * 1000));
32193190
const templateData = getTemplateData('weather', weather);
32203191
return templateData;
3221-
3222-
/*
3223-
let content = '<center>';
3224-
content += '<h6><b>' + weatherName + '</b><br></h6>';
3225-
content += '<b>Boosted Types:</b><br>' + weatherType + '<br>';
3226-
content += '<b>Cell ID:</b> ' + weather.id + '<br>';
3227-
content += '<b>Cell Level:</b> ' + weather.level + '<br>';
3228-
content += '<b>Lat:</b> ' + weather.latitude + '<br>';
3229-
content += '<b>Lon:</b> ' + weather.longitude + '<br>';
3230-
content += '<b>Gameplay Condition:</b> ' + weather.gameplay_condition + '<br>';
3231-
content += '<b>Wind Direction:</b> ' + weather.wind_direction + '° (' + degreesToCardinal(weather.wind_direction) + ')<br>';
3232-
content += '<b>Cloud Level:</b> ' + weather.cloud_level + '<br>';
3233-
content += '<b>Rain Level:</b> ' + weather.rain_level + '<br>';
3234-
content += '<b>Wind Level:</b> ' + weather.wind_level + '<br>';
3235-
content += '<b>Snow Level:</b> ' + weather.snow_level + '<br>';
3236-
content += '<b>Fog Level:</b> ' + weather.fog_level + '<br>';
3237-
content += '<b>Special Effects Level:</b> ' + weather.special_effect_level + '<br>';
3238-
content += '<b>Severity:</b> ' + weather.severity + '<br>';
3239-
content += '<b>Weather Warning:</b> ' + weather.warn_weather + '<br><br>';
3240-
3241-
const updatedDate = new Date(weather.updated * 1000);
3242-
3243-
content += '<b>Last Updated:</b> ' + updatedDate.toLocaleTimeString() + ' (' + getTimeSince(updatedDate) + ')';
3244-
content += '</center>';
3245-
return content;
3246-
*/
32473192
}
32483193

32493194
function getNestPopupContent(nest) {
32503195
nest.pokemon_name = getPokemonName(nest.pokemon_id);
32513196
nest.last_updated = new Date(nest.updated * 1000);
32523197
const templateData = getTemplateData('nest', nest);
32533198
return templateData;
3254-
/*
3255-
let content = `
3256-
<center>
3257-
<h6>Park: <b>${nest.name}</b></h6>
3258-
Pokemon: <b>${pokemonName}</b><br>
3259-
Average: <b>${nest.pokemon_avg.toLocaleString()}</b><br>
3260-
Count: <b>${nest.pokemon_count.toLocaleString()}</b><br>
3261-
<br>
3262-
<small>Last Updated: <b>${lastUpdated.toLocaleString()}</b></small><br>
3263-
</center>
3264-
`;
3265-
return content;
3266-
*/
32673199
}
32683200

32693201
function getScanAreaPopupContent(name, size) {
32703202
const templateData = getTemplateData('scanarea', { name, size });
32713203
return templateData;
3272-
/*
3273-
let content = `
3274-
<center>
3275-
<h6>Area: <b>${name}</b></h6>
3276-
Size: ${size} km<sup>2</sup>
3277-
</center>
3278-
`;
3279-
return content;
3280-
*/
32813204
}
32823205

32833206

@@ -3918,17 +3841,6 @@ function getDeviceMarker (device, ts) {
39183841
function getDevicePopupContent (device) {
39193842
const data = getTemplateData('device', device);
39203843
return data;
3921-
/*
3922-
const lastSeenDate = new Date(device.last_seen * 1000);
3923-
const lastSeen = lastSeenDate.toLocaleTimeString() + ' (' + getTimeSince(lastSeenDate) + ')';
3924-
const ts = Math.round((new Date()).getTime() / 1000);
3925-
const isOffline = isDeviceOffline(device, ts);
3926-
const content = '<center><h6><b>' + device.uuid + '</b></h6></center><br>' +
3927-
'<b>Instance:</b> ' + device.instance_name + '<br>' +
3928-
'<b>Last Seen:</b> ' + lastSeen + '<br>' +
3929-
'<b>Status:</b> ' + (isOffline ? 'Offline' : 'Online');
3930-
return content;
3931-
*/
39323844
}
39333845

39343846
function isDeviceOffline (device, ts) {

templates/gym.ejs

+22-6
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
</div>
2222
<div class="row" style="margin:auto;">
2323
<% if (has_raid_boss && is_raid_battle) { %>
24-
<div class="col text-nowrap">
2524
<% if (pokemon_types && pokemon_types.length > 0) { %>
25+
<div class="col text-nowrap"></div>
2626
<% pokemon_types.forEach(function(type) { %>
2727
<img src="<%= icon_path %>/type/<%= type %>.png" height="16" width="16">&nbsp;
2828
<% }); %>
29+
</div>
2930
<% } %>
30-
</div>
3131
<% } %>
3232
</div>
3333
</div>
@@ -81,22 +81,38 @@
8181
<div class="col-12 col-md-8 center-vertical p-4">
8282
<b>Team:</b> <%= team_name %><br>
8383
<b>Slots Available:</b> <%= available_slots %><br>
84-
<% if (guarding_pokemon_id) { %>
84+
<% if (guarding_pokemon_id > 0) { %>
8585
<b>Guard:</b> <%= guarding_pokemon_name %><br>
8686
<% } %>
87-
<% if (total_cp) { %>
87+
<% if (total_cp > 0) { %>
8888
<b>Total CP:</b> <%= total_cp.toLocaleString() %><br>
8989
<% } %>
90-
<% if (in_battle) { %>
90+
<% if (in_battle > 0) { %>
9191
<b>Gym is under attack!</b><br>
9292
<% } %>
93-
<% if (ex_raid_eligible) { %>
93+
<% if (ex_raid_eligible > 0) { %>
9494
<img src="<%= icon_path %>/misc/ex.png" height="24" width="32">
9595
<% } %>
9696
</div>
9797
</div>
9898
<br>
9999
<% } %>
100+
101+
<div class="text-center">
102+
<% if (is_raid && !is_raid_battle) { %>
103+
<b>Raid Start:</b> <%= new Date(raid_battle_timestamp * 1000).toLocaleString() %> (<%= time_until_battle %>)<br>
104+
<% } %>
105+
<% if (is_raid) { %>
106+
<b>Raid End:</b> <%= new Date(raid_end_timestamp * 1000).toLocaleString() %> (<%= time_until_end %>)<br><br>
107+
<% } %>
108+
</div>
109+
<% if (updated) { %> %>
110+
<small><b>Last Updated:</b> <%= new Date(updated * 1000).toLocaleString() %> (<%= time_since_updated %>)<br></small>
111+
<% } %>
112+
<% if (last_modified_timestamp) { %>
113+
<small><b>Last Modified:</b> <%= new Date(last_modified_timestamp * 1000).toLocaleString() %> (<%= time_since_modified %>)<br></small>
114+
<% } %>
115+
100116
<br>
101117
<div class="row text-center text-nowrap">
102118
<div class="col">

templates/pokestop.ejs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
<br>
4444
<% } %>
4545

46-
<% if (last_updated) { %>
47-
<small><b>Last Updated:</b> <%= last_updated.toLocaleString() %> (<%= time_since %>)<br></small>
46+
<% if (updated) { %>
47+
<small><b>Last Updated:</b> <%= new Date(updated * 1000).toLocaleString() %> (<%= time_since %>)<br></small>
4848
<% } %>
4949

5050
<br>

0 commit comments

Comments
 (0)