if it aint empty, excute the function

This commit is contained in:
Justin 2023-08-02 21:32:00 +08:00 committed by GitHub
parent f23c03c69d
commit caf38275ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3349,43 +3349,45 @@ function scanNetworks() {
} }
// UPLOAD CUSTOM STOCK LOGO // UPLOAD CUSTOM STOCK LOGO
function uploadStockLogo() { function uploadStockLogo() {
const fileInput_stocks = document.getElementById("stocks-logo-upload-browse"); const fileInput_stocks = document.getElementById("stocks-logo-upload-browse");
const stock_file = fileInput_stocks.files[0]; if (fileInput_stocks.value !== "") {
const stock_upload_msg = document.getElementById("stocklogoupload"); const stock_file = fileInput_stocks.files[0];
const stock_upload_msg = document.getElementById("stocklogoupload");
const formData_stocks = new FormData(); const formData_stocks = new FormData();
formData_stocks.append('file', stock_file) formData_stocks.append('file', stock_file)
fetch('/upload_stocks', { fetch('/upload_stocks', {
method: 'POST', method: 'POST',
body: formData_stocks body: formData_stocks
}) })
stock_upload_msg.style.display = "block"; stock_upload_msg.style.display = "block";
setTimeout(function hideElement() { setTimeout(function hideElement() {
stock_upload_msg.style.display = "none"; stock_upload_msg.style.display = "none";
}, 5000); }, 5000);
fileInput_stocks.value = ""; fileInput_stocks.value = "";
}
} }
// UPLOAD CUSTOM CRYPTO LOGO // UPLOAD CUSTOM CRYPTO LOGO
function uploadCryptoLogo() { function uploadCryptoLogo() {
const fileInput_crypto = document.getElementById("crypto-logo-upload-browse"); const fileInput_crypto = document.getElementById("crypto-logo-upload-browse");
const crypto_file = fileInput_crypto.files[0]; if (fileInput_crypto.value !== "") {
const crypto_upload_msg = document.getElementById("cryptologoupload"); const crypto_file = fileInput_crypto.files[0];
const crypto_upload_msg = document.getElementById("cryptologoupload");
const formData_crypto = new FormData(); const formData_crypto = new FormData();
formData_crypto.append('file', crypto_file); formData_crypto.append('file', crypto_file);
fetch('/upload_crypto', { fetch('/upload_crypto', {
method: 'POST', method: 'POST',
body: formData_crypto body: formData_crypto
}) });
crypto_upload_msg.style.display = "block"; crypto_upload_msg.style.display = "block";
setTimeout(function hideElement() { setTimeout(function hideElement() {
crypto_upload_msg.style.display = "none"; crypto_upload_msg.style.display = "none";
}, 5000); }, 5000);
fileInput_crypto.value = ""; fileInput_crypto.value = "";
}
} }