From 19a1f628cadf9a1ac9b1da960a63c2a13b5fc8af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Sun, 16 Dec 2018 02:38:43 +0100 Subject: [PATCH] uname, password -> login, password (breaks socket) --- src/index.coffee | 39 ++++++++++++++++++++++----------------- views/index.pug | 8 ++++---- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/index.coffee b/src/index.coffee index 802e517..ee9d349 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -9,13 +9,25 @@ $ -> # style sheet require './style/custom.scss' - # init Socket.IO - socket = io() + # # init Socket.IO + # socket = io() + + # reset forms + $('form').each -> + that = @ + @fullReset = -> + $('input', that).each -> + $(that).removeClass 'is-invalid' + $(that).removeClass 'is-valid' + that.reset() # login form $('form[name="login"]').submit -> + # inhibit normal form submission + event.preventDefault() + # gather form data - uname = $('input[name="uname"]', @) + login = $('input[name="login"]', @) password = $('input[name="password"]', @) # transmit form data @@ -23,14 +35,15 @@ $ -> console.log 'emitted "login", "%s", "%s"', uname.val(), password.val() # reset form - @reset() - # inhibit actual submission - false + @fullReset() # register form - $('form[name="register"]').submit -> + $('form[name="register"]').submit (event) -> + # inhibit normal form submission + event.preventDefault() + # gather form data - uname = $('input[name="uname"]', @) + login = $('input[name="login"]', @) password = $('input[name="password"]', @) confirm = $('input[name="confirm"]', @) @@ -42,17 +55,9 @@ $ -> console.log 'emitted "register", "%s", "%s"', uname.val(), password.val() # reset form - $('input', @).each -> - $(@).removeClass 'is-invalid' - $(@).removeClass 'is-valid' - return - - @reset() + @fullReset() else confirm.val '' confirm.addClass 'is-invalid' confirm.focus() - - # inhibit actual submission - false diff --git a/views/index.pug b/views/index.pug index bee41f7..9c15eeb 100644 --- a/views/index.pug +++ b/views/index.pug @@ -23,8 +23,8 @@ html h3 Login form(name="login") div.form-group - label(for="uname") User name: - input.form-control(name="uname" required) + label(for="login") User name: + input.form-control(name="login" required) div.form-group label(for="password") Password: @@ -37,8 +37,8 @@ html h3 Register form(name="register") div.form-group - label(for="uname") User name: - input.form-control(name="uname" required) + label(for="login") User name: + input.form-control(name="login" required) div.invalid-feedback User name not available. div.form-group