indices validation and web panel integration

This commit is contained in:
Justin 2022-10-05 18:29:42 +08:00 committed by GitHub
parent 34690b8433
commit 011a308900
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,6 +45,7 @@ var imagesFeatures = document.querySelectorAll("#images-features li");
var gifsFeatures = document.querySelectorAll("#gifs-features li");
var messagesFeatures = document.querySelectorAll("#messages-features li");
var commoditiesFeatures = document.querySelectorAll("#commodities-features li");
var indicesFeatures = document.querySelectorAll("#indices-features li");
var allFeaturesList = [
stocksFeatures,
@ -61,6 +62,7 @@ var allFeaturesList = [
gifsFeatures,
messagesFeatures,
commoditiesFeatures,
indicesFeatures,
];
// features remove buttons
@ -84,6 +86,7 @@ var imagesRemoveBtn = document.getElementById("images-remove-btn");
var gifsRemoveBtn = document.getElementById("gifs-remove-btn");
var messagesRemoveBtn = document.getElementById("messages-remove-btn");
var commoditiesRemoveBtn = document.getElementById("commodities-remove-btn");
var indicesRemoveBtn = document.getElementById("indices-remove-btn");
var allFeaturesRemoveBtns = [
stocksRemoveBtn,
@ -100,6 +103,7 @@ var allFeaturesRemoveBtns = [
gifsRemoveBtn,
messagesRemoveBtn,
commoditiesRemoveBtn,
indicesRemoveBtn,
];
// features increase buttons
var stocksincreaseBtn = document.getElementById("stocks-increase-btn");
@ -122,6 +126,7 @@ var imagesincreaseBtn = document.getElementById("images-increase-btn");
var gifsincreaseBtn = document.getElementById("gifs-increase-btn");
var messagesincreaseBtn = document.getElementById("messages-increase-btn");
var commoditiesincreaseBtn = document.getElementById("commodities-increase-btn");
var indicesincreaseBtn = document.getElementById("indices-increase-btn");
var allFeaturesIncreaseBtns = [
stocksincreaseBtn,
@ -138,6 +143,7 @@ var allFeaturesIncreaseBtns = [
gifsincreaseBtn,
messagesincreaseBtn,
commoditiesincreaseBtn,
indicesincreaseBtn,
];
// features decrease buttons
@ -161,6 +167,7 @@ var imagesDecreaseBtn = document.getElementById("images-decrease-btn");
var gifsDecreaseBtn = document.getElementById("gifs-decrease-btn");
var messagesDecreaseBtn = document.getElementById("messages-decrease-btn");
var commoditiesDecreaseBtn = document.getElementById("commodities-decrease-btn");
var indicesDecreaseBtn = document.getElementById("indices-decrease-btn");
var allFeaturesDecreaseBtns = [
stocksDecreaseBtn,
@ -177,6 +184,7 @@ var allFeaturesDecreaseBtns = [
gifsDecreaseBtn,
messagesDecreaseBtn,
commoditiesDecreaseBtn,
indicesDecreaseBtn,
];
const changeVarValue = () => {
@ -200,6 +208,7 @@ const changeVarValue = () => {
gifsFeatures = document.querySelectorAll("#gifs-features li");
messagesFeatures = document.querySelectorAll("#messages-features li");
commoditiesFeatures = document.querySelectorAll("#commodities-features li");
indicesFeatures = document.querySelectorAll("#indices-features li");
allFeaturesList = [
stocksFeatures,
@ -216,6 +225,7 @@ const changeVarValue = () => {
gifsFeatures,
messagesFeatures,
commoditiesFeatures,
indicesFeatures,
];
};
@ -585,6 +595,7 @@ var images = document.getElementById("images-features");
var gifs = document.getElementById("gifs-features");
var messages = document.getElementById("messages-features");
var commodities = document.getElementById("commodities-features");
var indices = document.getElementById("indices-features");
var allFeatures = [
stocks,
@ -601,6 +612,7 @@ var allFeatures = [
gifs,
messages,
commodities,
indices,
];
// features select box
@ -624,6 +636,7 @@ var allFeaturesSelectBox = [
null,
null,
null,
null,
];
// features select add buttons
@ -647,6 +660,7 @@ var allFeaturesSelectAddBtn = [
null,
null,
null,
null,
];
allFeaturesSelectAddBtn.map((value, index) => {
@ -680,6 +694,7 @@ var allFeaturesFile = [
gifsFile,
null,
null,
null,
];
// features file add button
var imagesFileAddBtn = document.getElementById("inputTextBtn11");
@ -700,6 +715,7 @@ var allFeaturesFileAddBtn = [
gifsFileAddBtn,
null,
null,
null,
];
// features input text
@ -710,6 +726,7 @@ var currentWeatherText = document.getElementById("inputText6");
var dailyForecastText = document.getElementById("inputText7");
var messagesText = document.getElementById("inputText13");
var commoditiesText = document.getElementById("inputText20");
var indicesText = document.getElementById("inputText21");
var allFeaturesText = [
stocksText,
@ -726,6 +743,7 @@ var allFeaturesText = [
null,
messagesText,
commoditiesText,
indicesText,
];
// features text add button
@ -736,6 +754,7 @@ var currentWeatherTextAddBtn = document.getElementById("inputTextBtn6");
var dailyForecastTextAddBtn = document.getElementById("inputTextBtn7");
var messagesTextAddBtn = document.getElementById("inputTextBtn13");
var commoditiesTextAddBtn = document.getElementById("inputTextBtn20");
var indicesTextAddBtn = document.getElementById("inputTextBtn21");
var allFeaturesTextAddBtn = [
stocksTextAddBtn,
@ -752,6 +771,7 @@ var allFeaturesTextAddBtn = [
null,
messagesTextAddBtn,
commoditiesTextAddBtn,
indicesTextAddBtn,
];
@ -770,6 +790,7 @@ var allFeaturesLimit = [
20,
20,
30,
40,
];
@ -1025,6 +1046,7 @@ function getFeatureSettings() {
"Custom GIFs",
"Custom Messages",
"Commodities",
"Indices",
];
let pageNum = features.indexOf(feature) + 1;
let pageSelector = "Page" + pageNum.toString();
@ -1078,6 +1100,9 @@ function getFeatureSettings() {
case 14:
s = getTradingSettings(page);
break;
case 15:
s = getTradingSettings(page);
break;
}
settings = { ...settings, ...s }; // merge both sets of settings
@ -1200,6 +1225,7 @@ function saveWeatherAPIKey(){
"Custom GIFs",
"Custom Messages",
"Commodities",
"Indices",
];
let pageNum = features.indexOf(feature) + 1;
let pageSelector = "Page" + pageNum.toString();
@ -1553,7 +1579,7 @@ inputAnimationBtn.addEventListener("click", () => {
// scroll speed row two
let inputScrollSpeedRow = [];
for (let i = 1; i <= 14; i++) {
for (let i = 1; i <= 15; i++) {
inputScrollSpeedRow.push(
document.getElementById(
i === 1 ? "inputScrollSpeedRow" : `inputScrollSpeedRow${i}`
@ -2130,3 +2156,60 @@ var specialChars = /[`!@#$%^&*()_+\-=\[\]{};':"\\|<>\/?~]/;
}
document.getElementById("demo8").innerHTML = text;
}
// Indices validation
function indicesValidate() {
var specialChars = /[`!@#$%&*()_+\-=\[\]{};':"\\|<>\/?~]/;
let x = document.getElementById("inputText21").value;
let text;
if (x.toUpperCase() != x) {
document.getElementById('demo9').style.display = "block";
text = "Index symbol must be uppercase";
document.getElementById("inputText21").value = '';
// createLi = false;
}
else if (x === '') {
document.getElementById('demo9').style.display = "block";
text = "No blanks"
// createLi = false;
}
else if (x.includes(' ')) {
text = "No spaces";
document.getElementById('demo9').style.display = "block";
document.getElementById("inputText21").value = '';
// createLi = false;
}
else if (specialChars.test(x)) {
document.getElementById('demo9').style.display = "block";
text = "No special characters allowed";
document.getElementById("inputText21").value = '';
// createLi = false;
}
else if (!["^DJI","^GSPC","^NDX","^RUT","^VIX","^GSPTSE","^MXX","^BVSP","^GDAXI","^FTSE","^IBEX","^FCHI","^SSMI","^BFX","^ATX","^AEX","^OMX",
"^OMXH25","PSI20.LS","^STOXX","^STOXX50E","^N100","^KS11","^NZ50","^AXJO","^STI","000001.SS","399001.SZ","^N225","^NSEI","^BSESN","^HSI","^TWII","^JKSE","PSEI.PS","^SET.BK","XU100.IS"].includes(x)) {
document.getElementById('demo9').style.display = "block";
document.getElementById("inputText21").value = '';
text = "Invalid index symbol"
}
else {
text = "Input OK";
document.getElementById('demo9').style.display = "none";
createLi = true;
// CALL ADDING ITEMS FUNCTION SO THAT ONLY VALIDATED ITEMS CAN GET ADDED TO LIST
setTimeout(
function() {
document.getElementById('inputText21').value="";
}, 100);
}
document.getElementById("demo9").innerHTML = text;
}