forex text input to dropdown menu
This commit is contained in:
parent
9b77876712
commit
a639cb343b
158
static/app.js
158
static/app.js
@ -746,7 +746,7 @@ var allFeaturesFileAddBtn = [
|
||||
// features input text
|
||||
var stocksText = document.getElementById("inputText3");
|
||||
var cryptoText = document.getElementById("inputText4");
|
||||
var forexText = document.getElementById("inputText5");
|
||||
var forexText = document.getElementById("base-select").value + ',' + document.getElementById("quote-select").value;
|
||||
var currentWeatherText = document.getElementById("inputText6");
|
||||
var dailyForecastText = document.getElementById("inputText7");
|
||||
var messagesText = document.getElementById("inputText13");
|
||||
@ -903,10 +903,13 @@ allFeaturesTextAddBtn.map((value, index) => {
|
||||
}
|
||||
|
||||
else{
|
||||
|
||||
if (createLi === true) {
|
||||
var tag = document.createElement("li");
|
||||
tag.innerHTML = allFeaturesText[index].value;
|
||||
if (index == 2) {
|
||||
tag.innerHTML= document.getElementById("base-select").value + ',' + document.getElementById("quote-select").value;
|
||||
} else{
|
||||
tag.innerHTML = allFeaturesText[index].value;
|
||||
}
|
||||
allFeatures[index].appendChild(tag);
|
||||
changeVarValue();
|
||||
addEventOnFeaturesList();
|
||||
@ -2245,95 +2248,96 @@ var specialChars = /[`!@#$%^&*()_+\-=\[\]{};':"\\|<>\/?~]/;
|
||||
|
||||
|
||||
// Forex validation
|
||||
|
||||
function forexValidate() {
|
||||
createLi = true;
|
||||
}
|
||||
|
||||
var specialChars = /[`!@#$%^&*()_+\-=\[\]{};':"\\|<>\/?~]/;
|
||||
// var specialChars = /[`!@#$%^&*()_+\-=\[\]{};':"\\|<>\/?~]/;
|
||||
|
||||
let x = document.getElementById("inputText5").value;
|
||||
let quoteCurrency = x.split(",")[1];
|
||||
let baseCurrency = x.split(",")[0];
|
||||
// let x = document.getElementById("inputText5").value;
|
||||
// let quoteCurrency = x.split(",")[1];
|
||||
// let baseCurrency = x.split(",")[0];
|
||||
|
||||
// console.log("base"+baseCurrency);
|
||||
// console.log("quote"+quoteCurrency);
|
||||
// // console.log("base"+baseCurrency);
|
||||
// // console.log("quote"+quoteCurrency);
|
||||
|
||||
let text;
|
||||
if (x.toUpperCase() != x) {
|
||||
document.getElementById('demo3').style.display = "block";
|
||||
text = "Base and quote must be uppercase";
|
||||
document.getElementById("inputText5").value = '';
|
||||
// createLi = false;
|
||||
}
|
||||
else if (x === '') {
|
||||
document.getElementById('demo3').style.display = "block";
|
||||
text = "No blanks"
|
||||
}
|
||||
// let text;
|
||||
// if (x.toUpperCase() != x) {
|
||||
// document.getElementById('demo3').style.display = "block";
|
||||
// text = "Base and quote must be uppercase";
|
||||
// document.getElementById("inputText5").value = '';
|
||||
// // createLi = false;
|
||||
// }
|
||||
// else if (x === '') {
|
||||
// document.getElementById('demo3').style.display = "block";
|
||||
// text = "No blanks"
|
||||
// }
|
||||
|
||||
else if (x.includes(' ')) {
|
||||
text = "No spaces";
|
||||
document.getElementById('demo3').style.display = "block";
|
||||
document.getElementById("inputText5").value = '';
|
||||
}
|
||||
// else if (x.includes(' ')) {
|
||||
// text = "No spaces";
|
||||
// document.getElementById('demo3').style.display = "block";
|
||||
// document.getElementById("inputText5").value = '';
|
||||
// }
|
||||
|
||||
else if (/\d/.test(x)) {
|
||||
document.getElementById('demo3').style.display = "block";
|
||||
text = "No numbers allowed";
|
||||
document.getElementById("inputText5").value = '';
|
||||
}
|
||||
// CAREFUL TO DELETE THE BACKEND LIST ITEMS, JUST DELETING THE VALUE LIKE THIS ISN"T 100% ACCURATE
|
||||
// else if (/\d/.test(x)) {
|
||||
// document.getElementById('demo3').style.display = "block";
|
||||
// text = "No numbers allowed";
|
||||
// document.getElementById("inputText5").value = '';
|
||||
// }
|
||||
// // CAREFUL TO DELETE THE BACKEND LIST ITEMS, JUST DELETING THE VALUE LIKE THIS ISN"T 100% ACCURATE
|
||||
|
||||
else if (specialChars.test(x)) {
|
||||
document.getElementById('demo3').style.display = "block";
|
||||
text = "No special characters allowed";
|
||||
document.getElementById("inputText5").value = '';
|
||||
}
|
||||
// else if (specialChars.test(x)) {
|
||||
// document.getElementById('demo3').style.display = "block";
|
||||
// text = "No special characters allowed";
|
||||
// document.getElementById("inputText5").value = '';
|
||||
// }
|
||||
|
||||
else if (!x.includes(',')) {
|
||||
document.getElementById('demo3').style.display = "block";
|
||||
document.getElementById("inputText5").value = '';
|
||||
text = "Missing ',' (e.g. EUR,USD)"
|
||||
}
|
||||
// else if (!x.includes(',')) {
|
||||
// document.getElementById('demo3').style.display = "block";
|
||||
// document.getElementById("inputText5").value = '';
|
||||
// text = "Missing ',' (e.g. EUR,USD)"
|
||||
// }
|
||||
|
||||
else if (x.length > 7) {
|
||||
document.getElementById('demo3').style.display = "block";
|
||||
text = "No more than 7 characters";
|
||||
document.getElementById("inputText5").value = '';
|
||||
}
|
||||
// else if (x.length > 7) {
|
||||
// document.getElementById('demo3').style.display = "block";
|
||||
// text = "No more than 7 characters";
|
||||
// document.getElementById("inputText5").value = '';
|
||||
// }
|
||||
|
||||
else if (!["USD","EUR","JPY","GBP","AUD","CAD","CHF","CNY","HKD","NZD","SEK","KRW","SGD","NOK","MXN","INR","RUB","ZAR","TRY","BRL",
|
||||
"TWD","DKK","PLN","THB","IDR","HUF","ILS","CLP","PHP","AED","CZK","COP","SAR","MYR","RON","CLP","ARS","VND","QAR","KWD"].includes(baseCurrency)) {
|
||||
document.getElementById('demo3').style.display = "block";
|
||||
document.getElementById("inputText5").value = '';
|
||||
text = "Invalid base currency"
|
||||
// else if (!["USD","EUR","JPY","GBP","AUD","CAD","CHF","CNY","HKD","NZD","SEK","KRW","SGD","NOK","MXN","INR","RUB","ZAR","TRY","BRL",
|
||||
// "TWD","DKK","PLN","THB","IDR","HUF","ILS","CLP","PHP","AED","CZK","COP","SAR","MYR","RON","CLP","ARS","VND","QAR","KWD"].includes(baseCurrency)) {
|
||||
// document.getElementById('demo3').style.display = "block";
|
||||
// document.getElementById("inputText5").value = '';
|
||||
// text = "Invalid base currency"
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
else if (!["AED","AFN","ALL","AMD","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BMD","BND","BOB","BRL","BSD", "BTN", "BWP", "BYN",
|
||||
"BZD", "CAD", "CDF", "CHF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR",
|
||||
"FJD", "FKP", "FOK", "GBP", "GEL", "GGP", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP",
|
||||
"INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY","KES","KGS","KHR","KID","KMF","KRW","KWD", "KYD","KZT","LAK","LBP","LKR","LRD","LSL", "LYD",
|
||||
"MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN",
|
||||
"PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLL","SOS","SRD","SSP","STN","SYP","SZL",
|
||||
"THB","TJS","TMT","TND","TOP","TRY","TTD","TVD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VES","VND","VUV","WST","YER","ZAR"].includes(quoteCurrency)) {
|
||||
document.getElementById('demo3').style.display = "block";
|
||||
document.getElementById("inputText5").value = '';
|
||||
text = "Invalid quote currency"
|
||||
// else if (!["AED","AFN","ALL","AMD","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BMD","BND","BOB","BRL","BSD", "BTN", "BWP", "BYN",
|
||||
// "BZD", "CAD", "CDF", "CHF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR",
|
||||
// "FJD", "FKP", "FOK", "GBP", "GEL", "GGP", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP",
|
||||
// "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY","KES","KGS","KHR","KID","KMF","KRW","KWD", "KYD","KZT","LAK","LBP","LKR","LRD","LSL", "LYD",
|
||||
// "MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN",
|
||||
// "PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLL","SOS","SRD","SSP","STN","SYP","SZL",
|
||||
// "THB","TJS","TMT","TND","TOP","TRY","TTD","TVD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VES","VND","VUV","WST","YER","ZAR"].includes(quoteCurrency)) {
|
||||
// document.getElementById('demo3').style.display = "block";
|
||||
// document.getElementById("inputText5").value = '';
|
||||
// text = "Invalid quote currency"
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
else {
|
||||
text = "Input OK";
|
||||
document.getElementById('demo3').style.display = "none";
|
||||
createLi = true;
|
||||
// CALL ADDING ITEMS FUNCTION SO THAT ONLY VALIDATED ITEMS CAN GET ADDED TO LIST
|
||||
// addingItems();
|
||||
setTimeout(
|
||||
function() {
|
||||
document.getElementById('inputText5').value="";
|
||||
}, 100);
|
||||
}
|
||||
document.getElementById("demo3").innerHTML = text;
|
||||
}
|
||||
// else {
|
||||
// text = "Input OK";
|
||||
// document.getElementById('demo3').style.display = "none";
|
||||
// createLi = true;
|
||||
// // CALL ADDING ITEMS FUNCTION SO THAT ONLY VALIDATED ITEMS CAN GET ADDED TO LIST
|
||||
// // addingItems();
|
||||
// setTimeout(
|
||||
// function() {
|
||||
// document.getElementById('inputText5').value="";
|
||||
// }, 100);
|
||||
// }
|
||||
// document.getElementById("demo3").innerHTML = text;
|
||||
// }
|
||||
|
||||
|
||||
// Custom messages validation
|
||||
|
Loading…
Reference in New Issue
Block a user