aboutsummaryrefslogtreecommitdiffstats
path: root/loginregister.js
diff options
context:
space:
mode:
authorAlex Vitkov <alexvitkov98@gmail.com>2021-01-29 14:45:52 +0200
committerAlex Vitkov <alexvitkov98@gmail.com>2021-01-29 14:45:52 +0200
commit8ba2c35a306719932307ec5f99701101637e1fd2 (patch)
tree0492e0d614c8afe741c8160481526c73175d99cb /loginregister.js
parentf4d5d71da4f94bf9bc87505e745eed913c9858b9 (diff)
downloadfileup-8ba2c35a306719932307ec5f99701101637e1fd2.tar.gz
Menu bar, different .php pages for logged in/not logged in
Diffstat (limited to 'loginregister.js')
-rw-r--r--loginregister.js102
1 files changed, 102 insertions, 0 deletions
diff --git a/loginregister.js b/loginregister.js
new file mode 100644
index 0000000..f3b6f9a
--- /dev/null
+++ b/loginregister.js
@@ -0,0 +1,102 @@
+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()
+{
+ var errors = document.getElementsByClassName("hero_form_error");
+ var i;
+ for (i = 0; i < errors.length; i++)
+ {
+ errors[i].hidden = true;
+ }
+}
+function validate_hero_login_form()
+{
+ var username=document.forms["login_form"]["username"].value;
+ var 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()
+{
+ var username=document.forms["register_form"]["username"].value;
+ var email=document.forms["register_form"]["email"].value;
+ var password=document.forms["register_form"]["password"].value;
+ var password2=document.forms["register_form"]["password2"].value;
+
+ var 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";
+}