mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-11 12:58:04 +02:00
- podcast name was too vague and didn't come clearly for users: handle is more relevant - update package.json dependencies and remove unnused packages closes #126
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
const PublishMessageWarning = (): void => {
|
|
const publishForm: HTMLFormElement | null = document.querySelector(
|
|
"form[data-submit='validate-message']"
|
|
);
|
|
|
|
if (publishForm) {
|
|
const messageTextArea: HTMLTextAreaElement | null =
|
|
publishForm.querySelector("[name='message']");
|
|
const submitButton: HTMLButtonElement | null = publishForm.querySelector(
|
|
"button[type='submit']"
|
|
);
|
|
const publishMessageWarning: HTMLDivElement | null =
|
|
publishForm.querySelector("[id='publish-warning']");
|
|
|
|
if (
|
|
messageTextArea &&
|
|
submitButton &&
|
|
submitButton.dataset.btnTextWarning &&
|
|
submitButton.dataset.btnText &&
|
|
publishMessageWarning
|
|
) {
|
|
publishForm.addEventListener("submit", (event) => {
|
|
if (
|
|
messageTextArea.value === "" &&
|
|
publishMessageWarning.classList.contains("hidden")
|
|
) {
|
|
event.preventDefault();
|
|
|
|
publishMessageWarning.classList.remove("hidden");
|
|
messageTextArea.focus();
|
|
submitButton.innerText = submitButton.dataset
|
|
.btnTextWarning as string;
|
|
}
|
|
});
|
|
|
|
messageTextArea.addEventListener("input", () => {
|
|
if (
|
|
submitButton.innerText !== submitButton.dataset.btnText &&
|
|
messageTextArea.value !== ""
|
|
) {
|
|
publishMessageWarning.classList.add("hidden");
|
|
submitButton.innerText = submitButton.dataset.btnText as string;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
export default PublishMessageWarning;
|