update the selected cusotm msg with any changes made

This commit is contained in:
Justin 2023-07-07 23:18:58 +08:00 committed by GitHub
parent 7c8e685d7c
commit 605432a181
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2761,6 +2761,8 @@ function setTop20() {
}
let theIndexOfMsg = 0
// get custom message values
function getCustomMsg(value) {
let messaged = value;
@ -2782,6 +2784,7 @@ function getCustomMsg(value) {
t_color.value = data.text_colour;
b_color.value = data.background_colour;
t_size.value = data.size;
theIndexOfMsg = data.index;
})
.catch(error => {
console.error('Error:', error);
@ -2789,3 +2792,35 @@ function getCustomMsg(value) {
}
// get custom message values
function updateSelectedMsg(){
const msg_name = document.getElementById("inputText13").value;
const msg_text = document.getElementById("inputText14").value;
if ((msg_name !== '') && (msg_text !== '')) {
const text_color = document.getElementById("inputScrollSpeed16").value;
const background_color = document.getElementById("inputScrollSpeed19").value;
const text_size = document.getElementById("inputScrollSpeed17").value;
document.getElementById('demo4').style.display = "none";
document.getElementById('demo5').style.display = "none";
fetch("/updateSelectedMsg", {
method: "POST",
body: JSON.stringify({'name': msg_name, 'text': msg_text, 'text_colour': text_color, 'size': text_size, 'background_colour': background_color, 'index':theIndexOfMsg}),
});
const ulElement = document.getElementById("messages-features");
const activeListItem = ulElement.querySelector("li.active");
activeListItem.innerText = msg_name;
document.getElementById('updated-message-p').style.display = "block";
setTimeout(function hideElement() {
document.getElementById('updated-message-p').style.display = "none";
}, 5000);
}
else {
customMsgValidate();
}
}