1 window
.onload = function() {
10 "register": "/register",
14 "login": "Connection token sent. Check your emails!",
15 "register": "Registration complete! Please check your emails.",
18 const animationDuration
= 300; //in milliseconds
20 // Basic anti-bot measure: force at least N seconds between arrival on page, and register form validation:
21 const enterTime
= Date
.now();
31 stage: "login", //or "register"
34 // https://laracasts.com/discuss/channels/vue/vuejs-set-focus-on-textfield
35 this.$refs
.userEmail
.focus();
38 toggleStage: function(stage
) {
39 let $form
= $("#form");
40 $form
.fadeOut(animationDuration
);
44 }, animationDuration
);
47 if (this.stage
=="register")
49 if (Date
.now() - enterTime
< 5000)
52 let error
= Validator
.checkObject({email: this.user
.email
}, "User");
53 if (!error
&& this.stage
== "register")
54 error
= Validator
.checkObject({name: this.user
.name
}, "User");
55 let $dialog
= $("#dialog");
57 setTimeout(() => {hide($dialog
);}, 3000);
59 return showMsg($dialog
, "error", error
);
60 showMsg($dialog
, "process", "Processing... Please wait");
61 $.ajax(ajaxUrl
[this.stage
],
66 email: encodeURIComponent(this.user
.email
),
67 name: encodeURIComponent(this.user
.name
), //may be unused
73 this.user
["name"] = "";
74 this.user
["email"] = "";
75 showMsg($dialog
, "info", infos
[this.stage
]);
78 showMsg($dialog
, "error", res
.errmsg
);