custom msg value js func

This commit is contained in:
Justin 2023-07-07 16:22:21 +08:00 committed by GitHub
parent db154b3c3c
commit 843b5fcc81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -910,11 +910,11 @@ allFeaturesTextAddBtn.map((value, index) => {
else{
tag.innerHTML = allFeaturesText[index].value;
tag.setAttribute("onclick", "getCustomMsg(this.innerText)");
allFeatures[index].appendChild(tag);
changeVarValue();
addEventOnFeaturesList();
createLi = false;
}}
} else {
var msg = "You've reached the maximum limit of items to add for this feature";
@ -2755,3 +2755,32 @@ function setTop20() {
});
}
// get custom message values
function getCustomMsg(value) {
let messaged = value;
const the_thing = document.getElementById("inputText13");
const the_msg = document.getElementById("inputText14");
const t_color = document.getElementById("inputScrollSpeed16");
const b_color = document.getElementById("inputScrollSpeed19");
const t_size = document.getElementById("inputScrollSpeed17");
the_thing.value = messaged;
fetch("/fetchCustomMsg", {
method: "POST",
body: JSON.stringify(messaged),
})
.then(response => response.json())
.then(data => {
// Update the elements with the retrieved information
the_msg.value = data.text;
t_color.value = data.text_colour;
b_color.value = data.background_colour;
t_size.value = data.size;
})
.catch(error => {
console.error('Error:', error);
});
}