255:a3e0d54eef57
Anton Shestakov <av6@dwimlabs.net>, Sun, 04 Dec 2016 13:58:13 +0800
contacts: only count unread for the exact jid

next change 257:32ad4a9536af
previous change 247:fcca53a2f523

js/register.js

Permissions: -rw-r--r--

Other formats: Feeds:
// Generated by CoffeeScript 1.11.1
(function() {
var cancelfn, registerfn, savefn;
window.clientState = new Tram.ClientState();
window.progressApp = new Tram.ProgressApp({
el: $('[data-app="progress"]'),
model: clientState
});
window.regForm = new Tram.RegistrationForm();
window.profileForm = new Tram.ProfileForm();
registerfn = function() {
if (regForm.isValid()) {
clientState.set('progress', 0);
return X.register(regForm.get('username').trim(), regForm.get('password1'));
}
};
savefn = function() {
var data, failcb, file, okcb, reader;
if (!profileForm.isValid()) {
return;
}
data = {
fullname: profileForm.get('fullname').trim(),
nickname: profileForm.get('nickname').trim()
};
okcb = function() {
clientState.set('progress', 100);
$('[data-step="profile"]').addClass('uk-hidden');
return location.href = '/';
};
failcb = function() {
clientState.unset('progress');
console.warn('profile is NOT set!', arguments);
return $('[data-msg="save-failed"]').removeClass('uk-hidden');
};
file = $('#avatar').get(0).files[0];
if (file != null) {
reader = new FileReader();
reader.onloadend = function() {
_(data).extend({
avatar: reader.result
});
clientState.set('progress', 0);
return X.savevCard(data, okcb, failcb);
};
return reader.readAsDataURL(file);
} else {
clientState.set('progress', 0);
return X.savevCard(data, okcb, failcb);
}
};
cancelfn = function() {
return X.unregister();
};
window.regRivet = rivets.bind($('[data-form="registration"]'), {
form: regForm,
register: registerfn
});
window.profileRivet = rivets.bind($('[data-form="profile"]'), {
form: profileForm,
save: savefn,
cancel: cancelfn
});
window.X = new Tram.XMPPInterface();
X.on('register', function() {
return $('[data-step="registration"]').removeClass('uk-hidden');
});
X.on('registered', function() {
X.finishRegistration();
return $('[data-step="registration"]').addClass('uk-hidden');
});
X.on('regifail', function() {
return $('[data-msg="registration-closed"]').removeClass('uk-hidden');
});
X.on('conflict', function() {
return regForm.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() {
profileForm.set('nickname', regForm.get('username').trim());
$('[data-step="profile"]').removeClass('uk-hidden');
return $('#fullname').focus();
});
X.on('disconnected', function() {
return location.reload();
});
X.on('status', function(status) {
switch (status) {
case Strophe.Status.REGISTERED:
return clientState.set('progress', 50);
case Strophe.Status.CONNECTED:
return clientState.set('progress', 100);
default:
return clientState.unset('progress');
}
});
X.startRegistration();
$('[data-form="registration"], [data-form="profile"]').streamline();
}).call(this);
//# sourceMappingURL=register.js.map