-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from jalibu/refactoring
Refactoring
- Loading branch information
Showing
9 changed files
with
376 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
class JastUtils { | ||
static getCurrentValue(stock, exchangeData) { | ||
let currentValue = "-"; | ||
if (stock.current) { | ||
currentValue = stock.current; | ||
if ( | ||
exchangeData && | ||
stock.tradeCurrency && | ||
stock.displayCurrency && | ||
stock.tradeCurrency !== stock.displayCurrency | ||
) { | ||
const exchange = exchangeData.find( | ||
(exchange) => | ||
exchange.from === stock.tradeCurrency && | ||
exchange.to === stock.displayCurrency | ||
); | ||
if (exchange) { | ||
currentValue = currentValue * exchange.rate; | ||
} | ||
} | ||
currentValue = currentValue.toFixed(2); | ||
} | ||
return currentValue; | ||
} | ||
|
||
static getCurrency(stock, exchangeData, config) { | ||
let currency = config.defaultCurrency; | ||
if (stock.displayCurrency) { | ||
const exchange = exchangeData.find( | ||
(exchange) => | ||
exchange.from === stock.tradeCurrency && | ||
exchange.to === stock.displayCurrency | ||
); | ||
if (exchange) { | ||
currency = stock.displayCurrency; | ||
} else if (stock.tradeCurrency) { | ||
currency = stock.tradeCurrency; | ||
} | ||
} | ||
return currency; | ||
} | ||
|
||
static getStockChange(stock) { | ||
if (stock.current && stock.last) { | ||
return (((stock.current - stock.last) / stock.last) * 100).toFixed(1); | ||
} else { | ||
return 0; | ||
} | ||
} | ||
|
||
static getDepotGrowth(config, exchangeData) { | ||
let growth = 0; | ||
let errors = false; | ||
config.stocks.forEach((stock) => { | ||
if (stock.current && stock.last) { | ||
let change = | ||
stock.current * stock.quantity - stock.last * stock.quantity; | ||
|
||
if ( | ||
stock.tradeCurrency && | ||
stock.tradeCurrency !== config.defaultCurrency | ||
) { | ||
const exchange = exchangeData.find( | ||
(exchange) => | ||
exchange.from === stock.tradeCurrency && | ||
exchange.to === stock.displayCurrency | ||
); | ||
if (exchange) { | ||
change = change * exchange.rate; | ||
} else { | ||
errors = true; | ||
} | ||
} else { | ||
errors = true; | ||
} | ||
growth = growth + change; | ||
} | ||
}); | ||
|
||
return { value: growth.toFixed(2), errors }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,56 @@ | ||
@keyframes tickerh { | ||
0% { | ||
transform: translate3d(0, 0, 0); | ||
transform: translate(0, 0); | ||
} | ||
100% { | ||
transform: translate3d(-100%, 0, 0); | ||
transform: translate(-100%, 0); | ||
} | ||
} | ||
.ticker-wrap { | ||
.jast-wrapper { | ||
overflow: hidden; | ||
} | ||
.ticker-wrap.vertical { | ||
height: 26px; | ||
} | ||
.ticker-wrap.horizontal { | ||
padding-left: 100%; | ||
.jast-wrapper.horizontal { | ||
margin: 0 auto; | ||
white-space: nowrap; | ||
} | ||
.ticker-wrap ul { | ||
.jast-wrapper ul { | ||
padding: 0; | ||
margin: 0; | ||
list-style-type: none; | ||
} | ||
.jast-wrapper.vertical { | ||
height: 26px; | ||
} | ||
.jast-wrapper.vertical > ul { | ||
animation-name: tickerv; | ||
animation-iteration-count: infinite; | ||
animation-timing-function: cubic-bezier(1, 0, 0.5, 0); | ||
} | ||
.ticker-wrap.vertical ul { | ||
animation-name: tickerv; | ||
.jast-wrapper.horizontal .jast-hticker { | ||
margin: 0 auto; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
position: absolute; | ||
} | ||
.ticker-wrap.horizontal ul { | ||
padding-right: 100%; | ||
|
||
.jast-wrapper.horizontal span.jast-tickerframe { | ||
display: inline-block; | ||
white-space: nowrap; | ||
animation-iteration-count: infinite; | ||
animation-timing-function: linear; | ||
animation-name: tickerh; | ||
padding-left: 100%; | ||
} | ||
.ticker-wrap.horizontal ul li:before { | ||
|
||
.jast-wrapper.horizontal span.jast-stock:before { | ||
content: "\2022"; | ||
margin-right: 0.4em; | ||
margin-left: 0.4em; | ||
} | ||
.ticker-wrap ul li { | ||
.jast-wrapper .jast-stock { | ||
font-size: 18px; | ||
line-height: 26px; | ||
} | ||
.ticker-wrap.horizontal ul li { | ||
display: inline-block; | ||
padding: 0 0.3rem; | ||
} | ||
.ticker-wrap ul li span.high { | ||
|
||
.jast-wrapper .jast-stock span.high { | ||
color: green; | ||
} | ||
.ticker-wrap ul li span.low { | ||
.jast-wrapper .jast-stock span.low { | ||
color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.