Commit | Line | Data |
---|---|---|
298c42e6 BA |
1 | // Note: not using Vue, but would be possible |
2 | function trySendMessage() | |
3 | { | |
4 | let email = document.getElementById("userEmail"); | |
5 | let subject = document.getElementById("mailSubject"); | |
6 | let content = document.getElementById("mailContent"); | |
7 | if (!email.value.match(/^[^@]+@[^@]+\.[^@]+$/)) | |
8 | return alert("Bad email"); | |
9 | if (content.value.trim().length == 0) | |
10 | return alert("Empty message"); | |
11 | if (subject.value.trim().length == 0 && !confirm("No subject. Send anyway?")) | |
12 | return; | |
13 | ||
14 | // Message sending: | |
15 | ajax( | |
16 | "/messages", | |
17 | "POST", | |
18 | { | |
19 | email: email.value, | |
20 | subject: subject.value, | |
21 | content: content.value, | |
22 | }, | |
23 | () => { | |
24 | subject.value = ""; | |
25 | content.value = ""; | |
26 | let emailSent = document.getElementById("emailSent"); | |
27 | emailSent.style.display = "inline-block"; | |
28 | setTimeout(() => { emailSent.style.display = "none"; }, 2000); | |
29 | } | |
30 | ); | |
31 | } |