uname, password -> login, password (breaks socket)

This commit is contained in:
Jörn-Michael Miehe 2018-12-16 02:38:43 +01:00
parent d0f7de6208
commit 19a1f628ca
2 changed files with 26 additions and 21 deletions

View file

@ -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

View file

@ -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