Merge pull request #45 from tylermatchett/dynamic-querystring

Readable dynamic length querystrings
master
Mike Bryant 5 years ago committed by GitHub
commit d048472a7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -128,10 +128,19 @@ const getPricesFromQuery = function () {
const params = new URLSearchParams(window.location.search.substr(1));
const sell_prices = params.get("prices").split(".").map((x) => parseInt(x, 10));
if (!Array.isArray(sell_prices) || sell_prices.length !== 14) {
if (!Array.isArray(sell_prices)) {
return null;
}
// Parse the array which is formatted like: [price, M-AM, M-PM, T-AM, T-PM, W-AM, W-PM, Th-AM, Th-PM, F-AM, F-PM, S-AM, S-PM, Su-AM, Su-PM]
// due to the format of local storage we need to double up the price at the start of the array.
sell_prices.unshift(sell_prices[0]);
// This allows us to fill out the missing fields at the end of the array
for (let i = sell_prices.length; i < 14; i++) {
sell_prices.push(0);
}
window.price_from_query = true;
return sell_prices;
} catch (e) {

Loading…
Cancel
Save