mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-21 05:35:45 +01:00
align stock market info
This commit is contained in:
parent
d54439be8b
commit
4858dabe99
@ -175,6 +175,11 @@ let StockMarket = {} //Full name to stock object
|
|||||||
let StockSymbols = {} //Full name to symbol
|
let StockSymbols = {} //Full name to symbol
|
||||||
let SymbolToStockMap = {}; //Symbol to Stock object
|
let SymbolToStockMap = {}; //Symbol to Stock object
|
||||||
|
|
||||||
|
let formatHelpData = {
|
||||||
|
longestName: 0,
|
||||||
|
longestSymbol: 0,
|
||||||
|
};
|
||||||
|
|
||||||
function loadStockMarket(saveString) {
|
function loadStockMarket(saveString) {
|
||||||
if (saveString === "") {
|
if (saveString === "") {
|
||||||
StockMarket = {};
|
StockMarket = {};
|
||||||
@ -220,6 +225,12 @@ function initStockSymbols() {
|
|||||||
StockSymbols["Catalyst Ventures"] = "CTYS";
|
StockSymbols["Catalyst Ventures"] = "CTYS";
|
||||||
StockSymbols["Microdyne Technologies"] = "MDYN";
|
StockSymbols["Microdyne Technologies"] = "MDYN";
|
||||||
StockSymbols["Titan Laboratories"] = "TITN";
|
StockSymbols["Titan Laboratories"] = "TITN";
|
||||||
|
|
||||||
|
for (const key in StockSymbols) {
|
||||||
|
formatHelpData.longestName = key.length > formatHelpData.longestName ? key.length : formatHelpData.longestName;
|
||||||
|
formatHelpData.longestSymbol = StockSymbols[key].length > formatHelpData.longestSymbol ? StockSymbols[key].length : formatHelpData.longestSymbol;
|
||||||
|
}
|
||||||
|
console.log(formatHelpData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initStockMarket() {
|
function initStockMarket() {
|
||||||
@ -1070,10 +1081,11 @@ function createStockTicker(stock) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var tickerId = "stock-market-ticker-" + stock.symbol;
|
var tickerId = "stock-market-ticker-" + stock.symbol;
|
||||||
var li = document.createElement("li"), hdr = document.createElement("button");
|
var li = document.createElement("li"), hdr = document.createElement("button"), hdrpre = document.createElement("pre");;
|
||||||
hdr.classList.add("accordion-header");
|
hdr.classList.add("accordion-header");
|
||||||
hdr.setAttribute("id", tickerId + "-hdr");
|
hdr.setAttribute("id", tickerId + "-hdr");
|
||||||
hdr.innerHTML = stock.name + " - " + stock.symbol + " - " + numeralWrapper.format(stock.price, '($0.000a)');
|
hdrpre.textContent = stock.name + " - " + stock.symbol + " - " + numeralWrapper.format(stock.price, '($0.000a)');
|
||||||
|
hdr.appendChild(hdrpre);
|
||||||
|
|
||||||
//Div for entire panel
|
//Div for entire panel
|
||||||
var stockDiv = document.createElement("div");
|
var stockDiv = document.createElement("div");
|
||||||
@ -1352,19 +1364,15 @@ function updateStockTicker(stock, increase) {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let hdrText = stock.name + " (" + stock.symbol + ") - " + numeralWrapper.format(stock.price, '($0.000a)');
|
const stockPriceFormat = numeralWrapper.format(stock.price, '($0.000a)')
|
||||||
|
let hdrText = `${stock.name}${" ".repeat(1 + formatHelpData.longestName - stock.name.length + (formatHelpData.longestSymbol-stock.symbol.length))}${stock.symbol} -${" ".repeat(10 - stockPriceFormat.length)}${stockPriceFormat}`;
|
||||||
if (Player.has4SData) {
|
if (Player.has4SData) {
|
||||||
hdrText += " - Volatility: " + numeralWrapper.format(stock.mv, '0,0.00') + "%" +
|
hdrText += ` - Volatility: ${numeralWrapper.format(stock.mv, '0,0.00')}% - Price Forecast: `;
|
||||||
" - Price Forecast: ";
|
hdrText += (stock.b?"+":"-").repeat(Math.floor(stock.otlkMag/10) + 1);
|
||||||
if (stock.b) {
|
|
||||||
hdrText += "+".repeat(Math.floor(stock.otlkMag/10) + 1);
|
|
||||||
} else {
|
|
||||||
hdrText += "-".repeat(Math.floor(stock.otlkMag/10) + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
hdr.innerText = hdrText;
|
hdr.firstChild.textContent = hdrText;
|
||||||
if (increase != null) {
|
if (increase != null) {
|
||||||
increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red";
|
hdr.firstChild.style.color = increase ? "#66ff33" : "red";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user