wowtoken.app

git clone https://git.emily.sh/wowtoken-app/wowtoken.app.git
Log | Files | Refs | README | LICENSE

commit 4c7ac49dddc5de1662efdf6b2278daf1275ecc94
parent a2adff73c7668ef22ef0502320ee9589135db79b
Author: Emily Doherty <emily@emilyd.xyz>
Date:   Sat,  3 Jul 2021 00:24:26 -0400

Added time and region query detection

Diffstat:
Msrc/index.js | 28++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/index.js b/src/index.js @@ -125,11 +125,35 @@ function formatToken() { $("#token").html(current_price_hash[current_region_selection].toLocaleString()); } +function detectURLQuery() { + const urlSearchParams = new URLSearchParams(window.location.search) + const allowedRegions = ['us', 'eu', 'tw', 'kr'] + if (urlSearchParams.has('region')) { + if (allowedRegions.includes(urlSearchParams.get('region').toLowerCase())) { + current_region_selection = urlSearchParams.get('region').toLowerCase() + } else { + console.log("An incorrect or malformed region selection was made in the query string") + } + } + // In the future, we will allow all the times to be selected, + // once I come up with a good reduction algorithm. + // For larger time selections, it's currently hardcoded into the backend + const allowedTimes = ['72h', '167h', '336h', '30d', '90d', '6m', 'all'] + if (urlSearchParams.has('time')) { + if (allowedTimes.includes(urlSearchParams.get('time').toLowerCase())) { + current_time_selection = urlSearchParams.get('time').toLowerCase() + } else { + console.log("An incorrect or malformed time selection was made in the query string") + } + } +} + $(document).ready(function() { - callUpdateURL() + detectURLQuery(); + callUpdateURL(); setInterval(callUpdateURL, 60*1000); pullChartData().then(populateChart); - setInterval(updateChartData, 15*60*1000) + setInterval(updateChartData, 15*60*1000); });