@ -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 ( ) ,
getPreviousPatternStateFrom Query ( ) ,
getPreviousPatternStateFrom Localstorage ( ) ,
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 ) ;
}