Anton Shestakov <av6@dwimlabs.net>, Mon, 21 Mar 2016 19:50:21 +0800
index: disconnect button
coffee/index.coffee
Permissions: -rw-r--r--
window.X = new Tram.XMPPInterface() $('[data-msg^="a/"]').addClass('uk-hidden') $('[data-msg="a/fail"]').removeClass('uk-hidden') $('[data-step="login"]').removeClass('uk-hidden') $('[data-step="main"]').addClass('uk-hidden') X.on 'connected attached', -> $('[data-step="login"]').addClass('uk-hidden') $('[data-step="main"]').removeClass('uk-hidden') $('button[data-disconnect]').on 'click', -> X.disconnect('Logged out') $form = $('[data-form="connect"]') $form.find('input').on 'keydown', (e) -> if (not @required or @value isnt '') and e.keyCode is 13 index = $form.find('input').index(@) $next = $form.find('input').eq(index + 1) $form.find('button').trigger('click') $form.find('button').on 'click', (e) -> Tram.validation.unsetError($('#username, #password')) ok &= Tram.validation.validateRequired($('#username'), true) ok &= Tram.validation.validateRequired($('#password')) X.connect($('#username').val().trim(), $('#password').val())