Removed UI notification when query is used.

A console log shows instead.

Cleaned up getPreviousFromQuery.
It now returns null when the "prices" parameter is not used.

Fixed getPreviousFromLocalStorage to only look at local storage.

Changed from_query to populated_from_query to be more descriptive.
master
Blake Felt 4 years ago
parent a62a86235c
commit a893a5617b

@ -273,13 +273,6 @@
<p>This app is still in development, but will improve over time!</p>
</div>
<div class="dialog-box" id="from_query" style="visibility: hidden;">
<h2 class="dialog-box__name">Daisy Mae</h2>
<p>I see you are have entered some parameters.
I will not save any changes for now.
</p>
</div>
<div class="dialog-box">
<h2 class="dialog-box__name">Daisy Mae</h2>
<p>

@ -200,33 +200,26 @@ const getPricesFromQuery = function (param) {
};
const getPreviousFromQuery = function () {
const queries = [
["first", getFirstBuyStateFromQuery],
["pattern", getPreviousPatternStateFromQuery],
["prices", getPricesFromQuery]
];
found = null; /* value to save if we found any parameters */
ret = [];
for (q of queries) {
val = q[1](q[0]); /* run the function with the parameter */
found = found || val;
ret.push(val);
/* Check if valid prices are entered. Exit immediately if not. */
prices = getPricesFromQuery("prices");
if (prices == null) {
return null;
}
if (found != null) { /* if we found any parameter */
window.from_query = true;
document.getElementById("from_query").style.visibility = "visible";
return ret;
}
return null;
console.log("Using data from query.");
window.populated_from_query = true;
return [
getFirstBuyStateFromQuery("first"),
getPreviousPatternStateFromQuery("pattern"),
prices
];
};
const getPreviousFromLocalstorage = function () {
return [
getFirstBuyStateFromLocalstorage(),
getPreviousPatternStateFromQuery(),
getPreviousPatternStateFromLocalstorage(),
getPricesFromLocalstorage()
];
};
@ -282,7 +275,7 @@ const update = function () {
const prices = [buy_price, buy_price, ...sell_prices];
if (!window.from_query) {
if (!window.populated_from_query) {
updateLocalStorage(prices, first_buy, previous_pattern);
}

Loading…
Cancel
Save