prettify, sorry for the big ass commit

This commit is contained in:
Olivier Gagnon
2021-09-04 19:09:30 -04:00
parent 3d7cdb4ef9
commit a18bdd6afc
554 changed files with 91615 additions and 66138 deletions
+44 -32
View File
@@ -13,44 +13,56 @@ import { Settings } from "../../Settings/Settings";
import { numeralWrapper } from "../../ui/numeralFormat";
type IProps = {
p: IPlayer;
stock: Stock;
}
p: IPlayer;
stock: Stock;
};
const localesWithLongPriceFormat = [
"cs",
"lv",
"pl",
"ru",
];
const localesWithLongPriceFormat = ["cs", "lv", "pl", "ru"];
export function StockTickerHeaderText(props: IProps): React.ReactElement {
const stock = props.stock;
const stock = props.stock;
const stockPriceFormat = numeralWrapper.formatMoney(stock.price);
const spacesAllottedForStockPrice = localesWithLongPriceFormat.includes(Settings.Locale) ? 15 : 12;
const spacesAfterStockName = " ".repeat(1 + TickerHeaderFormatData.longestName - stock.name.length + (TickerHeaderFormatData.longestSymbol - stock.symbol.length));
const spacesBeforePrice = " ".repeat(spacesAllottedForStockPrice - stockPriceFormat.length);
const stockPriceFormat = numeralWrapper.formatMoney(stock.price);
const spacesAllottedForStockPrice = localesWithLongPriceFormat.includes(
Settings.Locale,
)
? 15
: 12;
const spacesAfterStockName = " ".repeat(
1 +
TickerHeaderFormatData.longestName -
stock.name.length +
(TickerHeaderFormatData.longestSymbol - stock.symbol.length),
);
const spacesBeforePrice = " ".repeat(
spacesAllottedForStockPrice - stockPriceFormat.length,
);
let hdrText = `${stock.name}${spacesAfterStockName}${stock.symbol} -${spacesBeforePrice}${stockPriceFormat}`;
if (props.p.has4SData) {
hdrText += ` - Volatility: ${numeralWrapper.formatPercentage(stock.mv/100)} - Price Forecast: `;
let plusOrMinus = stock.b; // True for "+", false for "-"
if (stock.otlkMag < 0) { plusOrMinus = !plusOrMinus }
hdrText += (plusOrMinus ? "+" : "-").repeat(Math.floor(Math.abs(stock.otlkMag) / 10) + 1);
// Debugging:
// hdrText += ` - ${stock.getAbsoluteForecast()} / ${stock.otlkMagForecast}`;
let hdrText = `${stock.name}${spacesAfterStockName}${stock.symbol} -${spacesBeforePrice}${stockPriceFormat}`;
if (props.p.has4SData) {
hdrText += ` - Volatility: ${numeralWrapper.formatPercentage(
stock.mv / 100,
)} - Price Forecast: `;
let plusOrMinus = stock.b; // True for "+", false for "-"
if (stock.otlkMag < 0) {
plusOrMinus = !plusOrMinus;
}
hdrText += (plusOrMinus ? "+" : "-").repeat(
Math.floor(Math.abs(stock.otlkMag) / 10) + 1,
);
const styleMarkup = {
color: "#66ff33",
};
if (stock.lastPrice === stock.price) {
styleMarkup.color = "white";
} else if (stock.lastPrice > stock.price) {
styleMarkup.color = "red";
}
// Debugging:
// hdrText += ` - ${stock.getAbsoluteForecast()} / ${stock.otlkMagForecast}`;
}
return <pre style={styleMarkup}>{hdrText}</pre>;
const styleMarkup = {
color: "#66ff33",
};
if (stock.lastPrice === stock.price) {
styleMarkup.color = "white";
} else if (stock.lastPrice > stock.price) {
styleMarkup.color = "red";
}
return <pre style={styleMarkup}>{hdrText}</pre>;
}