getglobalstocksymbol function

This commit is contained in:
Justin 2023-09-26 15:19:47 +08:00 committed by GitHub
parent f435cbd9bb
commit fd782c6fbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3484,6 +3484,40 @@ function getStockSymbol(value) {
}} }}
// get global stock portfolio values
function getGlobalStockSymbol(value) {
let globalstock_symbol = value;
const globalstock_thing = document.getElementById("globalstocks_symbol");
const globalstock_shares = document.getElementById("globalstocks_port_shares");
const globalstock_cost = document.getElementById("globalstocks_port_cost");
const globalstock_date = document.getElementById("globalstocks_port_date");
const globalstock_portfolio_check = document.getElementById("globalstocks_portfolio");
globalstock_thing.value = globalstock_symbol;
if (globalstock_portfolio_check.checked) {
fetch("/fetchGlobalStockPortfolio", {
method: "POST",
body: JSON.stringify(globalstock_symbol),
})
.then(response => response.json())
.then(data => {
if (JSON.stringify(data) !== '{}') {
// Update the elements with the retrieved information
globalstock_shares.value = data.shares;
globalstock_cost.value = data.cost;
globalstock_date.value = data.day;
} else {
globalstock_shares.value = '';
globalstock_cost.value = '';
globalstock_date.value = '';
}
})
.catch(error => {
console.error('Error:', error);
});
}}
// get crypto portfolio values // get crypto portfolio values
function getCryptoSymbol(value) { function getCryptoSymbol(value) {
let crypto_symbol = value; let crypto_symbol = value;