update and remove global stock portfolio positions
This commit is contained in:
parent
12cf1fa1bc
commit
934026d6ad
@ -3586,7 +3586,6 @@ function removeStockPorftolio() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// update stock portfolio position with new values
|
// update stock portfolio position with new values
|
||||||
function updateStockPorftolio() {
|
function updateStockPorftolio() {
|
||||||
|
|
||||||
@ -3651,6 +3650,102 @@ function updateStockPorftolio() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// remove global stock portfolio position
|
||||||
|
function removeGlobalStockPorftolio() {
|
||||||
|
|
||||||
|
let remove_globalstock_symbol = document.getElementById('globalstocks_symbol').value;
|
||||||
|
|
||||||
|
if (remove_globalstock_symbol !== '') {
|
||||||
|
document.getElementById('globalstocks_port_cost').value = '';
|
||||||
|
document.getElementById('globalstocks_port_shares').value = '';
|
||||||
|
document.getElementById('globalstocks_port_date').value = '';
|
||||||
|
|
||||||
|
fetch("/deleteGlobalPortfolioPosition", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(remove_globalstock_symbol),
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('globalstockremoved-p').innerHTML = 'Global stock Position Removed!';
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "block";
|
||||||
|
setTimeout(function hideElement() {
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "none";
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
document.getElementById('globalstockremoved-p').innerHTML = 'No symbol selected.';
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "block";
|
||||||
|
setTimeout(function hideElement() {
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "none";
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// update global stock portfolio position with new values
|
||||||
|
function updateGlobalStockPorftolio() {
|
||||||
|
|
||||||
|
let update_globalstock_cost = document.getElementById('globalstocks_port_cost').value;
|
||||||
|
let update_globalstock_shares = document.getElementById('globalstocks_port_shares').value;
|
||||||
|
let update_globalsymbol = document.getElementById('globalstocks_symbol').value;
|
||||||
|
let update_globalstock_days = document.getElementById('globalstocks_port_date').value;
|
||||||
|
|
||||||
|
let update_globalstock_settings = {
|
||||||
|
shares:update_globalstock_shares,
|
||||||
|
cost:update_globalstock_cost,
|
||||||
|
symbol:update_globalsymbol,
|
||||||
|
days:update_globalstock_days,
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((update_globalsymbol === '') || (update_globalsymbol === ' ')) {
|
||||||
|
document.getElementById('globalstockremoved-p').innerHTML = 'No symbol selected.';
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "block";
|
||||||
|
setTimeout(function hideElement() {
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "none";
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
else if ((update_globalstock_cost === ' ') || (update_globalstock_shares === ' ') || (update_globalstock_days === ' ')) {
|
||||||
|
document.getElementById('globalstockremoved-p').innerHTML = 'No spaces.';
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "block";
|
||||||
|
setTimeout(function hideElement() {
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "none";
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
else if ((isNaN(update_globalstock_cost)) || (isNaN(update_globalstock_shares))) {
|
||||||
|
document.getElementById('globalstockremoved-p').innerHTML = 'No text characters, only numbers.';
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "block";
|
||||||
|
setTimeout(function hideElement() {
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "none";
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
else if ((!update_globalstock_days.includes('-')) && (update_globalstock_days !== '')) {
|
||||||
|
document.getElementById('globalstockremoved-p').innerHTML = 'Incorrect date format, it should be YYYY-MM-DD';
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "block";
|
||||||
|
setTimeout(function hideElement() {
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "none";
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
else if (((update_globalstock_shares !== '') || (update_globalstock_cost !== '') || (update_globalstock_days !== '')) && ((update_globalstock_shares === '') || (update_globalstock_cost === '') || (update_globalstock_days === ''))) {
|
||||||
|
document.getElementById('globalstockremoved-p').innerHTML = 'Some fields are empty.';
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "block";
|
||||||
|
setTimeout(function hideElement() {
|
||||||
|
document.getElementById('removed-globalstock-p').style.display = "none";
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fetch("/saveGlobalPortfolioSettings", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(update_globalstock_settings),
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('updated-globalstock-p').style.display = "block";
|
||||||
|
setTimeout(function hideElement() {
|
||||||
|
document.getElementById('updated-globalstock-p').style.display = "none";
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// remove crypto portfolio position
|
// remove crypto portfolio position
|
||||||
function removeCryptoPorftolio() {
|
function removeCryptoPorftolio() {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user