Anton Shestakov <av6@dwimlabs.net>, Sun, 20 Mar 2016 23:30:16 +0800
register: improve scripting, move XMPP interface to a separate file
js/register.js
Permissions: -rw-r--r--
// Generated by CoffeeScript 1.10.0 onConnect = function(status, error) { case Strophe.Status.CONNECTING: return console.debug('Strophe is connecting.'); case Strophe.Status.AUTHENTICATING: return console.debug('Strophe is authenticating.'); case Strophe.Status.AUTHFAIL: return console.debug('Strophe failed to authenticate:', error); case Strophe.Status.ERROR: return console.debug('Strophe received an error:', error); case Strophe.Status.CONNFAIL: return console.debug('Strophe failed to connect:', error); case Strophe.Status.DISCONNECTING: return console.debug('Strophe is disconnecting.'); case Strophe.Status.DISCONNECTED: return console.debug('Strophe is disconnected.'); case Strophe.Status.CONNECTED: console.debug('Strophe is connected.'); console.info('My jid:', X.conn.jid); return X.trigger('v/start'); case Strophe.Status.REGISTER: console.debug('Got registration prompt.'); return X.trigger('r/start'); case Strophe.Status.REGISTERED: console.debug('Registered!'); return X.conn.authenticate(); case Strophe.Status.CONFLICT: console.debug('Contact already exists!'); return X.trigger('r/conflict'); case Strophe.Status.NOTACCEPTABLE: console.debug('Registration form not properly filled out.'); return X.trigger('r/failed'); case Strophe.Status.REGIFAIL: console.debug('The server does not support In-Band Registration.'); return X.trigger('r/closed'); window.X = new Tram.XMPPInterface(); X.startRegistration(onConnect); $('[data-form="registration"], [data-form="vcard"]').each(function() { return $form.find('input').on('keydown', function(e) { if ((!this.required || this.value !== '') && e.keyCode === 13) { index = $form.find('input').index(this); $next = $form.find('input').eq(index + 1); if ($next.length !== 0) { return $form.find('button').trigger('click'); $('[data-form="registration"] button').on('click', function() { Tram.validation.unsetError($('#username, #password1, #password2')); ok &= Tram.validation.validateRequired($('#username'), true); ok &= Tram.validation.validatePasswords($('#password1'), $('#password2')); ok &= Tram.validation.validateRequired($('#password1')); ok &= Tram.validation.validateRequired($('#password2')); return X.register($('#username').val().trim(), $('#password1').val()); $('[data-form="vcard"] button').on('click', function() { file = $('#avatar').get(0).files[0]; reader = new FileReader(); reader.onloadend = function() { fullname: $('#fullname').val(), nickname: $('#nickname').val(), return reader.readAsDataURL(file); fullname: $('#fullname').val(), nickname: $('#nickname').val() X.on('r/start', function() { return $('[data-step="registration"]').removeClass('uk-hidden'); X.on('r/done', function() { return $('[data-step="registration"]').addClass('uk-hidden'); X.on('r/closed', function() { return $('[data-msg="r/closed"]').removeClass('uk-hidden'); X.on('r/conflict', function() { return Tram.validation.setError($('#username'), 'A user with this username already exists.'); X.on('r/failed', function() { return $('[data-msg="r/failed"]').removeClass('uk-hidden'); X.on('v/start', function() { $('#nickname').val($('#username').val()); $('[data-step="vcard"]').removeClass('uk-hidden'); return $('#fullname').focus(); X.on('v/done', function() { $('[data-step="vcard"]').addClass('uk-hidden'); return location.href = '/'; X.on('v/failed', function() { return $('[data-msg="v/failed"]').removeClass('uk-hidden'); //# sourceMappingURL=register.js.map