Anton Shestakov <av6@dwimlabs.net>, Fri, 15 Apr 2016 23:39:29 +0800
index: support receiving carbons (XEP-0280)
js/register.js
Permissions: -rw-r--r--
// Generated by CoffeeScript 1.10.0 var ProfileData, RegistrationData, cancelfn, registerfn, savefn, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; window.clientState = new Tram.ClientState(); window.progressApp = new Tram.ProgressApp({ el: $('[data-app="progress"]'), RegistrationData = (function(superClass) { extend(RegistrationData, superClass); function RegistrationData() { return RegistrationData.__super__.constructor.apply(this, arguments); RegistrationData.prototype.defaults = { RegistrationData.prototype.validate = function(attrs, options) { var ref, ref1, ref2, ref3, ref4; this.unset('username-errors'); this.unset('password1-errors'); this.unset('password2-errors'); if (((ref = attrs.username) != null ? ref : '').trim() === '') { this.set('username-errors', ['This field is required.']); if (((ref1 = attrs.password1) != null ? ref1 : '') === '') { this.set('password1-errors', ['This field is required.']); if (((ref2 = attrs.password1) != null ? ref2 : '') !== ((ref3 = attrs.password2) != null ? ref3 : '')) { this.set('password2-errors', ['Passwords must match.']); } else if (((ref4 = attrs.password2) != null ? ref4 : '') === '') { this.set('password2-errors', ['This field is required.']); return this.has('username-errors') || this.has('password1-errors') || this.has('password2-errors'); ProfileData = (function(superClass) { extend(ProfileData, superClass); return ProfileData.__super__.constructor.apply(this, arguments); ProfileData.prototype.defaults = { ProfileData.prototype.validate = function(attrs, options) { this.unset('avatar-errors'); file = $('#avatar').get(0).files[0]; if (file.type.match('image/.*') == null) { ae.push("File doesn't look like an image."); if (file.size > 64 * 1024) { ae.push('File is too big.'); this.set('avatar-errors', ae); return this.has('avatar-errors'); window.regData = new RegistrationData(); window.profileData = new ProfileData(); registerfn = function() { clientState.set('progress', 0); return X.register(regData.get('username').trim(), regData.get('password1')); var data, failcb, file, okcb, reader; if (!profileData.isValid()) { fullname: profileData.get('fullname').trim(), nickname: profileData.get('nickname').trim() clientState.set('progress', 100); $('[data-step="profile"]').addClass('uk-hidden'); return location.href = '/'; clientState.unset('progress'); console.warn('profile is NOT set!', arguments); return $('[data-msg="save-failed"]').removeClass('uk-hidden'); file = $('#avatar').get(0).files[0]; reader = new FileReader(); reader.onloadend = function() { clientState.set('progress', 0); return X.savevCard(data, okcb, failcb); return reader.readAsDataURL(file); clientState.set('progress', 0); return X.savevCard(data, okcb, failcb); window.regRivet = rivets.bind($('[data-form="registration"]'), { window.profileRivet = rivets.bind($('[data-form="profile"]'), { window.X = new Tram.XMPPInterface(); X.on('register', function() { return $('[data-step="registration"]').removeClass('uk-hidden'); X.on('registered', function() { return $('[data-step="registration"]').addClass('uk-hidden'); X.on('regifail', function() { return $('[data-msg="registration-closed"]').removeClass('uk-hidden'); X.on('conflict', function() { return regData.set('username-errors', ['A user with this username already exists.']); X.on('notacceptable', function() { return $('[data-msg="registration-failed"]').removeClass('uk-hidden'); X.on('connected', function() { profileData.set('nickname', regData.get('username').trim()); $('[data-step="profile"]').removeClass('uk-hidden'); return $('#fullname').focus(); X.on('disconnected', function() { return location.reload(); X.on('status', function(status) { case Strophe.Status.REGISTERED: return clientState.set('progress', 50); case Strophe.Status.CONNECTED: return clientState.set('progress', 100); return clientState.unset('progress'); $('[data-form="registration"], [data-form="profile"]').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'); //# sourceMappingURL=register.js.map