From 710b8dc9a649e28af05395c3d6e15b2cbe7944ec Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 12:36:39 -0700 Subject: [PATCH 01/20] Add custom device popup template --- src/routes/api.js | 7 +++++ src/services/utils.js | 52 ++++++++++++++++++++++++++++++++++++- src/views/header.mustache | 1 + src/views/index-js.mustache | 30 +++++++++++++++++++++ templates/devices.mustache | 7 +++++ 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 templates/devices.mustache diff --git a/src/routes/api.js b/src/routes/api.js index b9255743..127c01dc 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -26,6 +26,13 @@ router.post('/search', async (req, res) => { res.json({ data: data }); }); +router.post('/get_template/:name', async (req, res) => { + const template = req.params.name; + const view = req.body.data; + const templateData = await utils.render(template, view); + res.send(templateData); +}); + const getData = async (perms, filter) => { //console.log('Filter:', filter); diff --git a/src/services/utils.js b/src/services/utils.js index 8fdcc28b..2b38fee8 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -1,6 +1,11 @@ 'use strict'; +const fs = require('fs'); +const path = require('path'); +const mustache = require('mustache'); + const config = require('../config.json'); +const TemplatesDir = path.resolve(__dirname, '../../templates'); const generateString = () => { return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); @@ -46,9 +51,54 @@ const hasRole = (userRoles, requiredRoles) => { const zeroPad = (num, places) => String(num).padStart(places, '0'); +const fileExists = async (path) => { + return new Promise((resolve, reject) => { + try { + fs.exists(path, (exists) => { + resolve(exists); + }); + } catch (e) { + return reject(e); + } + }); +}; + +const fileRead = async (path) => { + return new Promise((resolve, reject) => { + try { + fs.readFile(path, 'utf-8', (err, data) => { + if (err) { + return reject(err); + } + resolve(data); + }); + } catch (e) { + return reject(e); + } + }); +}; + +const render = async (name, data) => { + try { + const filePath = path.resolve(TemplatesDir, name); + if (!await fileExists(filePath)) { + console.error('Template', filePath, 'does not exist!'); + return; + } + const templateData = await fileRead(filePath); + const result = mustache.render(templateData, data); + return result; + } catch (e) { + return reject(e); + } +}; + module.exports = { generateString, hasGuild, hasRole, - zeroPad + zeroPad, + fileExists, + fileRead, + render }; \ No newline at end of file diff --git a/src/views/header.mustache b/src/views/header.mustache index 73b83088..ea2c57f0 100644 --- a/src/views/header.mustache +++ b/src/views/header.mustache @@ -32,6 +32,7 @@ + {{#google_analytics_id}} {{/google_analytics_id}} diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 7b2832a2..1bb9a61c 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -3715,6 +3715,10 @@ function getDeviceMarker (device, ts) { } function getDevicePopupContent (device) { + //let data = Mustache.render('{{name}}', {name: "versx"}); + let data = getTemplateData('devices.mustache', device); + console.log('Data:', data); + return data; const lastSeenDate = new Date(device.last_seen * 1000); const lastSeen = lastSeenDate.toLocaleTimeString() + ' (' + getTimeSince(lastSeenDate) + ')'; const ts = Math.round((new Date()).getTime() / 1000); @@ -3776,6 +3780,32 @@ function setDespawnTimer (marker) { // TODO: rename to marker or something more } } +function getTemplateData(template, data) { + const { marker, ...dataWithoutMarker } = data; + let results = null; + $.ajax({ + url: '/api/get_template/' + template, + type: 'POST', + data: JSON.stringify({ + data: dataWithoutMarker, + _csrf: '{{csrf}}' + }), + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + async: false, + success: function (result) { + console.log('result:', result); + results = result; + }, + failure: function (err) { + console.error('Error:', err); + } + }); + return results; +} + // MARK: - Misc diff --git a/templates/devices.mustache b/templates/devices.mustache new file mode 100644 index 00000000..b1bb6132 --- /dev/null +++ b/templates/devices.mustache @@ -0,0 +1,7 @@ +
+
{{uuid}}
+
+
+Instance: {{instance_name}}
+Last Seen: {{last_seen}}
+Status: \ No newline at end of file From 0be71e9c757af9071c7d8f83fcbc25690daad7b0 Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 12:52:28 -0700 Subject: [PATCH 02/20] Use ejs instead of mustache --- package-lock.json | 44 ++++++++++++++++++++++++++++++++++++++ package.json | 1 + src/services/utils.js | 30 +++++++++++++++----------- templates/devices.mustache | 6 +++--- 4 files changed, 66 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index e21d039b..22cf72f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -508,6 +508,14 @@ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, + "ejs": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.5.tgz", + "integrity": "sha512-dldq3ZfFtgVTJMLjOe+/3sROTzALlL9E34V4/sDtUd/KlBSS0s6U1/+WPE1B4sj9CXHJpL1M6rhNJnc9Wbal9w==", + "requires": { + "jake": "^10.6.1" + } + }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -776,6 +784,14 @@ "flat-cache": "^2.0.1" } }, + "filelist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.1.tgz", + "integrity": "sha512-8zSK6Nu0DQIC08mUC46sWGXi+q3GGpKydAG36k+JDba6VRpkevvOWUW5a/PhShij4+vHT9M+ghgG7eM+a9JDUQ==", + "requires": { + "minimatch": "^3.0.4" + } + }, "finalhandler": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", @@ -1115,6 +1131,34 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, + "jake": { + "version": "10.8.2", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.2.tgz", + "integrity": "sha512-eLpKyrfG3mzvGE2Du8VoPbeSkRry093+tyNjdYaBbJS9v17knImYGNXQCUV0gLxQtF82m3E8iRb/wdSQZLoq7A==", + "requires": { + "async": "0.9.x", + "chalk": "^2.4.2", + "filelist": "^1.0.1", + "minimatch": "^3.0.4" + }, + "dependencies": { + "async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + } + } + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", diff --git a/package.json b/package.json index d789a487..4adf8b75 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "csurf": "^1.11.0", "discord-oauth2": "^2.2.0", "discord.js": "^12.2.0", + "ejs": "^3.1.5", "eslint": "^7.0.0", "express": "^4.17.1", "express-session": "^1.17.1", diff --git a/src/services/utils.js b/src/services/utils.js index 2b38fee8..d1583bd3 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -2,7 +2,7 @@ const fs = require('fs'); const path = require('path'); -const mustache = require('mustache'); +const ejs = require('ejs'); const config = require('../config.json'); const TemplatesDir = path.resolve(__dirname, '../../templates'); @@ -79,18 +79,24 @@ const fileRead = async (path) => { }; const render = async (name, data) => { - try { - const filePath = path.resolve(TemplatesDir, name); - if (!await fileExists(filePath)) { - console.error('Template', filePath, 'does not exist!'); - return; + return new Promise(async (resolve, reject) => { + try { + const filePath = path.resolve(TemplatesDir, name); + if (!await fileExists(filePath)) { + const errMsg = `Template ${filePath} does not exist!` + console.error(errMsg); + return reject(errMsg); + } + ejs.renderFile(filePath, data, (err, str) => { + if (err) { + return reject(err); + } + resolve(str); + }); + } catch (e) { + return reject(e); } - const templateData = await fileRead(filePath); - const result = mustache.render(templateData, data); - return result; - } catch (e) { - return reject(e); - } + }); }; module.exports = { diff --git a/templates/devices.mustache b/templates/devices.mustache index b1bb6132..7b98a3d9 100644 --- a/templates/devices.mustache +++ b/templates/devices.mustache @@ -1,7 +1,7 @@
-
{{uuid}}
+
<%= uuid %>

-Instance: {{instance_name}}
-Last Seen: {{last_seen}}
+Instance: <%= instance_name %>
+Last Seen: <%= last_seen %>
Status: \ No newline at end of file From 0dd179b189860e8901604039f94f24718d32c3be Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 15:08:00 -0700 Subject: [PATCH 03/20] Add template support for device and scanarea popups --- src/services/utils.js | 2 +- src/views/index-js.mustache | 12 ++++++++---- templates/device.ejs | 26 ++++++++++++++++++++++++++ templates/devices.mustache | 7 ------- templates/scanarea.ejs | 4 ++++ 5 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 templates/device.ejs delete mode 100644 templates/devices.mustache create mode 100644 templates/scanarea.ejs diff --git a/src/services/utils.js b/src/services/utils.js index d1583bd3..90be1c8f 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -81,7 +81,7 @@ const fileRead = async (path) => { const render = async (name, data) => { return new Promise(async (resolve, reject) => { try { - const filePath = path.resolve(TemplatesDir, name); + const filePath = path.resolve(TemplatesDir, name + '.ejs'); if (!await fileExists(filePath)) { const errMsg = `Template ${filePath} does not exist!` console.error(errMsg); diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 1bb9a61c..361f60a9 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -3074,6 +3074,9 @@ function getNestPopupContent(nest) { } function getScanAreaPopupContent(name, size) { + const templateData = getTemplateData('scanarea', { name, size }); + return templateData; + /* let content = `
Area: ${name}
@@ -3081,6 +3084,7 @@ function getScanAreaPopupContent(name, size) {
`; return content; + */ } @@ -3715,10 +3719,9 @@ function getDeviceMarker (device, ts) { } function getDevicePopupContent (device) { - //let data = Mustache.render('{{name}}', {name: "versx"}); - let data = getTemplateData('devices.mustache', device); - console.log('Data:', data); + let 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); @@ -3728,6 +3731,7 @@ function getDevicePopupContent (device) { 'Last Seen: ' + lastSeen + '
' + 'Status: ' + (isOffline ? 'Offline' : 'Online'); return content; + */ } function isDeviceOffline (device, ts) { @@ -3736,7 +3740,7 @@ function isDeviceOffline (device, ts) { return isOffline; } -function setDespawnTimer (marker) { // TODO: rename to marker or something more generic +function setDespawnTimer (marker) { let date = new Date(); const ts = date.getTime() / 1000; let raidTimestamp = 0; diff --git a/templates/device.ejs b/templates/device.ejs new file mode 100644 index 00000000..663dced7 --- /dev/null +++ b/templates/device.ejs @@ -0,0 +1,26 @@ +<% +function getTimeSince (date) { + const diff = Math.round((new Date() - date) / 1000); + const h = Math.floor(diff / 3600); + const m = Math.floor(diff % 3600 / 60); + const s = Math.floor(diff % 3600 % 60); + let str; + if (h > 0) { + str = h + 'h ' + m + 'm ' + s + 's'; + } else if (m > 0) { + str = m + 'm ' + s + 's'; + } else { + str = s + 's'; + } + return str; +} +%> + +
+
<%= uuid %>
+
+
+Instance: <%= instance_name %>
+<% let lastSeenDate = new Date(last_seen * 1000); %> +Last Seen: <%= lastSeenDate.toLocaleTimeString() + ' (' + getTimeSince(lastSeenDate) + ')'; %>
+Status: <%= last_seen > (Math.round(new Date().getTime() / 1000) - 15 * 60) ? 'Online' : 'Offline' %> \ No newline at end of file diff --git a/templates/devices.mustache b/templates/devices.mustache deleted file mode 100644 index 7b98a3d9..00000000 --- a/templates/devices.mustache +++ /dev/null @@ -1,7 +0,0 @@ -
-
<%= uuid %>
-
-
-Instance: <%= instance_name %>
-Last Seen: <%= last_seen %>
-Status: \ No newline at end of file diff --git a/templates/scanarea.ejs b/templates/scanarea.ejs new file mode 100644 index 00000000..3bb05a74 --- /dev/null +++ b/templates/scanarea.ejs @@ -0,0 +1,4 @@ +
+
Area: <%= name %>
+ Size: <%= size %> km2 +
\ No newline at end of file From 11cce47ab22ddd2982a87e55e854d21590a689a6 Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 15:12:20 -0700 Subject: [PATCH 04/20] Add template support for nest popups --- src/views/index-js.mustache | 12 ++++++++---- templates/nest.ejs | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 templates/nest.ejs diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 361f60a9..6faa7e72 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -3058,8 +3058,11 @@ function getWeatherPopupContent (weather) { } function getNestPopupContent(nest) { - const lastUpdated = new Date(nest.updated * 1000); - const pokemonName = getPokemonName(nest.pokemon_id); + nest.pokemon_name = getPokemonName(nest.pokemon_id); + nest.last_updated = new Date(nest.updated * 1000); + const templateData = getTemplateData('nest', nest); + return templateData; + /* let content = `
Park: ${nest.name}
@@ -3071,6 +3074,7 @@ function getNestPopupContent(nest) {
`; return content; + */ } function getScanAreaPopupContent(name, size) { @@ -3719,7 +3723,7 @@ function getDeviceMarker (device, ts) { } function getDevicePopupContent (device) { - let data = getTemplateData('device', device); + const data = getTemplateData('device', device); return data; /* const lastSeenDate = new Date(device.last_seen * 1000); @@ -3800,7 +3804,7 @@ function getTemplateData(template, data) { }, async: false, success: function (result) { - console.log('result:', result); + //console.log('result:', result); results = result; }, failure: function (err) { diff --git a/templates/nest.ejs b/templates/nest.ejs new file mode 100644 index 00000000..a1d58351 --- /dev/null +++ b/templates/nest.ejs @@ -0,0 +1,8 @@ +
+
Park: <%= name %>
+ Pokemon: <%= pokemon_name %>
+ Average: <%= pokemon_avg.toLocaleString() %>
+ Count: <%= pokemon_count.toLocaleString() %>
+
+ Last Updated: <%= last_updated.toLocaleString() %>
+
\ No newline at end of file From 68c469ffdcd72c2fd437dedb1beb90feb2511eee Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 15:17:38 -0700 Subject: [PATCH 05/20] Add template support for spawnpoint popups --- templates/spawnpoint.ejs | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 templates/spawnpoint.ejs diff --git a/templates/spawnpoint.ejs b/templates/spawnpoint.ejs new file mode 100644 index 00000000..72248ad9 --- /dev/null +++ b/templates/spawnpoint.ejs @@ -0,0 +1,4 @@ +
Spawnpoint
+<% if (despawn_second) { %> +
Despawn Timer: <%= Math.round(despawn_second / 60) %> minutes +<% } %> \ No newline at end of file From 8827ac173e0e64da9912564810fdf5874ec3277d Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 15:27:40 -0700 Subject: [PATCH 06/20] Add template support for weather popups --- src/views/index-js.mustache | 16 +++++++++++++--- templates/weather.ejs | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 templates/weather.ejs diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 6faa7e72..57b5ca6d 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -3029,9 +3029,14 @@ function degreesToCardinal (d) { } function getWeatherPopupContent (weather) { - const weatherName = weatherTypes[weather.gameplay_condition].name; - const weatherType = weatherTypes[weather.gameplay_condition].types; + weather.weather_name = weatherTypes[weather.gameplay_condition].name; + weather.weather_type = weatherTypes[weather.gameplay_condition].types; + weather.cardinal = degreesToCardinal(weather.wind_direction); + weather.time_since = getTimeSince(new Date(weather.updated * 1000)); + const templateData = getTemplateData('weather', weather); + return templateData; + /* let content = '
'; content += '
' + weatherName + '
'; content += 'Boosted Types:
' + weatherType + '
'; @@ -3055,6 +3060,7 @@ function getWeatherPopupContent (weather) { content += 'Last Updated: ' + updatedDate.toLocaleTimeString() + ' (' + getTimeSince(updatedDate) + ')'; content += '
'; return content; + */ } function getNestPopupContent(nest) { @@ -3604,19 +3610,23 @@ function getPokestopMarker (pokestop, ts) { } function getSpawnpointMarker (spawnpoint, ts) { + /* let content = '
Spawnpoint
'; const hasTimer = spawnpoint.despawn_second != null; if (hasTimer) { const timer = Math.round(spawnpoint.despawn_second / 60); content += '
Despawn Timer: ' + timer + ' minutes'; } + */ + const hasTimer = spawnpoint.despawn_second !== null; + const templateData = getTemplateData('spawnpoint', spawnpoint); const circle = L.circle([spawnpoint.lat, spawnpoint.lon], { color: hasTimer ? 'green' : 'red', fillColor: hasTimer ? 'green' : 'red', fillOpacity: 0.5, radius: 1.0 }); - circle.bindPopup(content); + circle.bindPopup(templateData); return circle; } diff --git a/templates/weather.ejs b/templates/weather.ejs new file mode 100644 index 00000000..0bb11a49 --- /dev/null +++ b/templates/weather.ejs @@ -0,0 +1,19 @@ +
+
<%= weather_name %>
+Boosted Types:
<%= weather_type %>
+Cell ID: <%= id %>
+Cell Level: <%= level %>
+Lat: <%= latitude.toFixed(5) %>
+Lon: <%= longitude.toFixed(5) %>
+Gameplay Condition: <%= gameplay_condition %>
+Wind Direction: <%= wind_direction %>° (<%= cardinal %>)
+Cloud Level: <%= cloud_level %>
+Rain Level: <%= rain_level %>
+Wind Level: <%= wind_level %>
+Snow Level: <%= snow_level %>
+Fog Level: <%= fog_level %>
+Special Effects Level: <%= special_effect_level %>
+Severity: <%= severity %>
+Weather Warning: <%= warn_weather %>

+Last Updated: <%= new Date(updated * 1000).toLocaleTimeString() %> (<%= time_since %>) +
\ No newline at end of file From 62d1035d3b33def78cd142ff6f363097dd8755e0 Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 15:33:19 -0700 Subject: [PATCH 07/20] Add template support for s2 scan cell popups --- src/views/index-js.mustache | 5 +++++ templates/cell.ejs | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 templates/cell.ejs diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 57b5ca6d..55275c04 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -2986,6 +2986,10 @@ function getGymPopupContent (gym) { } function getCellPopupContent (cell) { + cell.time_since = getTimeSince(new Date(cell.updated * 1000)); + const templateData = getTemplateData('cell', cell); + return templateData; + /* let content = '
'; content += '
Level ' + cell.level + ' S2 Cell
'; content += 'Id: ' + cell.id + '
'; @@ -2995,6 +2999,7 @@ function getCellPopupContent (cell) { content += 'Last Updated: ' + updatedDate.toLocaleTimeString() + ' (' + getTimeSince(updatedDate) + ')'; content += '
'; return content; + */ } function getSubmissionTypeCellPopupContent (cell) { diff --git a/templates/cell.ejs b/templates/cell.ejs new file mode 100644 index 00000000..8be74e6f --- /dev/null +++ b/templates/cell.ejs @@ -0,0 +1,5 @@ +
+
Level <%= level %> S2 Cell
+Id: <%= id %>
+Last Updated: <%= new Date(updated * 1000).toLocaleTimeString() %> (<%= time_since %>) +
\ No newline at end of file From d8f66479b2da0761c4210259767da4841bf07f29 Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 16:53:08 -0700 Subject: [PATCH 08/20] Add template support for pokestops --- src/routes/api.js | 1 + src/services/utils.js | 4 +- src/views/index-js.mustache | 47 ++++++++++++++++++++++- templates/pokestop.ejs | 75 +++++++++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 templates/pokestop.ejs diff --git a/src/routes/api.js b/src/routes/api.js index 127c01dc..69fa6665 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -29,6 +29,7 @@ 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); }); diff --git a/src/services/utils.js b/src/services/utils.js index 90be1c8f..19b39196 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -89,11 +89,13 @@ const render = async (name, data) => { } ejs.renderFile(filePath, data, (err, str) => { if (err) { - return reject(err); + console.error('Template render error:', err); + //return reject(err); } resolve(str); }); } catch (e) { + console.error('Template error:', e); return reject(e); } }); diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 55275c04..83168249 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -2668,7 +2668,7 @@ function addQuestFilter (pokemonId, itemId, show) { 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) { + if (rewardPokemonId === parseInt(pokemonId) && rewardItemId === parseInt(itemId)) { map.removeLayer(pokestop.marker); } }); @@ -2679,6 +2679,51 @@ function getPokestopPopupContent (pokestop) { const lureExpireDate = new Date(pokestop.lure_expire_timestamp * 1000); const invasionExpireDate = new Date(pokestop.incident_expire_timestamp * 1000); const isActiveLure = lureExpireDate >= now; + const isActiveInvasion = invasionExpireDate >= now; + const lastUpdatedDate = new Date(pokestop.updated * 1000); + + pokestop.is_lure_active = isActiveLure; + pokestop.is_invasion_active = isActiveInvasion; + pokestop.lure_time_since = getTimeUntill(lureExpireDate); + pokestop.invasion_time_since = getTimeUntill(invasionExpireDate); + pokestop.lure_expire_time = lureExpireDate.toLocaleTimeString(); + pokestop.invasion_expire_time = invasionExpireDate.toLocaleTimeString(); + pokestop.icon_path = availableIconStyles[selectedIconStyle]; + if (isActiveInvasion) { + pokestop.grunt_name = getGruntName(pokestop.grunt_type); + } + if (pokestop.quest_type !== null) { + let questRewards = []; + const conditions = pokestop.quest_conditions; + let conditionsString = ''; + if (conditions !== undefined && conditions.length > 0) { + conditionsString += ' ('; + $.each(conditions, function (index, condition) { + let formatting; + if (index === 0) { + formatting = ''; + } else { + formatting = ', '; + } + + conditionsString += formatting + getQuestCondition(condition); + }); + conditionsString += ')'; + } + + //content += 'Quest Condition: ' + getQuestName(pokestop.quest_type, pokestop.quest_target) + conditionsString + '
'; + pokestop.quest_name = getQuestName(pokestop.quest_type, pokestop.quest_target); + pokestop.quest_conditions_formatted = conditionsString; + $.each(pokestop.quest_rewards, function (index, reward) { + //content += 'Quest Reward: ' + getQuestReward(reward) + '
'; + questRewards.push(getQuestReward(reward)); + }); + pokestop.quest_rewards_formatted = questRewards; + } + pokestop.last_updated = lastUpdatedDate; + pokestop.time_since = getTimeUntill(lastUpdatedDate); + const templateData = getTemplateData('pokestop', pokestop); + return templateData; let content = '
'; if (pokestop.name === null || pokestop.name === '') { diff --git a/templates/pokestop.ejs b/templates/pokestop.ejs new file mode 100644 index 00000000..bb2c3028 --- /dev/null +++ b/templates/pokestop.ejs @@ -0,0 +1,75 @@ +
+ <% if (name) { %> +
<%= name %>
+ <% } else { %> +
Unknown Pokestop Name
+ <% } %> + + <% if (url) { + let lureClass = is_lure_active && lure_id !== 0 + ? (lure_id === 501 + ? 'lure-normal' + : lure_id === 502 + ? 'lure-glacial' + : lure_id === 503 + ? 'lure-mossy' + : lure_id === 504 + ? 'lure-magnetic' + : 'lure-normal') + : ''; + %> +

+ <% } %> + +
+
+ + <% if (is_lure_active) { %> + Lure Type: <%= lure_name %>
+ Lure End Time: <%= lure_expire_time %> (<%= lure_time_since %>)

+ <% } %> + + <% if (is_invasion_active) { %> + Team Rocket Invasion
+ Grunt Type: <%= grunt_name %>
+ End Time: <%= invasion_expire_time %> (<%= invasion_time_since %>)

+ <% } %> + + <% if (quest_type) { %> + Quest Condition: <%= quest_name %> <% if (quest_conditions_formatted) { %><%= quest_conditions_formatted %><% } %>
+ <% quest_rewards_formatted.forEach(function(reward) { %> + Quest Reward: <%= reward %>
+ <% }); %> +
+ <% } %> + + <% if (last_updated) { %> + Last Updated: <%= last_updated.toLocaleString() %> (<%= time_since %>)
+ <% } %> + +
+ <% if (quest_type) { %> + <% let questReward = quest_rewards ? quest_rewards[0] : {} %> +
[Exclude]
+ <% } %> + +
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
\ No newline at end of file From 031faa2c13384faf52d406447b3f5b7cb7c876f5 Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 17:53:58 -0700 Subject: [PATCH 09/20] Add template support for gym/raid popups --- src/views/index-js.mustache | 56 ++++++++++++++--- templates/gym.ejs | 117 ++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 7 deletions(-) create mode 100644 templates/gym.ejs diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 83168249..82c50edd 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -2831,14 +2831,9 @@ function getGymPopupContent (gym) { const isRaid = raidEndDate >= now && parseInt(gym.raid_level) > 0; const isRaidBattle = raidBattleDate <= now && isRaid; + const hasRaidBoss = gym.raid_pokemon_id > 0; - let gymName = ''; - if (gym.name === null || gym.name === '') { - gymName = 'Unknown Gym Name'; - } else { - gymName = gym.name; - } - + let gymName = gym.name ? gym.name : 'Unknown Gym Name'; let titleSize = 16;//'medium'; if (gymName.length > 40) { //titleSize = 'xx-small'; @@ -2851,6 +2846,53 @@ function getGymPopupContent (gym) { titleSize = 14; } + gym.gym_name = gymName; + gym.title_size = titleSize; + gym.is_raid = isRaid; + gym.is_raid_battle = isRaidBattle; + gym.available_slots = gym.availble_slots === 0 ? 'Full' : gym.availble_slots === 6 ? 'Empty' : gym.availble_slots; + gym.has_raid_boss = hasRaidBoss; + if (hasRaidBoss && isRaidBattle) { + let pokemonName = getPokemonName(gym.raid_pokemon_id); + if (gym.raid_pokemon_form > 0) { + const formName = getFormName(gym.raid_pokemon_form); + pokemonName = formName + ' ' + pokemonName; + gym.form_name = formName; + } + pokemonName += ' ' + getGenderIcon(gym.raid_pokemon_gender); + } else if (isRaidBattle) { + pokemonName = 'Unknown Raid Boss'; + } else { + pokemonName = 'Level ' + gym.raid_level + ' Egg'; + } + let pokemonTypes = []; + if (hasRaidBoss && isRaidBattle) { + const pkmn = masterfile.pokemon[gym.raid_pokemon_id]; + if (pkmn) { + const types = pkmn.types; + if (types && types.length > 0) { + if (types.length === 2) { + types.push(types[0].toLowerCase()); + types.push(types[1].toLowerCase()); + } else { + types.push(types[0].toLowerCase()); + } + } + } + } + gym.pokemon_types = pokemonTypes; + if (hasRaidBoss) { + gym.pokemon_icon = getPokemonIcon(gym.raid_pokemon_id, gym.raid_pokemon_form); + } + gym.pokemon_name = pokemonName; + gym.move_1_name = getMoveName(gym.raid_pokemon_move_1); + gym.move_2_name = getMoveName(gym.raid_pokemon_move_2); + gym.guarding_pokemon_name = getPokemonName(gym.guarding_pokemon_id); + gym.team_name = getTeamName(gym.team_id); + gym.icon_path = availableIconStyles[selectedIconStyle]; + const templateData = getTemplateData('gym', gym); + return templateData; + let content = '
' + // START 1ST ROW '
' + diff --git a/templates/gym.ejs b/templates/gym.ejs new file mode 100644 index 00000000..05938b02 --- /dev/null +++ b/templates/gym.ejs @@ -0,0 +1,117 @@ +
+
+ <%= gym_name %> +
+
+
+ +
+
+
+ +<% if (is_raid) { %> +
+
+
+ <% if (has_raid_boss && is_raid_battle) { %> + + <% } else { %> + + <% } %> +
+
+ <% if (has_raid_boss && is_raid_battle) { %> +
+ <% if (pokemon_types && pokemon_types.length > 0) { %> + <% pokemon_types.forEach(function(type) { %> +   + <% }); %> + <% } %> +
+ <% } %> +
+
+
+ <%= pokemon_name %>
+ <% if (has_raid_boss && is_raid_battle) { %> + <% if (raid_pokemon_cp) { %> + <% if (raid_is_exclusive) { %> + Level: EX
+ <% } else { %> + Level: <% raid_level %>
+ <% } %> + <% } %> + <% if (raid_pokemon_move_1) { %> + Fast: <%= move_1_name %>
+ <% } %> + <% if (raid_pokemon_move_2) { %> + Charge: <%= move_2_name %>
+ <% } %> + <% if (in_battle) { %> + Gym last seen in battle!
+ <% } %> + <% if (raid_pokemon_form > 0) { %> + Form: <%= form_name %>
+ <% } %> + <% } %> + <% if (ex_raid_eligible) { %> + + <% } %> +
+
+
+<% } else { %> +
+ <% if (url) { + let teamClass = team_id === 0 + ? 'team-neutral' + : team_id === 1 + ? 'team-mystic' + : team_id === 2 + ? 'team-valor' + : team_id === 3 + ? 'team-instinct' + : ''; + url.replace('http://', 'https://'); + %> +
+ +
+ <% } %> +
+ Team: <%= team_name %>
+ Slots Available: <%= available_slots %>
+ <% if (guarding_pokemon_id) { %> + Guard: <%= guarding_pokemon_name %>
+ <% } %> + <% if (total_cp) { %> + Total CP: <%= total_cp.toLocaleString() %>
+ <% } %> + <% if (in_battle) { %> + Gym is under attack!
+ <% } %> + <% if (ex_raid_eligible) { %> + + <% } %> +
+
+
+<% } %> +
+
+
+ + + +
+
+ + + +
+
+ + + +
+
\ No newline at end of file From 65d8080ef33b575536f9fbe63c6fb531cb5b3659 Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 20:18:43 -0700 Subject: [PATCH 10/20] Add template support for pokemon popups --- src/views/index-js.mustache | 61 +++++++++++++++++--- templates/gym.ejs | 2 +- templates/pokemon.ejs | 111 ++++++++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+), 10 deletions(-) create mode 100644 templates/pokemon.ejs diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 82c50edd..3d43ba52 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -2418,8 +2418,10 @@ function updateMapTimers () { function getPokemonPopupContent (pokemon) { const despawnDate = new Date(pokemon.expire_timestamp * 1000); + const firstSeenDate = new Date(pokemon.first_seen_timestamp * 1000); + const lastUpdatedDate = new Date(pokemon.updated * 1000); const hasIV = pokemon.atk_iv !== null; - let content = ''; + //let content = ''; let pokemonName; if (pokemon.form !== 0 && pokemon.form !== null) { @@ -2430,9 +2432,47 @@ function getPokemonPopupContent (pokemon) { if (pokemon.display_pokemon_id > 0) { pokemonName += ' (' + getPokemonNameNoId(pokemon.display_pokemon_id) + ')'; } - + pokemon.pokemon_name = pokemonName; const pokemonIcon = getPokemonIcon(pokemon.pokemon_id, pokemon.form) - + pokemon.pokemon_icon = pokemonIcon; + pokemon.icon_path = availableIconStyles[selectedIconStyle]; + 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()); + } + } + } + } + pokemon.pokemon_types = pokemonTypes; + pokemon.gender_icon = getGenderIcon(pokemon.gender); + pokemon.has_iv = hasIV; + if (pokemon.size > 0 && pokemon.weight > 0 && (pokemon.pokemon_id === 19 || pokemon.pokemon_id === 129)) { + const baseHeight = pokemon_id === 19 ? 0.300000011920929 : 0.89999998; + const baseWeight = pokemon_id === 19 ? 3.5 : 10; + const size = (size / baseHeight) + (pokemon.weight / baseWeight); + pokemon.size = getSize(size); + } + if (pokemon.move_1 > 0) { + pokemon.move_1_name = getMoveName(pokemon.move_1); + } + if (pokemon.move_2 > 0) { + pokemon.move_2_name = getMoveName(pokemon.move_2); + } + pokemon.enable_scouting = enableScouting; + pokemon.time_utill_despawn = getTimeUntill(despawnDate); + pokemon.time_since_first_seen = getTimeSince(firstSeenDate); + pokemon.time_since_updated = getTimeSince(lastUpdatedDate); + const templateData = getTemplateData('pokemon', pokemon); + return templateData; + /* content += '
' + // START 1ST ROW '
' + @@ -2615,6 +2655,7 @@ function getPokemonPopupContent (pokemon) { ) + '
'; return content; + */ } // eslint-disable-next-line no-unused-vars @@ -2721,7 +2762,7 @@ function getPokestopPopupContent (pokestop) { pokestop.quest_rewards_formatted = questRewards; } pokestop.last_updated = lastUpdatedDate; - pokestop.time_since = getTimeUntill(lastUpdatedDate); + pokestop.time_since = getTimeSince(lastUpdatedDate); const templateData = getTemplateData('pokestop', pokestop); return templateData; @@ -2852,8 +2893,9 @@ function getGymPopupContent (gym) { gym.is_raid_battle = isRaidBattle; gym.available_slots = gym.availble_slots === 0 ? 'Full' : gym.availble_slots === 6 ? 'Empty' : gym.availble_slots; gym.has_raid_boss = hasRaidBoss; + let pokemonName = ''; if (hasRaidBoss && isRaidBattle) { - let pokemonName = getPokemonName(gym.raid_pokemon_id); + pokemonName = getPokemonName(gym.raid_pokemon_id); if (gym.raid_pokemon_form > 0) { const formName = getFormName(gym.raid_pokemon_form); pokemonName = formName + ' ' + pokemonName; @@ -2872,10 +2914,10 @@ function getGymPopupContent (gym) { const types = pkmn.types; if (types && types.length > 0) { if (types.length === 2) { - types.push(types[0].toLowerCase()); - types.push(types[1].toLowerCase()); + pokemonTypes.push(types[0].toLowerCase()); + pokemonTypes.push(types[1].toLowerCase()); } else { - types.push(types[0].toLowerCase()); + pokemonTypes.push(types[0].toLowerCase()); } } } @@ -2892,7 +2934,7 @@ function getGymPopupContent (gym) { gym.icon_path = availableIconStyles[selectedIconStyle]; const templateData = getTemplateData('gym', gym); return templateData; - + /* let content = '
' + // START 1ST ROW '
' + @@ -3070,6 +3112,7 @@ function getGymPopupContent (gym) { '
' + '
'; return content; + */ } function getCellPopupContent (cell) { diff --git a/templates/gym.ejs b/templates/gym.ejs index 05938b02..b93fd714 100644 --- a/templates/gym.ejs +++ b/templates/gym.ejs @@ -38,7 +38,7 @@ <% if (raid_is_exclusive) { %> Level: EX
<% } else { %> - Level: <% raid_level %>
+ Level: <%= raid_level %>
<% } %> <% } %> <% if (raid_pokemon_move_1) { %> diff --git a/templates/pokemon.ejs b/templates/pokemon.ejs new file mode 100644 index 00000000..2691fbbf --- /dev/null +++ b/templates/pokemon.ejs @@ -0,0 +1,111 @@ +
+
+
<%= pokemon_name %> <%= gender_icon %>
+
+
+
+ <% if (!(display_pokemon_id > 0) && weather > 0) { %> + + <% } %> +
+
+
+ +
+
+
+ +
+
+ <% if (pokemon_types && pokemon_types.length > 0) { %> + <% pokemon_types.forEach(function(type) { %> +   + <% }); %> + <% } %> +
+
+
+ <% if (has_iv) { %> + <% const ivPercent = Math.round((atk_iv + def_iv + sta_iv) / 45 * 1000) / 10; %> + IV: <%= ivPercent %>% (A<%= atk_iv %>|D<%= def_iv %>|S<%= sta_iv%>)
+ <% } %> + <% if (cp) { %> + CP: <%= cp %> (Lvl. <%= level %>)
+ <% } %> + <% if (move_1) { %> + Fast: <%= move_1_name %>
+ <% } %> + <% if (move_2) { %> + Charge: <%= move_2_name %>
+ <% } %> + <% if (size > 0 && weight > 0 && (pokemon_id === 19 || pokemon_id === 129)) { %> + Size: <%= size %> | Weight: <%= Math.round(weight) %>kg
+ <% } else if (weight > 0) { %> + Weight: <%= Math.round(weight) %>kg
+ <% } %> + <% if (capture_1 && capture_2 && capture_3) { %> + Catch Chances:
+ <%= (capture_1 * 100).toFixed(1) %>% + <%= (capture_2 * 100).toFixed(1) %>%
+ <%= (capture_3 * 100).toFixed(1) %>%
+ <% } %> +
+
+
+
+
+ <% if (expire_timestamp_verified) { %> + Despawn Time: + <% } else { %> + Despawn Time: ~ + <% } %> + <%= new Date(expire_timestamp * 1000).toLocaleString() %> (<%= time_utill_despawn %>)
+
+
+ <% if (first_seen_timestamp > 0) { %> + <% const firstSeenDate = new Date(first_seen_timestamp * 1000); %> + First Seen: <%= firstSeenDate.toLocaleString() %> (<%= time_since_first_seen %>)
+ <% } %> +
+
+ <% if (updated > 0) { %> + <% const updatedDate = new Date(updated * 1000); %> + Latest Seen: <%= updatedDate.toLocaleString() %> (<%= time_since_updated %>)
+ <% } %> + + + +
+
+
+
+ [Hide]  + [Exclude] +
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ <% if (enable_scouting) { %> +
+ + <% } %> +
\ No newline at end of file From 8902afa88697cb4c7c286db1b3babe5b4d70a21c Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 20:40:30 -0700 Subject: [PATCH 11/20] Add pvp rankings to pokemon template --- src/views/index-js.mustache | 44 +++++++++++++++++++++++++++++++++++++ templates/pokemon.ejs | 17 +++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 3d43ba52..9c6d98bf 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -2470,6 +2470,50 @@ function getPokemonPopupContent (pokemon) { pokemon.time_utill_despawn = getTimeUntill(despawnDate); pokemon.time_since_first_seen = getTimeSince(firstSeenDate); pokemon.time_since_updated = getTimeSince(lastUpdatedDate); + + let greatLeagueRankings = []; + if (pokemon.pvp_rankings_ultra_league && pokemon.pvp_rankings_ultra_league.length > 0 && hasRelevantLeagueStats(pokemon.pvp_rankings_ultra_league, false)) { + $.each(pokemon.pvp_rankings_ultra_league, function (index, ranking) { + if (ranking.cp > 0 && ranking.cp >= 2400 && ranking.cp <= 2500 && ranking.rank <= 100) { + let pokemonName; + if (ranking.form !== 0) { + pokemonName = getFormName(ranking.form) + ' ' + getPokemonName(ranking.pokemon); + } else { + pokemonName = getPokemonName(ranking.pokemon); + } + greatLeagueRankings.push({ + pokemon_name: pokemonName, + rank: ranking.rank, + percent: Math.round(ranking.percentage * 1000) / 10, + cp: ranking.cp, + level: ranking.level + }); + } + }); + } + pokemon.great_league_rankings = greatLeagueRankings; + let ultraLeagueRankings = []; + if (pokemon.pvp_rankings_ultra_league && pokemon.pvp_rankings_ultra_league.length > 0 && hasRelevantLeagueStats(pokemon.pvp_rankings_ultra_league, false)) { + $.each(pokemon.pvp_rankings_ultra_league, function (index, ranking) { + if (ranking.cp > 0 && ranking.cp >= 2400 && ranking.cp <= 2500 && ranking.rank <= 100) { + let pokemonName; + if (ranking.form !== 0) { + pokemonName = getFormName(ranking.form) + ' ' + getPokemonName(ranking.pokemon); + } else { + pokemonName = getPokemonName(ranking.pokemon); + } + ultraLeagueRankings.push({ + pokemon_name: pokemonName, + rank: ranking.rank, + percent: Math.round(ranking.percentage * 1000) / 10, + cp: ranking.cp, + level: ranking.level + }); + } + }); + } + pokemon.ultra_league_rankings = ultraLeagueRankings; + const templateData = getTemplateData('pokemon', pokemon); return templateData; /* diff --git a/templates/pokemon.ejs b/templates/pokemon.ejs index 2691fbbf..b86ab68b 100644 --- a/templates/pokemon.ejs +++ b/templates/pokemon.ejs @@ -73,7 +73,22 @@ Latest Seen: <%= updatedDate.toLocaleString() %> (<%= time_since_updated %>)
<% } %> - + <% if (great_league_rankings && great_league_rankings.length > 0) { %> +
+ Great League:
+ <% for (let i = 0; i < great_league_rankings.length; i++) { %> + <% let ranking = great_league_rankings[i]; %> + <%= ranking.pokemon_name %>: #<%= ranking.rank %> (<%= ranking.percent %>%) @ <%= ranking.cp %> CP (Lvl. <%= ranking.level %>)
+ <% } %> + <% } %> + <% if (ultra_league_rankings && ultra_league_rankings.length > 0) { %> +
+ Ultra League:
+ <% for (let i = 0; i < ultra_league_rankings.length; i++) { %> + <% let ranking = ultra_league_rankings[i]; %> + <%= ranking.pokemon_name %>: #<%= ranking.rank %> (<%= ranking.percent %>%) @ <%= ranking.cp %> CP (Lvl. <%= ranking.level %>)
+ <% } %> + <% } %>
From 19bfd2fdcbab10d1b780dfcaafc9d30af64c6827 Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 20:51:53 -0700 Subject: [PATCH 12/20] Add template support for submission cell popups --- src/views/index-js.mustache | 4 ++++ templates/submission_cell.ejs | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 templates/submission_cell.ejs diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 9c6d98bf..77263b83 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -3177,6 +3177,9 @@ function getCellPopupContent (cell) { } function getSubmissionTypeCellPopupContent (cell) { + const templateData = getTemplateData('submission_cell', cell); + return templateData; + /* let content = '
'; content += '
Level ' + cell.level + ' S2 Cell
'; content += 'Id: ' + cell.id + '
'; @@ -3198,6 +3201,7 @@ function getSubmissionTypeCellPopupContent (cell) { content += '
'; return content; + */ } function degreesToCardinal (d) { diff --git a/templates/submission_cell.ejs b/templates/submission_cell.ejs new file mode 100644 index 00000000..0239cb20 --- /dev/null +++ b/templates/submission_cell.ejs @@ -0,0 +1,17 @@ +
+
Level <%= level %> S2 Cell
+Id: <%= id %>
+Total Count: <%= count %>
+Pokestop Count: <%= count_pokestops %>
+Gym Count: <%= count_gyms %>
+ +<% const gymThreshold = [2, 6, 20]; %> +<% if (count_gyms < 3) { %> + Submissions untill Gym: <%= gymThreshold[count_gyms] - count %> +<% } else { %> + Submissions untill Gym: Never +<% } %> +<% if ((count === 1 && count_gyms < 1) || (count === 5 && count_gyms < 2) || (count === 19 && count_gyms < 3)) { %> +
Next submission will cause a Gym! +<% } %> +
\ No newline at end of file From 2805c3aaa445b463514ee06db9f5e5281c3feb59 Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 20:55:06 -0700 Subject: [PATCH 13/20] Remove unused fileRead method --- src/services/utils.js | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/services/utils.js b/src/services/utils.js index 19b39196..e26b75d0 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -63,29 +63,12 @@ const fileExists = async (path) => { }); }; -const fileRead = async (path) => { - return new Promise((resolve, reject) => { - try { - fs.readFile(path, 'utf-8', (err, data) => { - if (err) { - return reject(err); - } - resolve(data); - }); - } catch (e) { - return reject(e); - } - }); -}; - const render = async (name, data) => { return new Promise(async (resolve, reject) => { try { const filePath = path.resolve(TemplatesDir, name + '.ejs'); if (!await fileExists(filePath)) { - const errMsg = `Template ${filePath} does not exist!` - console.error(errMsg); - return reject(errMsg); + return reject(`Template ${filePath} does not exist!`); } ejs.renderFile(filePath, data, (err, str) => { if (err) { @@ -107,6 +90,5 @@ module.exports = { hasRole, zeroPad, fileExists, - fileRead, render }; \ No newline at end of file From fe1480d31820d923ee7a61291f7e3d96f2531f15 Mon Sep 17 00:00:00 2001 From: versx Date: Fri, 21 Aug 2020 21:51:44 -0700 Subject: [PATCH 14/20] Small fixes --- src/routes/api.js | 1 - src/views/index-js.mustache | 120 +++++------------------------------- templates/gym.ejs | 28 +++++++-- templates/pokestop.ejs | 4 +- 4 files changed, 40 insertions(+), 113 deletions(-) diff --git a/src/routes/api.js b/src/routes/api.js index 69fa6665..127c01dc 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -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); }); diff --git a/src/views/index-js.mustache b/src/views/index-js.mustache index 77263b83..f3d872b8 100644 --- a/src/views/index-js.mustache +++ b/src/views/index-js.mustache @@ -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); @@ -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()); } } } @@ -2809,7 +2807,7 @@ function getPokestopPopupContent (pokestop) { pokestop.time_since = getTimeSince(lastUpdatedDate); const templateData = getTemplateData('pokestop', pokestop); return templateData; - + /* let content = '
'; if (pokestop.name === null || pokestop.name === '') { content += '
Unknown Pokestop Name
'; @@ -2907,12 +2905,15 @@ function getPokestopPopupContent (pokestop) { '
' + '
'; 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; @@ -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; /* @@ -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 = '
'; - content += '
Level ' + cell.level + ' S2 Cell
'; - content += 'Id: ' + cell.id + '
'; - - const updatedDate = new Date(cell.updated * 1000); - - content += 'Last Updated: ' + updatedDate.toLocaleTimeString() + ' (' + getTimeSince(updatedDate) + ')'; - content += '
'; - return content; - */ } function getSubmissionTypeCellPopupContent (cell) { const templateData = getTemplateData('submission_cell', cell); return templateData; - /* - let content = '
'; - content += '
Level ' + cell.level + ' S2 Cell
'; - content += 'Id: ' + cell.id + '
'; - content += 'Total Count: ' + cell.count + '
'; - content += 'Pokestop Count: ' + cell.count_pokestops + '
'; - content += 'Gym Count: ' + cell.count_gyms + '
'; - - const gymThreshold = [2, 6, 20]; - - if (cell.count_gyms < 3) { - content += 'Submissions untill Gym: ' + (gymThreshold[cell.count_gyms] - cell.count); - } else { - content += 'Submissions untill Gym: Never'; - } - - if ((cell.count === 1 && cell.count_gyms < 1) || (cell.count === 5 && cell.count_gyms < 2) || (cell.count === 19 && cell.count_gyms < 3)) { - content += '
Next submission will cause a Gym!'; - } - - content += '
'; - return content; - */ } function degreesToCardinal (d) { @@ -3218,32 +3189,6 @@ function getWeatherPopupContent (weather) { weather.time_since = getTimeSince(new Date(weather.updated * 1000)); const templateData = getTemplateData('weather', weather); return templateData; - - /* - let content = '
'; - content += '
' + weatherName + '
'; - content += 'Boosted Types:
' + weatherType + '
'; - content += 'Cell ID: ' + weather.id + '
'; - content += 'Cell Level: ' + weather.level + '
'; - content += 'Lat: ' + weather.latitude + '
'; - content += 'Lon: ' + weather.longitude + '
'; - content += 'Gameplay Condition: ' + weather.gameplay_condition + '
'; - content += 'Wind Direction: ' + weather.wind_direction + '° (' + degreesToCardinal(weather.wind_direction) + ')
'; - content += 'Cloud Level: ' + weather.cloud_level + '
'; - content += 'Rain Level: ' + weather.rain_level + '
'; - content += 'Wind Level: ' + weather.wind_level + '
'; - content += 'Snow Level: ' + weather.snow_level + '
'; - content += 'Fog Level: ' + weather.fog_level + '
'; - content += 'Special Effects Level: ' + weather.special_effect_level + '
'; - content += 'Severity: ' + weather.severity + '
'; - content += 'Weather Warning: ' + weather.warn_weather + '

'; - - const updatedDate = new Date(weather.updated * 1000); - - content += 'Last Updated: ' + updatedDate.toLocaleTimeString() + ' (' + getTimeSince(updatedDate) + ')'; - content += '
'; - return content; - */ } function getNestPopupContent(nest) { @@ -3251,33 +3196,11 @@ function getNestPopupContent(nest) { nest.last_updated = new Date(nest.updated * 1000); const templateData = getTemplateData('nest', nest); return templateData; - /* - let content = ` -
-
Park: ${nest.name}
- Pokemon: ${pokemonName}
- Average: ${nest.pokemon_avg.toLocaleString()}
- Count: ${nest.pokemon_count.toLocaleString()}
-
- Last Updated: ${lastUpdated.toLocaleString()}
-
- `; - return content; - */ } function getScanAreaPopupContent(name, size) { const templateData = getTemplateData('scanarea', { name, size }); return templateData; - /* - let content = ` -
-
Area: ${name}
- Size: ${size} km2 -
- `; - return content; - */ } @@ -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 = '
' + device.uuid + '

' + - 'Instance: ' + device.instance_name + '
' + - 'Last Seen: ' + lastSeen + '
' + - 'Status: ' + (isOffline ? 'Offline' : 'Online'); - return content; - */ } function isDeviceOffline (device, ts) { diff --git a/templates/gym.ejs b/templates/gym.ejs index b93fd714..56d54654 100644 --- a/templates/gym.ejs +++ b/templates/gym.ejs @@ -21,13 +21,13 @@
<% if (has_raid_boss && is_raid_battle) { %> -
<% if (pokemon_types && pokemon_types.length > 0) { %> +
<% pokemon_types.forEach(function(type) { %>   <% }); %> +
<% } %> -
<% } %> @@ -81,22 +81,38 @@
Team: <%= team_name %>
Slots Available: <%= available_slots %>
- <% if (guarding_pokemon_id) { %> + <% if (guarding_pokemon_id > 0) { %> Guard: <%= guarding_pokemon_name %>
<% } %> - <% if (total_cp) { %> + <% if (total_cp > 0) { %> Total CP: <%= total_cp.toLocaleString() %>
<% } %> - <% if (in_battle) { %> + <% if (in_battle > 0) { %> Gym is under attack!
<% } %> - <% if (ex_raid_eligible) { %> + <% if (ex_raid_eligible > 0) { %> <% } %>

<% } %> + +
+ <% if (is_raid && !is_raid_battle) { %> + Raid Start: <%= new Date(raid_battle_timestamp * 1000).toLocaleString() %> (<%= time_until_battle %>)
+ <% } %> + <% if (is_raid) { %> + Raid End: <%= new Date(raid_end_timestamp * 1000).toLocaleString() %> (<%= time_until_end %>)

+ <% } %> +
+ <% if (updated) { %> %> + Last Updated: <%= new Date(updated * 1000).toLocaleString() %> (<%= time_since_updated %>)
+ <% } %> + <% if (last_modified_timestamp) { %> + Last Modified: <%= new Date(last_modified_timestamp * 1000).toLocaleString() %> (<%= time_since_modified %>)
+ <% } %> +
diff --git a/templates/pokestop.ejs b/templates/pokestop.ejs index bb2c3028..58ea3915 100644 --- a/templates/pokestop.ejs +++ b/templates/pokestop.ejs @@ -43,8 +43,8 @@
<% } %> - <% if (last_updated) { %> - Last Updated: <%= last_updated.toLocaleString() %> (<%= time_since %>)
+ <% if (updated) { %> + Last Updated: <%= new Date(updated * 1000).toLocaleString() %> (<%= time_since %>)
<% } %>
From a6e069638ba006f758d0af2c1e165430779e6a89 Mon Sep 17 00:00:00 2001 From: versx Date: Thu, 17 Sep 2020 10:35:53 -0700 Subject: [PATCH 15/20] Rename example templates. Add gitignore for templates folder. --- .gitignore | 4 ++++ templates/{cell.ejs => cell.example.ejs} | 0 templates/{device.ejs => device.example.ejs} | 0 templates/{gym.ejs => gym.example.ejs} | 0 templates/{nest.ejs => nest.example.ejs} | 0 templates/{pokemon.ejs => pokemon.example.ejs} | 0 templates/{pokestop.ejs => pokestop.example.ejs} | 0 templates/{scanarea.ejs => scanarea.example.ejs} | 0 templates/{spawnpoint.ejs => spawnpoint.example.ejs} | 0 .../{submission_cell.ejs => submission_cell.example.ejs} | 0 templates/{weather.ejs => weather.example.ejs} | 0 11 files changed, 4 insertions(+) rename templates/{cell.ejs => cell.example.ejs} (100%) rename templates/{device.ejs => device.example.ejs} (100%) rename templates/{gym.ejs => gym.example.ejs} (100%) rename templates/{nest.ejs => nest.example.ejs} (100%) rename templates/{pokemon.ejs => pokemon.example.ejs} (100%) rename templates/{pokestop.ejs => pokestop.example.ejs} (100%) rename templates/{scanarea.ejs => scanarea.example.ejs} (100%) rename templates/{spawnpoint.ejs => spawnpoint.example.ejs} (100%) rename templates/{submission_cell.ejs => submission_cell.example.ejs} (100%) rename templates/{weather.ejs => weather.example.ejs} (100%) diff --git a/.gitignore b/.gitignore index 65ca5ca2..e9d09524 100644 --- a/.gitignore +++ b/.gitignore @@ -125,3 +125,7 @@ static/locales/* # No docker-compose.yml files docker-compose.yml + +# Only keep example templates +/templates/* +!/templates/*.example.ejs \ No newline at end of file diff --git a/templates/cell.ejs b/templates/cell.example.ejs similarity index 100% rename from templates/cell.ejs rename to templates/cell.example.ejs diff --git a/templates/device.ejs b/templates/device.example.ejs similarity index 100% rename from templates/device.ejs rename to templates/device.example.ejs diff --git a/templates/gym.ejs b/templates/gym.example.ejs similarity index 100% rename from templates/gym.ejs rename to templates/gym.example.ejs diff --git a/templates/nest.ejs b/templates/nest.example.ejs similarity index 100% rename from templates/nest.ejs rename to templates/nest.example.ejs diff --git a/templates/pokemon.ejs b/templates/pokemon.example.ejs similarity index 100% rename from templates/pokemon.ejs rename to templates/pokemon.example.ejs diff --git a/templates/pokestop.ejs b/templates/pokestop.example.ejs similarity index 100% rename from templates/pokestop.ejs rename to templates/pokestop.example.ejs diff --git a/templates/scanarea.ejs b/templates/scanarea.example.ejs similarity index 100% rename from templates/scanarea.ejs rename to templates/scanarea.example.ejs diff --git a/templates/spawnpoint.ejs b/templates/spawnpoint.example.ejs similarity index 100% rename from templates/spawnpoint.ejs rename to templates/spawnpoint.example.ejs diff --git a/templates/submission_cell.ejs b/templates/submission_cell.example.ejs similarity index 100% rename from templates/submission_cell.ejs rename to templates/submission_cell.example.ejs diff --git a/templates/weather.ejs b/templates/weather.example.ejs similarity index 100% rename from templates/weather.ejs rename to templates/weather.example.ejs From d0ef8576d2e8d46eb1791b6a5c73583b3678c087 Mon Sep 17 00:00:00 2001 From: versx Date: Thu, 17 Sep 2020 10:38:46 -0700 Subject: [PATCH 16/20] Lint --- src/services/utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/utils.js b/src/services/utils.js index ab9fcfc8..eda175ac 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -64,12 +64,12 @@ const fileExists = async (path) => { }; const render = async (name, data) => { - return new Promise(async (resolve, reject) => { + const filePath = path.resolve(TemplatesDir, name + '.ejs'); + if (!await fileExists(filePath)) { + throw `Template ${filePath} does not exist!`; + } + return new Promise((resolve, reject) => { try { - const filePath = path.resolve(TemplatesDir, name + '.ejs'); - if (!await fileExists(filePath)) { - return reject(`Template ${filePath} does not exist!`); - } ejs.renderFile(filePath, data, (err, str) => { if (err) { console.error('Template render error:', err); From c58c1f26178d7a77e5059c7df3a9c3b6e33733c9 Mon Sep 17 00:00:00 2001 From: versx Date: Thu, 17 Sep 2020 11:13:20 -0700 Subject: [PATCH 17/20] Remove spawnpoints, s2 cells, and s2 submission cells from templates. Small fixes. --- package-lock.json | 2 +- static/js/index.js | 61 ++++++++++++++++++++++++++--------- templates/pokemon.example.ejs | 2 +- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 95f8d80a..fdb03ee2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1641,7 +1641,7 @@ "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, "pogo-translations": { - "version": "git+https://github.com/bschultz/pogo-translations.git#96d3303807b34601698319d8225c89b84de90ee4", + "version": "git+https://github.com/bschultz/pogo-translations.git#05e79555999871e4e7439c689b28fdc12e577a32", "from": "git+https://github.com/bschultz/pogo-translations.git" }, "prelude-ls": { diff --git a/static/js/index.js b/static/js/index.js index 8b4ab1f4..92e9380e 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -2608,9 +2608,10 @@ function getPokemonPopupContent (pokemon) { pokemonName += ' (' + getPokemonNameNoId(pokemon.display_pokemon_id) + ')'; } pokemon.pokemon_name = pokemonName; - const pokemonIcon = getPokemonIcon(pokemon.pokemon_id, pokemon.form) - pokemon.pokemon_icon = pokemonIcon; - pokemon.icon_path = availableIconStyles[selectedIconStyle]; + // TODO: add evolution https://github.com/versx/DataParser/issues/9 + const pokemonIcon = getPokemonIcon(pokemon.pokemon_id, pokemon.form, 0, pokemon.gender, pokemon.costume); + pokemon.pokemon_icon = `${availableIconStyles[selectedIconStyle].path}/${pokemonIcon}.png`; + pokemon.icon_path = '/img'; const pkmn = masterfile.pokemon[pokemon.pokemon_id]; let pokemonTypes = []; if (pkmn && pkmn.types && pkmn.types.length > 0) { @@ -2644,9 +2645,6 @@ function getPokemonPopupContent (pokemon) { pokemon.time_since_first_seen = getTimeSince(firstSeenDate); pokemon.time_since_updated = getTimeSince(lastUpdatedDate); - // TODO: add evolution https://github.com/versx/DataParser/issues/9 - const pokemonIcon = getPokemonIcon(pokemon.pokemon_id, pokemon.form, 0, pokemon.gender, pokemon.costume); - let greatLeagueRankings = []; if (pokemon.pvp_rankings_ultra_league && pokemon.pvp_rankings_ultra_league.length > 0 && hasRelevantLeagueStats(pokemon.pvp_rankings_ultra_league, false)) { $.each(pokemon.pvp_rankings_ultra_league, function (index, ranking) { @@ -2949,7 +2947,7 @@ function getPokestopPopupContent (pokestop) { pokestop.invasion_time_since = getTimeUntill(invasionExpireDate); pokestop.lure_expire_time = lureExpireDate.toLocaleTimeString(); pokestop.invasion_expire_time = invasionExpireDate.toLocaleTimeString(); - pokestop.icon_path = availableIconStyles[selectedIconStyle]; + pokestop.icon_path = '/img'; if (isActiveInvasion) { pokestop.grunt_name = getGruntName(pokestop.grunt_type); } @@ -3197,7 +3195,7 @@ function getGymPopupContent (gym) { gym.move_2_name = getMoveName(gym.raid_pokemon_move_2); gym.guarding_pokemon_name = getPokemonName(gym.guarding_pokemon_id); gym.team_name = getTeamName(gym.team_id); - gym.icon_path = availableIconStyles[selectedIconStyle]; + gym.icon_path = '/img'; gym.time_until_battle = getTimeUntill(raidBattleDate); gym.time_until_end = getTimeUntill(raidEndDate); gym.time_since_updated = getTimeSince(updatedDate); @@ -3395,14 +3393,45 @@ function getGymPopupContent (gym) { } function getCellPopupContent (cell) { - cell.time_since = getTimeSince(new Date(cell.updated * 1000)); - const templateData = getTemplateData('cell', cell); - return templateData; + //cell.time_since = getTimeSince(new Date(cell.updated * 1000)); + //const templateData = getTemplateData('cell', cell); + //return templateData; + const content = ` +
+
Level ${cell.level} S2 Cell
+ Id: ${cell.id}
+ Last Updated: ${new Date(cell.updated * 1000).toLocaleTimeString()} (${getTimeSince(new Date(cell.updated * 1000))}) +
+ `; + return content; } function getSubmissionTypeCellPopupContent (cell) { - const templateData = getTemplateData('submission_cell', cell); - return templateData; + //const templateData = getTemplateData('submission_cell', cell); + //return templateData; + const gymThreshold = [2, 6, 20]; + let content = ` +
+
Level ${cell.level} S2 Cell
+ Id: ${cell.id}
+ Total Count: ${cell.count}
+ Pokestop Count: ${cell.count_pokestops}
+ Gym Count: ${cell.count_gyms}
+ `; + if (cell.count_gyms < 3) { + content += `Submissions untill Gym: ${gymThreshold[cell.count_gyms] - cell.count}`; + } else { + content += 'Submissions untill Gym: Never'; + } + if ((cell.count === 1 && cell.count_gyms < 1) || + (cell.count === 5 && cell.count_gyms < 2) || + (cell.count === 19 && cell.count_gyms < 3)) { + content += '
Next submission will cause a Gym!'; + } + content += ` +
+ `; + return content; } function degreesToCardinal (d) { @@ -3991,23 +4020,23 @@ function getPokestopMarker (pokestop, ts) { } function getSpawnpointMarker (spawnpoint, ts) { - /* let content = '
Spawnpoint
'; const hasTimer = spawnpoint.despawn_second != null; if (hasTimer) { const timer = Math.round(spawnpoint.despawn_second / 60); content += '
Despawn Timer: ' + timer + ' minutes'; } - */ + /* const hasTimer = spawnpoint.despawn_second !== null; const templateData = getTemplateData('spawnpoint', spawnpoint); + */ const circle = L.circle([spawnpoint.lat, spawnpoint.lon], { color: hasTimer ? 'green' : 'red', fillColor: hasTimer ? 'green' : 'red', fillOpacity: 0.5, radius: 1.0 }); - circle.bindPopup(templateData); + circle.bindPopup(content); return circle; } diff --git a/templates/pokemon.example.ejs b/templates/pokemon.example.ejs index b86ab68b..fe1a98e0 100644 --- a/templates/pokemon.example.ejs +++ b/templates/pokemon.example.ejs @@ -14,7 +14,7 @@
- +
<% if (pokemon_types && pokemon_types.length > 0) { %> From 7329c3d3f5ebe7281cd12f08abbe07e63bee5299 Mon Sep 17 00:00:00 2001 From: versx Date: Thu, 17 Sep 2020 15:18:34 -0700 Subject: [PATCH 18/20] Fix pokemon popup columns on smaller screens --- templates/pokemon.example.ejs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/pokemon.example.ejs b/templates/pokemon.example.ejs index fe1a98e0..6421be20 100644 --- a/templates/pokemon.example.ejs +++ b/templates/pokemon.example.ejs @@ -12,7 +12,7 @@
-
+
@@ -24,7 +24,7 @@ <% } %>
-
+
<% if (has_iv) { %> <% const ivPercent = Math.round((atk_iv + def_iv + sta_iv) / 45 * 1000) / 10; %> IV: <%= ivPercent %>% (A<%= atk_iv %>|D<%= def_iv %>|S<%= sta_iv%>)
From 0de08bc6c9e84d3200719bb08163e8c0c7502547 Mon Sep 17 00:00:00 2001 From: versx Date: Thu, 17 Sep 2020 15:32:09 -0700 Subject: [PATCH 19/20] Fix gym popup columns on smaller screens and raid image --- static/js/index.js | 2 +- templates/gym.example.ejs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 92e9380e..a320df1f 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -3188,7 +3188,7 @@ function getGymPopupContent (gym) { } gym.pokemon_types = pokemonTypes; if (hasRaidBoss) { - gym.pokemon_icon = getPokemonIcon(gym.raid_pokemon_id, gym.raid_pokemon_form); + gym.pokemon_icon = `${availableIconStyles[selectedIconStyle].path}/${getPokemonIcon(gym.raid_pokemon_id, gym.raid_pokemon_form)}.png`; } gym.pokemon_name = pokemonName; gym.move_1_name = getMoveName(gym.raid_pokemon_move_1); diff --git a/templates/gym.example.ejs b/templates/gym.example.ejs index 56d54654..b49031c2 100644 --- a/templates/gym.example.ejs +++ b/templates/gym.example.ejs @@ -1,8 +1,8 @@
-
+
<%= gym_name %>
-
+
@@ -10,11 +10,11 @@
<% if (is_raid) { %> -
-
+
+
<% if (has_raid_boss && is_raid_battle) { %> - + <% } else { %> <% } %> @@ -31,7 +31,7 @@ <% } %>
-
+
<%= pokemon_name %>
<% if (has_raid_boss && is_raid_battle) { %> <% if (raid_pokemon_cp) { %> @@ -74,11 +74,11 @@ : ''; url.replace('http://', 'https://'); %> -
+
<% } %> -
+
Team: <%= team_name %>
Slots Available: <%= available_slots %>
<% if (guarding_pokemon_id > 0) { %> From 280496e88be24700a13efe1beec00d8b038f3ed8 Mon Sep 17 00:00:00 2001 From: versx Date: Thu, 17 Sep 2020 15:33:34 -0700 Subject: [PATCH 20/20] Fix raid popup image to include gender and costume --- static/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/index.js b/static/js/index.js index a320df1f..d69cf138 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -3188,7 +3188,7 @@ function getGymPopupContent (gym) { } gym.pokemon_types = pokemonTypes; if (hasRaidBoss) { - gym.pokemon_icon = `${availableIconStyles[selectedIconStyle].path}/${getPokemonIcon(gym.raid_pokemon_id, gym.raid_pokemon_form)}.png`; + gym.pokemon_icon = `${availableIconStyles[selectedIconStyle].path}/${getPokemonIcon(gym.raid_pokemon_id, gym.raid_pokemon_form, gym.raid_pokemon_evolution, gym.raid_pokemon_gender, gym.raid_pokemon_costume)}.png`; } gym.pokemon_name = pokemonName; gym.move_1_name = getMoveName(gym.raid_pokemon_move_1);