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";
30 name: "my-contact-form",
33 enterTime: Number.MAX_SAFE_INTEGER, //for a basic anti-bot strategy
39 trySetEnterTime: function(event) {
40 if (event.target.checked) {
41 this.enterTime = Date.now();
45 trySendMessage: function() {
46 // Basic anti-bot strategy:
47 const exitTime = Date.now();
48 if (exitTime - this.enterTime < 5000) return;
49 let email = document.getElementById("userEmail");
50 let subject = document.getElementById("mailSubject");
51 let content = document.getElementById("mailContent");
52 let error = checkNameEmail({ email: email });
53 if (!error && content.value.trim().length == 0)
54 error = this.st.tr["Empty message"];
60 subject.value.trim().length == 0 &&
61 !confirm(this.st.tr["No subject. Send anyway?"])
70 subject: subject.value,
71 content: content.value
74 this.infoMsg = "Email sent!";
84 <style lang="sass" scoped>
85 [type="checkbox"].modal+div .card