endpoint agnostic
This commit is contained in:
parent
dd38879204
commit
afdbc62f05
1 changed files with 20 additions and 19 deletions
|
@ -211,9 +211,9 @@ function sendNone(endpoint, message) {
|
||||||
r.send(message);
|
r.send(message);
|
||||||
}
|
}
|
||||||
// send all
|
// send all
|
||||||
function sendAll(title, message, attachment, click) {
|
function sendAll(endpoint, title, message, attachment, click) {
|
||||||
const r = new XMLHttpRequest();
|
const r = new XMLHttpRequest();
|
||||||
r.open("POST", ntfyEndpoint, true);
|
r.open("POST", endpoint, true);
|
||||||
r.setRequestHeader("Content-Type", "text/plain");
|
r.setRequestHeader("Content-Type", "text/plain");
|
||||||
r.setRequestHeader("Title", title);
|
r.setRequestHeader("Title", title);
|
||||||
r.setRequestHeader("Attach", attachment);
|
r.setRequestHeader("Attach", attachment);
|
||||||
|
@ -221,51 +221,51 @@ function sendAll(title, message, attachment, click) {
|
||||||
r.send(message);
|
r.send(message);
|
||||||
}
|
}
|
||||||
// send title only
|
// send title only
|
||||||
function sendTitle(title, message) {
|
function sendTitle(endpoint, title, message) {
|
||||||
const r = new XMLHttpRequest();
|
const r = new XMLHttpRequest();
|
||||||
r.open("POST", ntfyEndpoint, true);
|
r.open("POST", endpoint, true);
|
||||||
r.setRequestHeader("Content-Type", "text/plain");
|
r.setRequestHeader("Content-Type", "text/plain");
|
||||||
r.setRequestHeader("Title", title);
|
r.setRequestHeader("Title", title);
|
||||||
r.send(message);
|
r.send(message);
|
||||||
}
|
}
|
||||||
// send attachment only
|
// send attachment only
|
||||||
function sendAttach(message, attachment) {
|
function sendAttach(endpoint, message, attachment) {
|
||||||
const r = new XMLHttpRequest();
|
const r = new XMLHttpRequest();
|
||||||
r.open("POST", ntfyEndpoint, true);
|
r.open("POST", endpoint, true);
|
||||||
r.setRequestHeader("Content-Type", "text/plain");
|
r.setRequestHeader("Content-Type", "text/plain");
|
||||||
r.setRequestHeader("Attach", attachment);
|
r.setRequestHeader("Attach", attachment);
|
||||||
r.send(message);
|
r.send(message);
|
||||||
}
|
}
|
||||||
// send click only
|
// send click only
|
||||||
function sendClick(message, click) {
|
function sendClick(endpoint, message, click) {
|
||||||
const r = new XMLHttpRequest();
|
const r = new XMLHttpRequest();
|
||||||
r.open("POST", ntfyEndpoint, true);
|
r.open("POST", endpoint, true);
|
||||||
r.setRequestHeader("Content-Type", "text/plain");
|
r.setRequestHeader("Content-Type", "text/plain");
|
||||||
r.setRequestHeader("Click", click);
|
r.setRequestHeader("Click", click);
|
||||||
r.send(message);
|
r.send(message);
|
||||||
}
|
}
|
||||||
// send Title & Attachment
|
// send Title & Attachment
|
||||||
function sendTitleAttach(title, message, attachment) {
|
function sendTitleAttach(endpoint, title, message, attachment) {
|
||||||
const r = new XMLHttpRequest();
|
const r = new XMLHttpRequest();
|
||||||
r.open("POST", ntfyEndpoint, true);
|
r.open("POST", endpoint, true);
|
||||||
r.setRequestHeader("Content-Type", "text/plain");
|
r.setRequestHeader("Content-Type", "text/plain");
|
||||||
r.setRequestHeader("Title", title);
|
r.setRequestHeader("Title", title);
|
||||||
r.setRequestHeader("Attach", attachment);
|
r.setRequestHeader("Attach", attachment);
|
||||||
r.send(message);
|
r.send(message);
|
||||||
}
|
}
|
||||||
// send Title & Click
|
// send Title & Click
|
||||||
function sendTitleClick(title, message, click) {
|
function sendTitleClick(endpoint, title, message, click) {
|
||||||
const r = new XMLHttpRequest();
|
const r = new XMLHttpRequest();
|
||||||
r.open("POST", ntfyEndpoint, true);
|
r.open("POST", endpoint, true);
|
||||||
r.setRequestHeader("Content-Type", "text/plain");
|
r.setRequestHeader("Content-Type", "text/plain");
|
||||||
r.setRequestHeader("Title", title);
|
r.setRequestHeader("Title", title);
|
||||||
r.setRequestHeader("Click", click);
|
r.setRequestHeader("Click", click);
|
||||||
r.send(message);
|
r.send(message);
|
||||||
}
|
}
|
||||||
// send Attach & Click
|
// send Attach & Click
|
||||||
function sendAttachClick(message, attachment, click) {
|
function sendAttachClick(endpoint, message, attachment, click) {
|
||||||
const r = new XMLHttpRequest();
|
const r = new XMLHttpRequest();
|
||||||
r.open("POST", ntfyEndpoint, true);
|
r.open("POST", endpoint, true);
|
||||||
r.setRequestHeader("Content-Type", "text/plain");
|
r.setRequestHeader("Content-Type", "text/plain");
|
||||||
r.setRequestHeader("Attach", attachment);
|
r.setRequestHeader("Attach", attachment);
|
||||||
r.setRequestHeader("Click", click);
|
r.setRequestHeader("Click", click);
|
||||||
|
@ -282,33 +282,33 @@ function sendNotification() {
|
||||||
}
|
}
|
||||||
// attachment only
|
// attachment only
|
||||||
if (!titleEnabled && attachmentEnabled && !clickEnabled) {
|
if (!titleEnabled && attachmentEnabled && !clickEnabled) {
|
||||||
sendAttach(ntfyMessage.value, ntfyAttach.value);
|
sendAttach(ntfyEndpoint, ntfyMessage.value, ntfyAttach.value);
|
||||||
ntfyMessage.value = "";
|
ntfyMessage.value = "";
|
||||||
ntfyAttach.value = "";
|
ntfyAttach.value = "";
|
||||||
}
|
}
|
||||||
// click only
|
// click only
|
||||||
if (!titleEnabled && !attachmentEnabled && clickEnabled) {
|
if (!titleEnabled && !attachmentEnabled && clickEnabled) {
|
||||||
sendClick(ntfyMessage.value, ntfyClickAction.value);
|
sendClick(ntfyEndpoint, ntfyMessage.value, ntfyClickAction.value);
|
||||||
ntfyMessage.value = "";
|
ntfyMessage.value = "";
|
||||||
ntfyClickAction.value = "";
|
ntfyClickAction.value = "";
|
||||||
}
|
}
|
||||||
// title & attachment
|
// title & attachment
|
||||||
if (titleEnabled && attachmentEnabled && !clickEnabled) {
|
if (titleEnabled && attachmentEnabled && !clickEnabled) {
|
||||||
sendTitleAttach(ntfyTitle.value, ntfyMessage.value, ntfyAttach.value);
|
sendTitleAttach(ntfyEndpoint, ntfyTitle.value, ntfyMessage.value, ntfyAttach.value);
|
||||||
ntfyTitle.value = "";
|
ntfyTitle.value = "";
|
||||||
ntfyMessage.value = "";
|
ntfyMessage.value = "";
|
||||||
ntfyAttach.value = "";
|
ntfyAttach.value = "";
|
||||||
}
|
}
|
||||||
// title & click
|
// title & click
|
||||||
if (titleEnabled && !attachmentEnabled && clickEnabled) {
|
if (titleEnabled && !attachmentEnabled && clickEnabled) {
|
||||||
sendTitleClick(ntfyTitle.value, ntfyMessage.value, ntfyClickAction.value);
|
sendTitleClick(ntfyEndpoint, ntfyTitle.value, ntfyMessage.value, ntfyClickAction.value);
|
||||||
ntfyTitle.value = "";
|
ntfyTitle.value = "";
|
||||||
ntfyMessage.value = "";
|
ntfyMessage.value = "";
|
||||||
ntfyClickAction.value = "";
|
ntfyClickAction.value = "";
|
||||||
}
|
}
|
||||||
// attachment & click
|
// attachment & click
|
||||||
if (!titleEnabled && attachmentEnabled && clickEnabled) {
|
if (!titleEnabled && attachmentEnabled && clickEnabled) {
|
||||||
sendAttachClick(ntfyMessage.value, ntfyAttach.value, ntfyClickAction.value);
|
sendAttachClick(ntfyEndpoint, ntfyMessage.value, ntfyAttach.value, ntfyClickAction.value);
|
||||||
ntfyAttach.value = "";
|
ntfyAttach.value = "";
|
||||||
ntfyMessage.value = "";
|
ntfyMessage.value = "";
|
||||||
ntfyClickAction.value = "";
|
ntfyClickAction.value = "";
|
||||||
|
@ -316,6 +316,7 @@ function sendNotification() {
|
||||||
// all three
|
// all three
|
||||||
if (titleEnabled && attachmentEnabled && clickEnabled) {
|
if (titleEnabled && attachmentEnabled && clickEnabled) {
|
||||||
sendAll(
|
sendAll(
|
||||||
|
ntfyEndpoint,
|
||||||
ntfyTitle.value,
|
ntfyTitle.value,
|
||||||
ntfyMessage.value,
|
ntfyMessage.value,
|
||||||
ntfyAttach.value,
|
ntfyAttach.value,
|
||||||
|
|
Loading…
Reference in a new issue