--- a/coffee/register.coffee Sun Mar 20 11:53:21 2016 +0800
+++ b/coffee/register.coffee Sun Mar 20 23:30:16 2016 +0800
when Strophe.Status.CONNECTED
console.debug('Strophe is connected.')
- console.info('My jid:', conn.jid)
+ console.info('My jid:', X.conn.jid)
when Strophe.Status.REGISTER
- console.debug('Got registration prompt')
+ console.debug('Got registration prompt.')
when Strophe.Status.REGISTERED
console.debug('Registered!')
when Strophe.Status.CONFLICT
console.debug('Contact already exists!')
+ X.trigger('r/conflict')
when Strophe.Status.NOTACCEPTABLE
console.debug('Registration form not properly filled out.')
when Strophe.Status.REGIFAIL
- console.debug('The Server does not support In-Band Registration')
+ console.debug('The server does not support In-Band Registration.')
+window.X = new Tram.XMPPInterface()
+X.startRegistration(onConnect)
- $vcard = $iq(type: 'set').c('vCard', xmlns: Strophe.NS.VCARD)
- $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)
- .c('TYPE').t(type).up()
- console.debug('vcard is set!', arguments)
- console.warn('vcard is NOT set!', arguments)
- conn.sendIQ $vcard.tree(), okcb, failcb
+$('[data-form="registration"], [data-form="vcard"]').each ->
+ $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')
-window.R = _.clone Backbone.Events
- register: (username, password) ->
- conn.register.fields.username = username
- conn.register.fields.password = password
-conn = new Strophe.Connection "https://#{ Tram.config.host }/http-bind"
-conn.register.connect Tram.config.domain, onConnect
-$('#register').on 'click', ->
+$('[data-form="registration"] button').on 'click', ->
Tram.validation.unsetError($('#username, #password1, #password2'))
ok &= Tram.validation.validateRequired($('#username'), true)
ok &= Tram.validation.validateRequired($('#password1'))
ok &= Tram.validation.validateRequired($('#password2'))
- R.register $('#username').val().trim(), $('#password1').val()
+ X.register($('#username').val().trim(), $('#password1').val())
-$('#save').on 'click', ->
+$('[data-form="vcard"] button').on 'click', ->
file = $('#avatar').get(0).files[0]
reader = new FileReader()
fullname: $('#fullname').val()
nickname: $('#nickname').val()
reader.readAsDataURL(file)
fullname: $('#fullname').val()
nickname: $('#nickname').val()
- $('[data-step="registration"]').removeClass 'uk-hidden'
+ $('[data-step="registration"]').removeClass('uk-hidden')
- $('[data-step="registration"]').addClass 'uk-hidden'
+ $('[data-step="registration"]').addClass('uk-hidden')
- $('[data-msg="r/closed"]').removeClass 'uk-hidden'
+ $('[data-msg="r/closed"]').removeClass('uk-hidden')
- Tram.validation.setError $('#username'), 'A user with this username already exists.'
+ Tram.validation.setError($('#username'), 'A user with this username already exists.')
- $('[data-msg="r/failed"]').removeClass 'uk-hidden'
+ $('[data-msg="r/failed"]').removeClass('uk-hidden')
- $('#nickname').val $('#username').val()
- $('[data-step="vcard"]').removeClass 'uk-hidden'
+ $('#nickname').val($('#username').val())
+ $('[data-step="vcard"]').removeClass('uk-hidden')
- $('[data-step="vcard"]').addClass 'uk-hidden'
+ $('[data-step="vcard"]').addClass('uk-hidden')
- $('[data-msg="v/failed"]').removeClass 'uk-hidden'
+ $('[data-msg="v/failed"]').removeClass('uk-hidden')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/coffee/xmpp.coffee Sun Mar 20 23:30:16 2016 +0800
+class Tram.XMPPInterface
+ console.debug('connection exists, not reconnecting')
+ @conn = new Strophe.Connection("https://#{ Tram.config.host }/http-bind")
+ connect: (node, pass, onConnect) ->
+ jid = "#{ node }@#{ Tram.config.domain }"
+ @conn.connect(jid, pass, onConnect)
+ disconnect: (reason) ->
+ @conn.disconnect(reason)
+ startRegistration: (onConnect) ->
+ @conn.register.connect(Tram.config.domain, onConnect)
+ register: (username, password) ->
+ @conn.register.fields.username = username
+ @conn.register.fields.password = password
+ @conn.register.submit()
+ $vcard = $iq(type: 'set').c('vCard', xmlns: Strophe.NS.VCARD)
+ $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)
+ .c('TYPE').t(type).up()
+ console.debug('vcard is set!', arguments)
+ console.warn('vcard is NOT set!', arguments)
+ @conn.sendIQ($vcard.tree(), okcb, failcb)
+_(Tram.XMPPInterface.prototype).extend(Backbone.Events)
--- a/js/register.js Sun Mar 20 11:53:21 2016 +0800
+++ b/js/register.js Sun Mar 20 23:30:16 2016 +0800
// Generated by CoffeeScript 1.10.0
- var conn, onConnect, savevCard;
onConnect = function(status, error) {
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');
+ console.info('My jid:', X.conn.jid);
+ return X.trigger('v/start');
case Strophe.Status.REGISTER:
- console.debug('Got registration prompt');
- return R.trigger('r/start');
+ console.debug('Got registration prompt.');
+ return X.trigger('r/start');
case Strophe.Status.REGISTERED:
console.debug('Registered!');
- return conn.authenticate();
+ return X.conn.authenticate();
case Strophe.Status.CONFLICT:
console.debug('Contact already exists!');
- return R.trigger('r/conflict');
+ return X.trigger('r/conflict');
case Strophe.Status.NOTACCEPTABLE:
console.debug('Registration form not properly filled out.');
- return R.trigger('r/failed');
+ return X.trigger('r/failed');
case Strophe.Status.REGIFAIL:
- console.debug('The Server does not support In-Band Registration');
- return R.trigger('r/closed');
+ console.debug('The server does not support In-Band Registration.');
+ return X.trigger('r/closed');
- savevCard = function(data) {
- var $vcard, b, bi, binval, bl, d, dl, failcb, okcb, type;
- xmlns: Strophe.NS.VCARD
+ 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');
- $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 = new Strophe.Connection("https://" + Tram.config.host + "/http-bind");
- conn.register.connect(Tram.config.domain, onConnect);
- $('#register').on('click', function() {
+ $('[data-form="registration"] button').on('click', function() {
Tram.validation.unsetError($('#username, #password1, #password2'));
ok &= Tram.validation.validateRequired($('#password1'));
ok &= Tram.validation.validateRequired($('#password2'));
- return R.register($('#username').val().trim(), $('#password1').val());
+ return X.register($('#username').val().trim(), $('#password1').val());
- $('#save').on('click', function() {
+ $('[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()
- R.on('r/start', function() {
+ X.on('r/start', function() {
return $('[data-step="registration"]').removeClass('uk-hidden');
- R.on('r/done', function() {
+ X.on('r/done', function() {
return $('[data-step="registration"]').addClass('uk-hidden');
- R.on('r/closed', function() {
+ X.on('r/closed', function() {
return $('[data-msg="r/closed"]').removeClass('uk-hidden');
- R.on('r/conflict', function() {
+ X.on('r/conflict', function() {
return Tram.validation.setError($('#username'), 'A user with this username already exists.');
- R.on('r/failed', function() {
+ X.on('r/failed', function() {
return $('[data-msg="r/failed"]').removeClass('uk-hidden');
- R.on('v/start', function() {
+ X.on('v/start', function() {
$('#nickname').val($('#username').val());
- return $('[data-step="vcard"]').removeClass('uk-hidden');
+ $('[data-step="vcard"]').removeClass('uk-hidden');
+ return $('#fullname').focus();
- R.on('v/done', function() {
+ X.on('v/done', function() {
$('[data-step="vcard"]').addClass('uk-hidden');
return location.href = '/';
- R.on('v/failed', function() {
+ X.on('v/failed', function() {
return $('[data-msg="v/failed"]').removeClass('uk-hidden');
--- a/js/register.js.map Sun Mar 20 11:53:21 2016 +0800
+++ b/js/register.js.map Sun Mar 20 23:30:16 2016 +0800
- "mappings": ";AAAA;AAAA,MAAA;;EAAA,SAAA,GAAY,SAAC,MAAD,EAAS,KAAT;AACV,YAAO,MAAP;AAAA,WACO,OAAO,CAAC,MAAM,CAAC,UADtB;eAEI,OAAO,CAAC,KAAR,CAAc,wBAAd;AAFJ,WAIO,OAAO,CAAC,MAAM,CAAC,cAJtB;eAKI,OAAO,CAAC,KAAR,CAAc,4BAAd;AALJ,WAOO,OAAO,CAAC,MAAM,CAAC,QAPtB;eAQI,OAAO,CAAC,KAAR,CAAc,iCAAd,EAAiD,KAAjD;AARJ,WAUO,OAAO,CAAC,MAAM,CAAC,KAVtB;eAWI,OAAO,CAAC,KAAR,CAAc,4BAAd,EAA4C,KAA5C;AAXJ,WAaO,OAAO,CAAC,MAAM,CAAC,QAbtB;eAcI,OAAO,CAAC,KAAR,CAAc,4BAAd,EAA4C,KAA5C;AAdJ,WAgBO,OAAO,CAAC,MAAM,CAAC,aAhBtB;eAiBI,OAAO,CAAC,KAAR,CAAc,2BAAd;AAjBJ,WAmBO,OAAO,CAAC,MAAM,CAAC,YAnBtB;eAoBI,OAAO,CAAC,KAAR,CAAc,0BAAd;AApBJ,WAsBO,OAAO,CAAC,MAAM,CAAC,SAtBtB;QAuBI,OAAO,CAAC,KAAR,CAAc,uBAAd;QACA,OAAO,CAAC,IAAR,CAAa,SAAb,EAAwB,IAAI,CAAC,GAA7B;eACA,CAAC,CAAC,OAAF,CAAU,SAAV;AAzBJ,WA2BO,OAAO,CAA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E,WAAF,CAAc,CAAC,KAAf,CAAA;EAHc,CAAhB;;EAMA,CAAC,CAAC,EAAF,CAAK,QAAL,EAAe,SAAA;IACb,CAAA,CAAE,qBAAF,CAAwB,CAAC,QAAzB,CAAkC,WAAlC;WACA,QAAQ,CAAC,IAAT,GAAgB;EAFH,CAAf;;EAKA,CAAC,CAAC,EAAF,CAAK,UAAL,EAAiB,SAAA;WACf,CAAA,CAAE,uBAAF,CAA0B,CAAC,WAA3B,CAAuC,WAAvC;EADe,CAAjB;AAhIA"
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/js/xmpp.js Sun Mar 20 23:30:16 2016 +0800
+// Generated by CoffeeScript 1.10.0
+ Tram.XMPPInterface = (function() {
+ XMPPInterface.prototype.conn = null;
+ function XMPPInterface() {}
+ XMPPInterface.prototype._prepareConnection = function() {
+ if (this.conn != null) {
+ console.debug('connection exists, not reconnecting');
+ return this.conn = new Strophe.Connection("https://" + Tram.config.host + "/http-bind");
+ XMPPInterface.prototype.connect = function(node, pass, onConnect) {
+ this._prepareConnection();
+ jid = node + "@" + Tram.config.domain;
+ return this.conn.connect(jid, pass, onConnect);
+ XMPPInterface.prototype.disconnect = function(reason) {
+ if (this.conn == null) {
+ this.conn.disconnect(reason);
+ XMPPInterface.prototype.startRegistration = function(onConnect) {
+ this._prepareConnection();
+ return this.conn.register.connect(Tram.config.domain, onConnect);
+ XMPPInterface.prototype.register = function(username, password) {
+ this.conn.register.fields.username = username;
+ this.conn.register.fields.password = password;
+ return this.conn.register.submit();
+ XMPPInterface.prototype.savevCard = function(data) {
+ var $vcard, b, bi, binval, bl, d, dl, failcb, okcb, type;
+ xmlns: Strophe.NS.VCARD
+ $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);
+ okcb = (function(_this) {
+ console.debug('vcard is set!', arguments);
+ return _this.trigger('v/done');
+ failcb = (function(_this) {
+ console.warn('vcard is NOT set!', arguments);
+ return _this.trigger('v/failed');
+ return this.conn.sendIQ($vcard.tree(), okcb, failcb);
+ _(Tram.XMPPInterface.prototype).extend(Backbone.Events);
+//# sourceMappingURL=xmpp.js.map
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/js/xmpp.js.map Sun Mar 20 23:30:16 2016 +0800
+ "mappings": ";AAAA;EAAM,IAAI,CAAC;4BACT,IAAA,GAAM;;IAEO,uBAAA,GAAA;;4BAEb,kBAAA,GAAoB,SAAA;MAClB,IAAG,iBAAH;QACE,OAAO,CAAC,KAAR,CAAc,qCAAd,EADF;;aAGA,IAAC,CAAA,IAAD,GAAY,IAAA,OAAO,CAAC,UAAR,CAAmB,UAAA,GAAY,IAAI,CAAC,MAAM,CAAC,IAAxB,GAA8B,YAAjD;IAJM;;4BAMpB,OAAA,GAAS,SAAC,IAAD,EAAO,IAAP,EAAa,SAAb;AACP,UAAA;MAAA,IAAC,CAAA,kBAAD,CAAA;MAEA,GAAA,GAAU,IAAF,GAAQ,GAAR,GAAY,IAAI,CAAC,MAAM,CAAC;aAChC,IAAC,CAAA,IAAI,CAAC,OAAN,CAAc,GAAd,EAAmB,IAAnB,EAAyB,SAAzB;IAJO;;4BAMT,UAAA,GAAY,SAAC,MAAD;MACV,IAAO,iBAAP;AACE,eADF;;MAGA,IAAC,CAAA,IAAI,CAAC,UAAN,CAAiB,MAAjB;MACA,IAAC,CAAA,IAAD,GAAQ;IALE;;4BAQZ,iBAAA,GAAmB,SAAC,SAAD;MACjB,IAAC,CAAA,kBAAD,CAAA;aAEA,IAAC,CAAA,IAAI,CAAC,QAAQ,CAAC,OAAf,CAAuB,IAAI,CAAC,MAAM,CAAC,MAAnC,EAA2C,SAA3C;IAHiB;;4BAKnB,QAAA,GAAU,SAAC,QAAD,EAAW,QAAX;MACR,IAAC,C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,SAAA,KAAA;eAAA,SAAA;UACL,OAAO,CAAC,KAAR,CAAc,eAAd,EAA+B,SAA/B;iBACA,KAAC,CAAA,OAAD,CAAS,QAAT;QAFK;MAAA,CAAA,CAAA,CAAA,IAAA;MAIP,MAAA,GAAS,CAAA,SAAA,KAAA;eAAA,SAAA;UACP,OAAO,CAAC,IAAR,CAAa,mBAAb,EAAkC,SAAlC;iBACA,KAAC,CAAA,OAAD,CAAS,UAAT;QAFO;MAAA,CAAA,CAAA,CAAA,IAAA;aAIT,IAAC,CAAA,IAAI,CAAC,MAAN,CAAa,MAAM,CAAC,IAAP,CAAA,CAAb,EAA4B,IAA5B,EAAkC,MAAlC;IA9BS;;;;;;EAiCb,CAAA,CAAE,IAAI,CAAC,aAAa,CAAC,SAArB,CAA+B,CAAC,MAAhC,CAAuC,QAAQ,CAAC,MAAhD;AApEA"
\ No newline at end of file
--- a/register.html Sun Mar 20 11:53:21 2016 +0800
+++ b/register.html Sun Mar 20 23:30:16 2016 +0800
<div class="uk-alert uk-alert-danger uk-hidden" data-msg="r/closed">Registration is closed at the moment.</div>
- <div class="uk-form uk-form-horizontal uk-hidden" data-step="registration">
+ <div class="uk-form uk-form-horizontal uk-hidden" data-step="registration" data-form="registration">
<div class="uk-form-row">
<label for="username" class="uk-form-label">Username</label>
<div class="uk-form-controls">
<div class="uk-form-row">
<div class="uk-form-controls">
<div class="uk-alert uk-alert-danger uk-hidden" data-msg="r/failed">Unspecified error, sorry.</div>
- <button id="register" type="button" class="uk-button uk-button-primary">Register</button>
+ <button type="button" class="uk-button uk-button-primary">Register</button>
<a class="uk-float-right uk-button uk-button-link" href="/">Log in</a>
- <div class="uk-form uk-form-horizontal uk-hidden" data-step="vcard">
+ <div class="uk-form uk-form-horizontal uk-hidden" data-step="vcard" data-form="vcard">
<div class="uk-form-row">
<label for="fullname" class="uk-form-label">Full Name</label>
<div class="uk-form-controls">
<div class="uk-form-row">
<div class="uk-form-controls">
- <button id="save" class="uk-button uk-button-primary">Save</button>
+ <button class="uk-button uk-button-primary">Save</button>
<script src='/js/tram.js'></script>
<script src='/js/validation.js'></script>
+ <script src='/js/xmpp.js'></script>
<script src='/config.js'></script>
<script src='/js/register.js'></script>