3 input#modalContact.modal(
5 @change="trySetEnterTime($event)"
9 data-checkbox="modalContact"
12 label.modal-close(for="modalContact")
14 label(for="userEmail") {{ st.tr["Email"] }}
15 input#userEmail(type="email" :value="st.user.email")
17 label(for="mailSubject") {{ st.tr["Subject"] }}
18 input#mailSubject(type="text")
20 textarea#mailContent(:placeholder="st.tr['Your message']")
21 button(@click="trySendMessage()") {{ st.tr["Send"] }}
22 #dialog.text-center {{ st.tr[infoMsg] }}
26 import { ajax } from "@/utils/ajax";
27 import { store } from "@/store";
28 import { checkNameEmail } from "@/data/userCheck";
29 import { processModalClick } from "@/utils/modalClick.js";
31 name: "my-contact-form",
34 enterTime: Number.MAX_SAFE_INTEGER, //for a basic anti-bot strategy
40 document.getElementById("contactDiv")
41 .addEventListener("click", processModalClick);
44 trySetEnterTime: function(event) {
45 if (event.target.checked) {
46 this.enterTime = Date.now();
50 trySendMessage: function() {
51 // Basic anti-bot strategy:
52 const exitTime = Date.now();
53 if (exitTime - this.enterTime < 5000) return;
54 let email = document.getElementById("userEmail");
55 let subject = document.getElementById("mailSubject");
56 let content = document.getElementById("mailContent");
57 let error = checkNameEmail({ email: email });
58 if (!error && content.value.trim().length == 0)
59 error = this.st.tr["Empty message"];
65 subject.value.trim().length == 0 &&
66 !confirm(this.st.tr["No subject. Send anyway?"])
77 subject: subject.value,
78 content: content.value
81 this.infoMsg = "Email sent!";
92 <style lang="sass" scoped>
93 [type="checkbox"].modal+div .card