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();
|
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 message = document.getElementById("ntfy-message").value;
|
||||||
const el = document.getElementById("ntfy-char-count");
|
const el = document.getElementById("ntfy-char-count");
|
||||||
|
|
||||||
|
@ -354,7 +371,7 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
on:input={updateCharCount}
|
on:input={updateNtfyCharCount}
|
||||||
type="text"
|
type="text"
|
||||||
id="ntfy-message"
|
id="ntfy-message"
|
||||||
name="ntfy-message"
|
name="ntfy-message"
|
||||||
|
@ -366,27 +383,7 @@
|
||||||
128
|
128
|
||||||
</label>
|
</label>
|
||||||
<br />
|
<br />
|
||||||
<button
|
<button on:click={sendNtfyMessage} style="margin-top: 1rem;"> Send </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>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
Loading…
Reference in a new issue