aboutsummaryrefslogtreecommitdiffstats
path: root/loginregister.js
diff options
context:
space:
mode:
authoradam <adam@>2021-02-11 19:43:06 +0200
committeradam <adam@>2021-02-11 19:43:06 +0200
commitd538c3041c6c7d05a9328ace960838aa194879d9 (patch)
tree0b070027c9e758ed1783012c43c58070b39595f5 /loginregister.js
parentd35678c131d4547cea8b3d9fcc1978dec0d2d903 (diff)
parentf1cd0085cd8dba8b25818fc998d315b28e6c13a5 (diff)
downloadfileup-d538c3041c6c7d05a9328ace960838aa194879d9.tar.gz
setting up
Diffstat (limited to 'loginregister.js')
-rw-r--r--loginregister.js101
1 files changed, 101 insertions, 0 deletions
diff --git a/loginregister.js b/loginregister.js
new file mode 100644
index 0000000..cb87444
--- /dev/null
+++ b/loginregister.js
@@ -0,0 +1,101 @@
+arrows = [];
+
+const minSpeed = 3;
+const maxSpeed = 8;
+const delay = 1500;
+const lifetime = 20000;
+
+function make_arrow() {
+ const svg = document.getElementById("protoarrow").cloneNode();
+ svg.style.left = Math.random() * 100 + '%';
+ svg.style.display = 'block';
+ document.getElementById('arrows').append(svg);
+ const ob = {
+ y: -800,
+ svg: svg,
+ speed: Math.random() * (maxSpeed - minSpeed) + minSpeed
+ };
+ arrows.push(ob);
+ setTimeout(make_arrow, delay);
+ setTimeout(() => {
+ svg.remove();
+ arrows.shift();
+ }, lifetime);
+}
+
+function update() {
+ for (const arrow of arrows) {
+ arrow.y += arrow.speed;
+ arrow.svg.style.bottom = arrow.y + 'px';
+ }
+
+ window.requestAnimationFrame(update);
+}
+
+make_arrow();
+update();
+
+
+
+
+function clear_hero_errors()
+{
+ let errors = document.getElementsByClassName("hero_form_error");
+ for (let i = 0; i < errors.length; i++)
+ {
+ errors[i].hidden = true;
+ }
+}
+function validate_hero_login_form()
+{
+ let username=document.forms["login_form"]["username"].value;
+ let flag=true;
+ clear_hero_errors();
+
+ if(username.length==0)
+ {
+ document.getElementById("username-length-error").hidden=false;
+ flag=false;
+ }
+ document.activeElement.blur();
+ return flag;
+}
+function validate_hero_form()
+{
+ let username=document.forms["register_form"]["username"].value;
+ let email=document.forms["register_form"]["email"].value;
+ let password=document.forms["register_form"]["password"].value;
+ let password2=document.forms["register_form"]["password2"].value;
+
+ let flag=true;
+ clear_hero_errors();
+
+ if(username.length==0)
+ {
+ document.getElementById("username-length-error").hidden=false;
+ flag=false;
+ }
+ if(!email.match(/\S+@\S+/))
+ {
+ document.getElementById("email-error").hidden=false;
+ flag=false;
+ }
+ if(password.length==0)
+ {
+ document.getElementById("password-length-error").hidden=false;
+ flag=false;
+ }
+ if(password !== password2)
+ {
+ document.getElementById("password-match-error").hidden=false;
+ flag=false;
+ }
+ document.activeElement.blur();
+ return flag;
+
+}
+
+function showLogin(l) {
+ document.getElementById("loginform").style.display = l ? "flex" : "none";
+ document.getElementById("signupform").style.display = l ? "none" : "flex";
+}