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();
32 stage: "login", //or "register"
35 // https://laracasts.com/discuss/channels/vue/vuejs-set-focus-on-textfield
36 this.$refs
.userEmail
.focus();
39 toggleStage: function(stage
) {
40 let $form
= $("#form");
41 $form
.fadeOut(animationDuration
);
45 }, animationDuration
);
48 if (this.stage
=="register")
50 if (Date
.now() - enterTime
< 5000)
53 let error
= Validator
.checkObject({email: this.user
.email
}, "User");
54 if (!error
&& this.stage
== "register")
55 error
= Validator
.checkObject({forename: this.user
.forename
, name: this.user
.name
}, "User");
56 let $dialog
= $("#dialog");
58 setTimeout(() => {hide($dialog
);}, 3000);
60 return showMsg($dialog
, "error", error
);
61 showMsg($dialog
, "process", "Processing... Please wait");
62 $.ajax(ajaxUrl
[this.stage
],
67 email: encodeURIComponent(this.user
.email
),
68 forename: encodeURIComponent(this.user
.forename
), //may be unused
69 name: encodeURIComponent(this.user
.name
), //may be unused
75 this.user
["forename"] = "";
76 this.user
["name"] = "";
77 this.user
["email"] = "";
78 showMsg($dialog
, "info", infos
[this.stage
]);
81 showMsg($dialog
, "error", res
.errmsg
);