3 input#modalContact.modal(
5 @change="trySetEnterTime($event)"
9 data-checkbox="modalContact"
12 label.modal-close(for="modalContact")
13 form(@submit.prevent="trySendMessage()" @keyup.enter="trySendMessage()")
15 label(for="userEmail") {{ st.tr["Email"] }}
16 input#userEmail(type="email")
18 label(for="mailSubject") {{ st.tr["Subject"] }}
19 input#mailSubject(type="text")
21 textarea#mailContent(:placeholder="st.tr['Your message']")
22 button(@click="trySendMessage()") {{ st.tr["Send"] }}
23 #dialog.text-center {{ st.tr[infoMsg] }}
27 import { ajax } from "../utils/ajax";
28 import { store } from "@/store";
29 import { checkNameEmail } from "@/data/userCheck";
31 name: "my-contact-form",
34 enterTime: Number.MAX_SAFE_INTEGER, //for a basic anti-bot strategy
40 trySetEnterTime: function(event) {
41 if (event.target.checked) {
42 this.enterTime = Date.now();
46 trySendMessage: function() {
47 // Basic anti-bot strategy:
48 const exitTime = Date.now();
49 if (exitTime - this.enterTime < 5000) return;
50 let email = document.getElementById("userEmail");
51 let subject = document.getElementById("mailSubject");
52 let content = document.getElementById("mailContent");
53 let error = checkNameEmail({ email: email });
54 if (!error && content.value.trim().length == 0)
55 error = this.st.tr["Empty message"];
61 subject.value.trim().length == 0 &&
62 !confirm(this.st.tr["No subject. Send anyway?"])
71 subject: subject.value,
72 content: content.value
75 this.infoMsg = "Email sent!";
85 <style lang="sass" scoped>
86 [type="checkbox"].modal+div .card