Anton Shestakov <av6@dwimlabs.net>, Sat, 19 Mar 2016 10:46:01 +0800
provision: service checks
js/register.js
Permissions: -rw-r--r--
// Generated by CoffeeScript 1.10.0 var conn, domain, onConnect, savevCard; domain = location.hostname; conn = new Strophe.Connection("https://" + location.host + "/http-bind"); 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:', conn.jid); return R.trigger('v/start'); case Strophe.Status.REGISTER: console.debug('Got registration prompt'); return R.trigger('r/start'); case Strophe.Status.REGISTERED: console.debug('Registered!'); return conn.authenticate(); case Strophe.Status.CONFLICT: console.debug('Contact already exists!'); return R.trigger('r/conflict'); case Strophe.Status.NOTACCEPTABLE: console.debug('Registration form not properly filled out.'); return R.trigger('r/failed'); case Strophe.Status.REGIFAIL: console.debug('The Server does not support In-Band Registration'); return R.trigger('r/closed'); savevCard = function(data) { var $vcard, b, bi, binval, bl, d, dl, failcb, okcb, type; $vcard.c('NICKNAME').t(data.nickname).up(); $vcard.c('FN').t(data.fullname).up(); bi = data.avatar.indexOf(b); type = data.avatar.substr(dl, bi - dl); binval = data.avatar.substr(bi + bl); $vcard.c('PHOTO').c('TYPE').t(type).up().c('BINVAL').t(binval); console.debug('vcard is set!', arguments); return R.trigger('v/done'); console.warn('vcard is NOT set!', arguments); return R.trigger('v/failed'); return conn.sendIQ($vcard.tree(), okcb, failcb); window.R = _.clone(Backbone.Events); register: function(username, password) { conn.register.fields.username = username; conn.register.fields.password = password; return conn.register.submit(); conn.register.connect(domain, onConnect); $('#register').on('click', function() { validation.unsetError($('#username, #password1, #password2')); ok &= validation.validateRequired($('#username'), true); ok &= validation.validatePasswords($('#password1'), $('#password2')); ok &= validation.validateRequired($('#password1')); ok &= validation.validateRequired($('#password2')); return R.register($('#username').val().trim(), $('#password1').val()); $('#save').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() R.on('r/start', function() { return $('[data-step="registration"]').removeClass('uk-hidden'); R.on('r/done', function() { return $('[data-step="registration"]').addClass('uk-hidden'); R.on('r/closed', function() { return $('[data-msg="r/closed"]').removeClass('uk-hidden'); R.on('r/conflict', function() { return validation.setError($('#username'), 'A user with this username already exists.'); R.on('r/failed', function() { return $('[data-msg="r/failed"]').removeClass('uk-hidden'); R.on('v/start', function() { $('#nickname').val($('#username').val()); return $('[data-step="vcard"]').removeClass('uk-hidden'); R.on('v/done', function() { $('[data-step="vcard"]').addClass('uk-hidden'); return location.href = '/'; R.on('v/failed', function() { return $('[data-msg="v/failed"]').removeClass('uk-hidden'); //# sourceMappingURL=register.js.map