functioning show/hide system

This commit is contained in:
nelle 2024-09-03 15:33:41 -06:00
parent f69004be1f
commit 6aedbadae1
2 changed files with 26 additions and 23 deletions

View file

@ -4,6 +4,11 @@ const ntfyAttach = document.getElementById("ntfy-attach");
const ntfyClickAction = document.getElementById("ntfy-click");
const ntfyButton = document.getElementById("ntfy-button");
const titleCheck = document.getElementById("titleCheckbox");
const attachmentCheck = document.getElementById("attachmentCheckbox");
const clickCheck = document.getElementById("clickCheckbox");
const msgPFX = "message: "
// Random placeholder
@ -49,21 +54,19 @@ function getPlaceholder() {
function send(message, title, attachment, click) {
const r = new XMLHttpRequest();
r.open("POST", "https://ntfy.ouroboros.group/beep", true);
r.setRequestHeader("Content-Type", "text/plain");/*
r.setRequestHeader("Content-Type", "text/plain");
r.setRequestHeader("Title", title);
r.setRequestHeader("Attach", attachment);
r.setRequestHeader("Click", click);*/
r.setRequestHeader("Click", click);
r.send(message);
}
// send notification
function sendNotification() {/*
function sendNotification() {
send(ntfyTitle.value, ntfyMessage.value, ntfyAttach.value, ntfyClickAction.value);
ntfyTitle.value = "";
ntfyAttach.value = "";
ntfyClickAction.value = "";*/
send(ntfyMessage.value);
ntfyMessage.value = "";
ntfyClickAction.value = "";
}
// on send button click
@ -84,28 +87,28 @@ async function ntfyClick() {
}
function toggleTitle() {
if (ntfyTitle.style.display === "none") {
ntfyTitle.style.display = "internal"
if (titleCheck.checked) {
ntfyTitle.style.display = "initial"
}
if (ntfyTitle.style.display === "internal") {
if (!titleCheck.checked) {
ntfyTitle.style.display = "none"
}
}
function toggleAttach() {
if (ntfyAttach.style.display === "none") {
ntfyAttach.style.display = "internal"
if (attachmentCheck.checked) {
ntfyAttach.style.display = "initial"
}
if (ntfyAttach.style.display === "internal") {
if (!attachmentCheck.checked) {
ntfyAttach.style.display = "none"
}
}
function toggleClick() {
if (ntfyClickAction.style.display === "none") {
ntfyClickAction.style.display = "internal"
if (clickCheck.checked) {
ntfyClickAction.style.display = "initial"
}
if (ntfyAttach.style.display === "internal") {
ntfyAttach.style.display = "none"
if (!clickCheck.checked) {
ntfyClickAction.style.display = "none"
}
}

View file

@ -20,18 +20,18 @@
</small>
<br>
<br>
<fieldset style="margin-left: 35%; margin-right: 35%; margin-bottom: 2%; display: none;">
<fieldset style="margin-left: 35%; margin-right: 35%; margin-bottom: 2%;">
<div>
<input type="checkbox" id="title" name="title" onchange="toggleTitle()" />
<label for="title">Add Title?</label>
<input type="checkbox" id="titleCheckbox" name="titleCheckbox" onchange="toggleTitle()"/>
<label for="titleCheckbox">Add Title?</label>
</div>
<div>
<input type="checkbox" id="attachment" name="attachment" onchange="toggleAttach()" />
<label for="attachment">Add Attachment?</label>
<input type="checkbox" id="attachmentCheckbox" name="attachmentCheckbox" onchange="toggleAttach()" />
<label for="attachmentCheckbox">Add Attachment?</label>
</div>
<div>
<input type="checkbox" id="click" name="click" onchange="toggleClick()" />
<label for="click">Add Click Action?</label>
<input type="checkbox" id="clickCheckbox" name="clickCheckbox" onchange="toggleClick()" />
<label for="clickCheckbox">Add Click Action?</label>
</div>
</fieldset>
<textarea id="ntfy-title" placeholder="title" rows=1 style="resize: none; display: none;"></textarea>