diff --git a/static/app.js b/static/app.js index 49c15a9..6e115bd 100755 --- a/static/app.js +++ b/static/app.js @@ -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(); + } +} + +