From 0a88e950d6348414227860b3598a4d59263d7db6 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Mon, 6 Aug 2018 03:59:36 +0000 Subject: [PATCH] Implement a guest login button, initially hidden --- webapp/titanembeds/static/css/embed.css | 4 +++ webapp/titanembeds/static/js/embed.js | 32 ++++++++++++++-------- webapp/titanembeds/templates/embed.html.j2 | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/webapp/titanembeds/static/css/embed.css b/webapp/titanembeds/static/css/embed.css index ef92006..4904c11 100644 --- a/webapp/titanembeds/static/css/embed.css +++ b/webapp/titanembeds/static/css/embed.css @@ -446,6 +446,10 @@ a { max-width: 100%; } +#guestlogin_btn { + display: none; +} + #modal_invite_btn { padding: 0 1em; } diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index 4263d7f..46023bc 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -1489,20 +1489,28 @@ $("#custom_username_field").keyup(function(event){ if (event.keyCode == 13) { - if (!(new RegExp(/^[a-z\d\-_\s]+$/i).test($(this).val()))) { - Materialize.toast('Illegal username provided! Only alphanumeric, spaces, dashes, and underscores allowed in usernames.', 10000); - return; - } - if($(this).val().length >= 2 && $(this).val().length <= 32) { - $("#custom_username_field").blur(); - if (unauth_captcha_enabled) { - $('#recaptchamodal').modal('open'); - } else { - submit_unauthenticated_captcha(); - } - } + do_guest_login(); } }); + + $("#guestlogin_btn").click(function () { + do_guest_login(); + }); + + function do_guest_login() { + if (!(new RegExp(/^[a-z\d\-_\s]+$/i).test($("#custom_username_field").val()))) { + Materialize.toast('Illegal username provided! Only alphanumeric, spaces, dashes, and underscores allowed in usernames.', 10000); + return; + } + if($("#custom_username_field").val().length >= 2 && $("#custom_username_field").val().length <= 32) { + $("#custom_username_field").blur(); + if (unauth_captcha_enabled) { + $('#recaptchamodal').modal('open'); + } else { + submit_unauthenticated_captcha(); + } + } + } $("#submit-unauthenticated-captcha-btn").click(function(){ lock_login_fields(); diff --git a/webapp/titanembeds/templates/embed.html.j2 b/webapp/titanembeds/templates/embed.html.j2 index 246be67..b7ff2a0 100644 --- a/webapp/titanembeds/templates/embed.html.j2 +++ b/webapp/titanembeds/templates/embed.html.j2 @@ -149,6 +149,7 @@

{{ _("Of course, you also have the option to login by picking a temporary username for your current browsing session.") }}

+ Guest Login {% endif %}