X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FContactForm.vue;h=cadbf73d10e42370274312fce3e24827c5a76d6f;hb=725da57f8e2983d744629b524f9084516a43cbac;hp=61796bfa73fb694d30e4c2891159ef306e997f78;hpb=89021f181ac0689bbc785ce0ebd9a910e66352b0;p=vchess.git diff --git a/client/src/components/ContactForm.vue b/client/src/components/ContactForm.vue index 61796bfa..cadbf73d 100644 --- a/client/src/components/ContactForm.vue +++ b/client/src/components/ContactForm.vue @@ -1,18 +1,23 @@ @@ -27,13 +32,12 @@ export default { return { enterTime: Number.MAX_SAFE_INTEGER, //for a basic anti-bot strategy st: store.state, - infoMsg: "", + infoMsg: "" }; }, methods: { trySetEnterTime: function(event) { - if (!!event.target.checked) - { + if (event.target.checked) { this.enterTime = Date.now(); this.infoMsg = ""; } @@ -41,19 +45,22 @@ export default { trySendMessage: function() { // Basic anti-bot strategy: const exitTime = Date.now(); - if (exitTime - this.enterTime < 5000) - return; + if (exitTime - this.enterTime < 5000) return; let email = document.getElementById("userEmail"); let subject = document.getElementById("mailSubject"); let content = document.getElementById("mailContent"); - const error = checkNameEmail({email: email}); - if (!!error) - return alert(error); - if (content.value.trim().length == 0) - return alert(this.st.tr["Empty message"]); - if (subject.value.trim().length == 0 && !confirm(this.st.tr["No subject. Send anyway?"])) + let error = checkNameEmail({ email: email }); + if (!error && content.value.trim().length == 0) + error = this.st.tr["Empty message"]; + if (error) { + alert(error); + return; + } + if ( + subject.value.trim().length == 0 && + !confirm(this.st.tr["No subject. Send anyway?"]) + ) return; - // Message sending: ajax( "/messages", @@ -61,7 +68,7 @@ export default { { email: email.value, subject: subject.value, - content: content.value, + content: content.value }, () => { this.infoMsg = "Email sent!"; @@ -69,8 +76,8 @@ export default { content.value = ""; } ); - }, - }, + } + } }; @@ -78,9 +85,11 @@ export default { [type="checkbox"].modal+div .card max-width: 767px max-height: 100% + textarea#mailContent width: 100% min-height: 100px + #dialog padding: 5px color: blue