8 "register": "/register",
17 "login": "Connection token sent. Check your emails!",
18 "register": "Registration complete! Please check your emails.",
21 const animationDuration
= 300; //in milliseconds
23 // Basic anti-bot measure: force at least N seconds between arrival on page, and register form validation:
24 const enterTime
= Date
.now();
34 stage: "login", //or "register"
37 // https://laracasts.com/discuss/channels/vue/vuejs-set-focus-on-textfield
38 this.$refs
.userEmail
.focus();
41 toggleStage: function(stage
) {
42 let $form
= $("#form");
43 $form
.fadeOut(animationDuration
);
47 }, animationDuration
);
50 if (this.stage
=="register")
52 if (Date
.now() - enterTime
< 5000)
55 let error
= Validator
.checkObject({email: this.user
.email
}, "User");
56 if (!error
&& this.stage
== "register")
57 error
= Validator
.checkObject({name: this.user
.name
}, "User");
58 let $dialog
= $("#dialog");
60 setTimeout(() => {hide($dialog
);}, 3000);
62 return showMsg($dialog
, "error", error
);
63 showMsg($dialog
, "process", "Processing... Please wait");
64 $.ajax(ajaxUrl
[this.stage
],
66 method: ajaxMethod
[this.stage
],
69 email: encodeURIComponent(this.user
.email
),
70 name: encodeURIComponent(this.user
.name
), //may be unused
76 this.user
["name"] = "";
77 this.user
["email"] = "";
78 showMsg($dialog
, "info", infos
[this.stage
]);
81 showMsg($dialog
, "error", res
.errmsg
);