# libs window.$ = require('jquery') # on load $ -> # style sheet require './style/custom.scss' # 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 (event) -> # inhibit normal form submission event.preventDefault() # gather form data login = $('input[name="login"]', @) password = $('input[name="password"]', @) # transmit form data $.post '/login', login: login.val() password: password.val() .done (data) -> alert "#{data.status}, #{data.uid}, #{data.text}" # reset form @fullReset() # registration form $('form[name="register"]').submit (event) -> # inhibit normal form submission event.preventDefault() # gather form data login = $('input[name="login"]', @) password = $('input[name="password"]', @) confirm = $('input[name="confirm"]', @) # check form data if password.val() == confirm.val() # transmit form data $.post '/register', login: login.val() password: password.val() .done (data) -> alert "#{data.status}, #{data.uid}, #{data.text}" # reset form @fullReset() else confirm.val '' confirm.addClass 'is-invalid' confirm.focus()