Spaces:
Runtime error
Runtime error
<script> | |
function changeButtonColors() { | |
const streamlitDoc = window.parent.document; | |
const buttons = Array.from(streamlitDoc.querySelectorAll('.stButton > button')); | |
const Create_Obituary = buttons.find(el => el.innerText === 'Create Obituary'); | |
const I_want_to_add_more_information = buttons.find(el => el.innerText === 'I want to add more information'); | |
const I_want_to_export_and_edit_manually = buttons.find(el => el.innerText === 'I want to export and edit manually'); | |
const save_docx = buttons.find(el => el.innerText === 'Save as DOCX'); | |
const Email_Obituary = buttons.find(el => el.innerText === 'Email Obituary'); | |
const Send = buttons.find(el => el.innerText === 'Send'); | |
if (Create_Obituary) { | |
Create_Obituary.style.backgroundColor = "Blue"; | |
} | |
if (I_want_to_add_more_information) { | |
I_want_to_add_more_information.style.backgroundColor = "Blue"; | |
} | |
if (I_want_to_export_and_edit_manually) { | |
I_want_to_export_and_edit_manually.style.backgroundColor = "#e75480"; | |
} | |
if (save_docx) { | |
save_docx.style.backgroundColor = "Blue"; | |
} | |
if (Email_Obituary) { | |
Email_Obituary.style.backgroundColor = "#e75480"; | |
} | |
if (Send) { | |
Send.style.backgroundColor = "#e75480"; | |
} | |
} | |
function updateButtonColorsOnClick() { | |
const streamlitDoc = window.parent.document; | |
const Email_Obituary = streamlitDoc.querySelector('.stButton > button:contains("Email Obituary")'); | |
if (Email_Obituary) { | |
Email_Obituary.addEventListener("click", () => { | |
setTimeout(() => { | |
changeButtonColors(); | |
}, 50); | |
}); | |
} | |
} | |
changeButtonColors(); // Call initially to set colors for form page buttons | |
updateButtonColorsOnClick(); // Add event listener for "Email Obituary" button | |
window.addEventListener('message', (event) => { | |
if (event.data.type === 'streamlit:update') { | |
setTimeout(() => { | |
changeButtonColors(); | |
updateButtonColorsOnClick(); | |
}, 200); | |
} | |
}); | |
</script> | |