From 758afd5feefbf3a76f5c6abe8bff8c08f39dd7cc Mon Sep 17 00:00:00 2001 From: adam Date: Thu, 28 Jan 2021 19:05:24 +0200 Subject: restructuring stuff --- js/arrows.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 js/arrows.js (limited to 'js') diff --git a/js/arrows.js b/js/arrows.js new file mode 100644 index 0000000..a23af87 --- /dev/null +++ b/js/arrows.js @@ -0,0 +1,37 @@ + +arrows = []; + +const minSpeed = 3; +const maxSpeed = 8; +const delay = 1500; +const lifetime = 25000; + +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.remove(ob); + }, 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(); -- cgit v1.2.3 From 5d3d901d968db7eb3da9c038e6d823f7c75f1e10 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 29 Jan 2021 02:16:01 +0200 Subject: some cosmetic stuff --- js/arrows.js | 2 +- js/validate_hero.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 js/validate_hero.js (limited to 'js') diff --git a/js/arrows.js b/js/arrows.js index a23af87..ec7352c 100644 --- a/js/arrows.js +++ b/js/arrows.js @@ -4,7 +4,7 @@ arrows = []; const minSpeed = 3; const maxSpeed = 8; const delay = 1500; -const lifetime = 25000; +const lifetime = 20000; function make_arrow() { const svg = document.getElementById("protoarrow").cloneNode(); diff --git a/js/validate_hero.js b/js/validate_hero.js new file mode 100644 index 0000000..118abbf --- /dev/null +++ b/js/validate_hero.js @@ -0,0 +1,43 @@ + +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_form() +{ + var username=document.forms["hero_form"]["username"].value; + var email=document.forms["hero_form"]["email"].value; + var password=document.forms["hero_form"]["password"].value; + var password2=document.forms["hero_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 !== password2) + { + document.getElementById("password-error").hidden=false; + flag=false; + } + + if(flag) + { + document.getElementById("success").hidden=false; + } + return flag; + +} -- cgit v1.2.3 From 472e170f408e3d8d1db2eb066d445153aad55d73 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 29 Jan 2021 03:26:28 +0200 Subject: register and login looks ok --- js/arrows.js | 2 +- js/validate_hero.js | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'js') diff --git a/js/arrows.js b/js/arrows.js index ec7352c..10ad416 100644 --- a/js/arrows.js +++ b/js/arrows.js @@ -20,7 +20,7 @@ function make_arrow() { setTimeout(make_arrow, delay); setTimeout(() => { svg.remove(); - arrows.remove(ob); + arrows.shift(); }, lifetime); } diff --git a/js/validate_hero.js b/js/validate_hero.js index 118abbf..6d29a53 100644 --- a/js/validate_hero.js +++ b/js/validate_hero.js @@ -8,6 +8,20 @@ function clear_hero_errors() errors[i].hidden = true; } } +function validate_hero_login_form() +{ + var username=document.forms["hero_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["hero_form"]["username"].value; @@ -28,16 +42,17 @@ function validate_hero_form() document.getElementById("email-error").hidden=false; flag=false; } - if(password !== password2) + if(password.length==0) { - document.getElementById("password-error").hidden=false; + document.getElementById("password-length-error").hidden=false; flag=false; } - - if(flag) + if(password !== password2) { - document.getElementById("success").hidden=false; + document.getElementById("password-match-error").hidden=false; + flag=false; } + document.activeElement.blur(); return flag; } -- cgit v1.2.3