main #8

Closed
limepotato wants to merge 183 commits from main into blog-drafts
Showing only changes of commit afdbc62f05 - Show all commits

View file

@ -211,9 +211,9 @@ function sendNone(endpoint, message) {
r.send(message);
}
// send all
function sendAll(title, message, attachment, click) {
function sendAll(endpoint, title, message, attachment, click) {
const r = new XMLHttpRequest();
r.open("POST", ntfyEndpoint, true);
r.open("POST", endpoint, true);
r.setRequestHeader("Content-Type", "text/plain");
r.setRequestHeader("Title", title);
r.setRequestHeader("Attach", attachment);
@ -221,51 +221,51 @@ function sendAll(title, message, attachment, click) {
r.send(message);
}
// send title only
function sendTitle(title, message) {
function sendTitle(endpoint, title, message) {
const r = new XMLHttpRequest();
r.open("POST", ntfyEndpoint, true);
r.open("POST", endpoint, true);
r.setRequestHeader("Content-Type", "text/plain");
r.setRequestHeader("Title", title);
r.send(message);
}
// send attachment only
function sendAttach(message, attachment) {
function sendAttach(endpoint, message, attachment) {
const r = new XMLHttpRequest();
r.open("POST", ntfyEndpoint, true);
r.open("POST", endpoint, true);
r.setRequestHeader("Content-Type", "text/plain");
r.setRequestHeader("Attach", attachment);
r.send(message);
}
// send click only
function sendClick(message, click) {
function sendClick(endpoint, message, click) {
const r = new XMLHttpRequest();
r.open("POST", ntfyEndpoint, true);
r.open("POST", endpoint, true);
r.setRequestHeader("Content-Type", "text/plain");
r.setRequestHeader("Click", click);
r.send(message);
}
// send Title & Attachment
function sendTitleAttach(title, message, attachment) {
function sendTitleAttach(endpoint, title, message, attachment) {
const r = new XMLHttpRequest();
r.open("POST", ntfyEndpoint, true);
r.open("POST", endpoint, true);
r.setRequestHeader("Content-Type", "text/plain");
r.setRequestHeader("Title", title);
r.setRequestHeader("Attach", attachment);
r.send(message);
}
// send Title & Click
function sendTitleClick(title, message, click) {
function sendTitleClick(endpoint, title, message, click) {
const r = new XMLHttpRequest();
r.open("POST", ntfyEndpoint, true);
r.open("POST", endpoint, true);
r.setRequestHeader("Content-Type", "text/plain");
r.setRequestHeader("Title", title);
r.setRequestHeader("Click", click);
r.send(message);
}
// send Attach & Click
function sendAttachClick(message, attachment, click) {
function sendAttachClick(endpoint, message, attachment, click) {
const r = new XMLHttpRequest();
r.open("POST", ntfyEndpoint, true);
r.open("POST", endpoint, true);
r.setRequestHeader("Content-Type", "text/plain");
r.setRequestHeader("Attach", attachment);
r.setRequestHeader("Click", click);
@ -282,33 +282,33 @@ function sendNotification() {
}
// attachment only
if (!titleEnabled && attachmentEnabled && !clickEnabled) {
sendAttach(ntfyMessage.value, ntfyAttach.value);
sendAttach(ntfyEndpoint, ntfyMessage.value, ntfyAttach.value);
ntfyMessage.value = "";
ntfyAttach.value = "";
}
// click only
if (!titleEnabled && !attachmentEnabled && clickEnabled) {
sendClick(ntfyMessage.value, ntfyClickAction.value);
sendClick(ntfyEndpoint, ntfyMessage.value, ntfyClickAction.value);
ntfyMessage.value = "";
ntfyClickAction.value = "";
}
// title & attachment
if (titleEnabled && attachmentEnabled && !clickEnabled) {
sendTitleAttach(ntfyTitle.value, ntfyMessage.value, ntfyAttach.value);
sendTitleAttach(ntfyEndpoint, ntfyTitle.value, ntfyMessage.value, ntfyAttach.value);
ntfyTitle.value = "";
ntfyMessage.value = "";
ntfyAttach.value = "";
}
// title & click
if (titleEnabled && !attachmentEnabled && clickEnabled) {
sendTitleClick(ntfyTitle.value, ntfyMessage.value, ntfyClickAction.value);
sendTitleClick(ntfyEndpoint, ntfyTitle.value, ntfyMessage.value, ntfyClickAction.value);
ntfyTitle.value = "";
ntfyMessage.value = "";
ntfyClickAction.value = "";
}
// attachment & click
if (!titleEnabled && attachmentEnabled && clickEnabled) {
sendAttachClick(ntfyMessage.value, ntfyAttach.value, ntfyClickAction.value);
sendAttachClick(ntfyEndpoint, ntfyMessage.value, ntfyAttach.value, ntfyClickAction.value);
ntfyAttach.value = "";
ntfyMessage.value = "";
ntfyClickAction.value = "";
@ -316,6 +316,7 @@ function sendNotification() {
// all three
if (titleEnabled && attachmentEnabled && clickEnabled) {
sendAll(
ntfyEndpoint,
ntfyTitle.value,
ntfyMessage.value,
ntfyAttach.value,