Use named function to submit ntfy message
This commit is contained in:
parent
697dfdab18
commit
6e6db6d109
1 changed files with 20 additions and 23 deletions
|
@ -5,7 +5,24 @@
|
|||
|
||||
const pages = getPages();
|
||||
|
||||
function updateCharCount(_) {
|
||||
function sendNtfyMessage() {
|
||||
const message = document.getElementById("ntfy-message").value;
|
||||
if (message.length < 15)
|
||||
return alert(
|
||||
`Message must be 15 to 128 characters. Current length is ${message.length}`,
|
||||
);
|
||||
fetch("https://ntfy.meow.company/pancakes", {
|
||||
method: "POST",
|
||||
body: message,
|
||||
headers: {
|
||||
Title: "pancakes.gay",
|
||||
Priority: "min",
|
||||
Tags: "black_cat",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function updateNtfyCharCount(_) {
|
||||
const message = document.getElementById("ntfy-message").value;
|
||||
const el = document.getElementById("ntfy-char-count");
|
||||
|
||||
|
@ -354,7 +371,7 @@
|
|||
</p>
|
||||
|
||||
<input
|
||||
on:input={updateCharCount}
|
||||
on:input={updateNtfyCharCount}
|
||||
type="text"
|
||||
id="ntfy-message"
|
||||
name="ntfy-message"
|
||||
|
@ -366,27 +383,7 @@
|
|||
128
|
||||
</label>
|
||||
<br />
|
||||
<button
|
||||
on:click={() => {
|
||||
const message = document.getElementById("ntfy-message").value;
|
||||
if (message.length < 15)
|
||||
return alert(
|
||||
`Message must be 15 to 128 characters. Current length is ${message.length}`,
|
||||
);
|
||||
fetch("https://ntfy.meow.company/pancakes", {
|
||||
method: "POST",
|
||||
body: message,
|
||||
headers: {
|
||||
Title: "pancakes.gay",
|
||||
Priority: "min",
|
||||
Tags: "black_cat",
|
||||
},
|
||||
});
|
||||
}}
|
||||
style="margin-top: 1rem;"
|
||||
>
|
||||
Send
|
||||
</button>
|
||||
<button on:click={sendNtfyMessage} style="margin-top: 1rem;"> Send </button>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
|
|
Loading…
Reference in a new issue