Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
versx committed Aug 22, 2020
1 parent 2805c3a commit fe1480d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 113 deletions.
1 change: 0 additions & 1 deletion src/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ router.post('/search', async (req, res) => {
router.post('/get_template/:name', async (req, res) => {
const template = req.params.name;
const view = req.body.data;
view.error = false;
const templateData = await utils.render(template, view);
res.send(templateData);
});
Expand Down
120 changes: 16 additions & 104 deletions src/views/index-js.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2424,7 +2424,7 @@ function getPokemonPopupContent (pokemon) {
//let content = '';
let pokemonName;
if (pokemon.form !== 0 && pokemon.form !== null) {
if (pokemon.form > 0) {
pokemonName = getFormName(pokemon.form) + ' ' + getPokemonName(pokemon.pokemon_id);
} else {
pokemonName = getPokemonName(pokemon.pokemon_id);
Expand All @@ -2439,15 +2439,13 @@ function getPokemonPopupContent (pokemon) {
const pkmn = masterfile.pokemon[pokemon.pokemon_id];
let pokemonTypes = [];
if (pkmn && pkmn.types && pkmn.types.length > 0) {
if (pkmn) {
const types = pkmn.types;
if (types && types.length > 0) {
if (types.length === 2) {
pokemonTypes.push(types[0].toLowerCase());
pokemonTypes.push(types[1].toLowerCase());
} else {
pokemonTypes.push(types[0].toLowerCase());
}
const types = pkmn.types;
if (types && types.length > 0) {
if (types.length === 2) {
pokemonTypes.push(types[0].toLowerCase());
pokemonTypes.push(types[1].toLowerCase());
} else {
pokemonTypes.push(types[0].toLowerCase());
}
}
}
Expand Down Expand Up @@ -2809,7 +2807,7 @@ function getPokestopPopupContent (pokestop) {
pokestop.time_since = getTimeSince(lastUpdatedDate);
const templateData = getTemplateData('pokestop', pokestop);
return templateData;

/*
let content = '<div class="text-center">';
if (pokestop.name === null || pokestop.name === '') {
content += '<h6><b>Unknown Pokestop Name</b></h6>';
Expand Down Expand Up @@ -2907,12 +2905,15 @@ function getPokestopPopupContent (pokestop) {
'</div>' +
'</div>';
return content;
*/
}

function getGymPopupContent (gym) {
const now = new Date();
const raidBattleDate = new Date(gym.raid_battle_timestamp * 1000);
const raidEndDate = new Date(gym.raid_end_timestamp * 1000);
const updatedDate = new Date(gym.updated * 1000);
const modifiedDate = new Date(gym.last_modified_timestamp * 1000);
const isRaid = raidEndDate >= now && parseInt(gym.raid_level) > 0;
const isRaidBattle = raidBattleDate <= now && isRaid;
Expand Down Expand Up @@ -2976,6 +2977,10 @@ function getGymPopupContent (gym) {
gym.guarding_pokemon_name = getPokemonName(gym.guarding_pokemon_id);
gym.team_name = getTeamName(gym.team_id);
gym.icon_path = availableIconStyles[selectedIconStyle];
gym.time_until_battle = getTimeUntill(raidBattleDate);
gym.time_until_end = getTimeUntill(raidEndDate);
gym.time_since_updated = getTimeSince(updatedDate);
gym.time_since_modified = getTimeSince(modifiedDate);
const templateData = getTemplateData('gym', gym);
return templateData;
/*
Expand Down Expand Up @@ -3163,45 +3168,11 @@ function getCellPopupContent (cell) {
cell.time_since = getTimeSince(new Date(cell.updated * 1000));
const templateData = getTemplateData('cell', cell);
return templateData;
/*
let content = '<center>';
content += '<h6><b>Level ' + cell.level + ' S2 Cell</b></h6>';
content += '<b>Id:</b> ' + cell.id + '<br>';
const updatedDate = new Date(cell.updated * 1000);
content += '<b>Last Updated:</b> ' + updatedDate.toLocaleTimeString() + ' (' + getTimeSince(updatedDate) + ')';
content += '</center>';
return content;
*/
}

function getSubmissionTypeCellPopupContent (cell) {
const templateData = getTemplateData('submission_cell', cell);
return templateData;
/*
let content = '<center>';
content += '<h6><b>Level ' + cell.level + ' S2 Cell</b></h6>';
content += '<b>Id:</b> ' + cell.id + '<br>';
content += '<b>Total Count:</b> ' + cell.count + '<br>';
content += '<b>Pokestop Count:</b> ' + cell.count_pokestops + '<br>';
content += '<b>Gym Count:</b> ' + cell.count_gyms + '<br>';
const gymThreshold = [2, 6, 20];
if (cell.count_gyms < 3) {
content += '<b>Submissions untill Gym:</b> ' + (gymThreshold[cell.count_gyms] - cell.count);
} else {
content += '<b>Submissions untill Gym:</b> Never';
}

if ((cell.count === 1 && cell.count_gyms < 1) || (cell.count === 5 && cell.count_gyms < 2) || (cell.count === 19 && cell.count_gyms < 3)) {
content += '<br><b>Next submission will cause a Gym!';
}

content += '</center>';
return content;
*/
}

function degreesToCardinal (d) {
Expand All @@ -3218,66 +3189,18 @@ function getWeatherPopupContent (weather) {
weather.time_since = getTimeSince(new Date(weather.updated * 1000));
const templateData = getTemplateData('weather', weather);
return templateData;
/*
let content = '<center>';
content += '<h6><b>' + weatherName + '</b><br></h6>';
content += '<b>Boosted Types:</b><br>' + weatherType + '<br>';
content += '<b>Cell ID:</b> ' + weather.id + '<br>';
content += '<b>Cell Level:</b> ' + weather.level + '<br>';
content += '<b>Lat:</b> ' + weather.latitude + '<br>';
content += '<b>Lon:</b> ' + weather.longitude + '<br>';
content += '<b>Gameplay Condition:</b> ' + weather.gameplay_condition + '<br>';
content += '<b>Wind Direction:</b> ' + weather.wind_direction + '° (' + degreesToCardinal(weather.wind_direction) + ')<br>';
content += '<b>Cloud Level:</b> ' + weather.cloud_level + '<br>';
content += '<b>Rain Level:</b> ' + weather.rain_level + '<br>';
content += '<b>Wind Level:</b> ' + weather.wind_level + '<br>';
content += '<b>Snow Level:</b> ' + weather.snow_level + '<br>';
content += '<b>Fog Level:</b> ' + weather.fog_level + '<br>';
content += '<b>Special Effects Level:</b> ' + weather.special_effect_level + '<br>';
content += '<b>Severity:</b> ' + weather.severity + '<br>';
content += '<b>Weather Warning:</b> ' + weather.warn_weather + '<br><br>';
const updatedDate = new Date(weather.updated * 1000);
content += '<b>Last Updated:</b> ' + updatedDate.toLocaleTimeString() + ' (' + getTimeSince(updatedDate) + ')';
content += '</center>';
return content;
*/
}

function getNestPopupContent(nest) {
nest.pokemon_name = getPokemonName(nest.pokemon_id);
nest.last_updated = new Date(nest.updated * 1000);
const templateData = getTemplateData('nest', nest);
return templateData;
/*
let content = `
<center>
<h6>Park: <b>${nest.name}</b></h6>
Pokemon: <b>${pokemonName}</b><br>
Average: <b>${nest.pokemon_avg.toLocaleString()}</b><br>
Count: <b>${nest.pokemon_count.toLocaleString()}</b><br>
<br>
<small>Last Updated: <b>${lastUpdated.toLocaleString()}</b></small><br>
</center>
`;
return content;
*/
}

function getScanAreaPopupContent(name, size) {
const templateData = getTemplateData('scanarea', { name, size });
return templateData;
/*
let content = `
<center>
<h6>Area: <b>${name}</b></h6>
Size: ${size} km<sup>2</sup>
</center>
`;
return content;
*/
}


Expand Down Expand Up @@ -3918,17 +3841,6 @@ function getDeviceMarker (device, ts) {
function getDevicePopupContent (device) {
const data = getTemplateData('device', device);
return data;
/*
const lastSeenDate = new Date(device.last_seen * 1000);
const lastSeen = lastSeenDate.toLocaleTimeString() + ' (' + getTimeSince(lastSeenDate) + ')';
const ts = Math.round((new Date()).getTime() / 1000);
const isOffline = isDeviceOffline(device, ts);
const content = '<center><h6><b>' + device.uuid + '</b></h6></center><br>' +
'<b>Instance:</b> ' + device.instance_name + '<br>' +
'<b>Last Seen:</b> ' + lastSeen + '<br>' +
'<b>Status:</b> ' + (isOffline ? 'Offline' : 'Online');
return content;
*/
}

function isDeviceOffline (device, ts) {
Expand Down
28 changes: 22 additions & 6 deletions templates/gym.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
</div>
<div class="row" style="margin:auto;">
<% if (has_raid_boss && is_raid_battle) { %>
<div class="col text-nowrap">
<% if (pokemon_types && pokemon_types.length > 0) { %>
<div class="col text-nowrap"></div>
<% pokemon_types.forEach(function(type) { %>
<img src="<%= icon_path %>/type/<%= type %>.png" height="16" width="16">&nbsp;
<% }); %>
</div>
<% } %>
</div>
<% } %>
</div>
</div>
Expand Down Expand Up @@ -81,22 +81,38 @@
<div class="col-12 col-md-8 center-vertical p-4">
<b>Team:</b> <%= team_name %><br>
<b>Slots Available:</b> <%= available_slots %><br>
<% if (guarding_pokemon_id) { %>
<% if (guarding_pokemon_id > 0) { %>
<b>Guard:</b> <%= guarding_pokemon_name %><br>
<% } %>
<% if (total_cp) { %>
<% if (total_cp > 0) { %>
<b>Total CP:</b> <%= total_cp.toLocaleString() %><br>
<% } %>
<% if (in_battle) { %>
<% if (in_battle > 0) { %>
<b>Gym is under attack!</b><br>
<% } %>
<% if (ex_raid_eligible) { %>
<% if (ex_raid_eligible > 0) { %>
<img src="<%= icon_path %>/misc/ex.png" height="24" width="32">
<% } %>
</div>
</div>
<br>
<% } %>

<div class="text-center">
<% if (is_raid && !is_raid_battle) { %>
<b>Raid Start:</b> <%= new Date(raid_battle_timestamp * 1000).toLocaleString() %> (<%= time_until_battle %>)<br>
<% } %>
<% if (is_raid) { %>
<b>Raid End:</b> <%= new Date(raid_end_timestamp * 1000).toLocaleString() %> (<%= time_until_end %>)<br><br>
<% } %>
</div>
<% if (updated) { %> %>
<small><b>Last Updated:</b> <%= new Date(updated * 1000).toLocaleString() %> (<%= time_since_updated %>)<br></small>
<% } %>
<% if (last_modified_timestamp) { %>
<small><b>Last Modified:</b> <%= new Date(last_modified_timestamp * 1000).toLocaleString() %> (<%= time_since_modified %>)<br></small>
<% } %>

<br>
<div class="row text-center text-nowrap">
<div class="col">
Expand Down
4 changes: 2 additions & 2 deletions templates/pokestop.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<br>
<% } %>

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

<br>
Expand Down

0 comments on commit fe1480d

Please sign in to comment.