Download:
child 22:dba8124befc3
parent 20:aa1eeed14fff
21:e43ed046f909
Anton Shestakov <av6@dwimlabs.net>, Mon, 21 Mar 2016 14:33:42 +0800
register: rename status events, pass callbacks to XMPPInterface.savevCard()

7 файлов изменено, 138 вставок(+), 135 удалений(-) [+]
coffee/register.coffee file | annotate | diff | comparison | revisions
coffee/xmpp.coffee file | annotate | diff | comparison | revisions
js/register.js file | annotate | diff | comparison | revisions
js/register.js.map file | annotate | diff | comparison | revisions
js/xmpp.js file | annotate | diff | comparison | revisions
js/xmpp.js.map file | annotate | diff | comparison | revisions
register.html file | annotate | diff | comparison | revisions
--- a/coffee/register.coffee Mon Mar 21 10:29:04 2016 +0800
+++ b/coffee/register.coffee Mon Mar 21 14:33:42 2016 +0800
@@ -1,6 +1,33 @@
window.X = new Tram.XMPPInterface()
+X.on 'register', ->
+ $('[data-step="registration"]').removeClass('uk-hidden')
+
+
+X.on 'registered', ->
+ X.finishRegistration()
+ $('[data-step="registration"]').addClass('uk-hidden')
+
+
+X.on 'regifail', ->
+ $('[data-msg="registration-closed"]').removeClass('uk-hidden')
+
+
+X.on 'conflict', ->
+ Tram.validation.setError($('#username'), 'A user with this username already exists.')
+
+
+X.on 'notacceptable', ->
+ $('[data-msg="registration-failed"]').removeClass('uk-hidden')
+
+
+X.on 'connected', ->
+ $('#nickname').val($('#username').val())
+ $('[data-step="vcard"]').removeClass('uk-hidden')
+ $('#fullname').focus()
+
+
X.startRegistration()
@@ -29,52 +56,25 @@
$('[data-form="vcard"] button').on 'click', ->
+ data =
+ fullname: $('#fullname').val()
+ nickname: $('#nickname').val()
+
+ okcb = ->
+ console.debug('vcard is set!', arguments)
+ $('[data-step="vcard"]').addClass('uk-hidden')
+ location.href = '/'
+
+ failcb = ->
+ console.warn('vcard is NOT set!', arguments)
+ $('[data-msg="save-failed"]').removeClass('uk-hidden')
+
file = $('#avatar').get(0).files[0]
if file
reader = new FileReader()
reader.onloadend = ->
- X.savevCard
- fullname: $('#fullname').val()
- nickname: $('#nickname').val()
- avatar: @result
+ _(data).extend(avatar: reader.result)
+ X.savevCard(data, okcb, failcb)
reader.readAsDataURL(file)
else
- X.savevCard
- fullname: $('#fullname').val()
- nickname: $('#nickname').val()
-
-
-X.on 'r/start', ->
- $('[data-step="registration"]').removeClass('uk-hidden')
-
-
-X.on 'r/done', ->
- X.finishRegistration()
- $('[data-step="registration"]').addClass('uk-hidden')
-
-
-X.on 'r/closed', ->
- $('[data-msg="r/closed"]').removeClass('uk-hidden')
-
-
-X.on 'r/conflict', ->
- Tram.validation.setError($('#username'), 'A user with this username already exists.')
-
-
-X.on 'r/failed', ->
- $('[data-msg="r/failed"]').removeClass('uk-hidden')
-
-
-X.on 'v/start', ->
- $('#nickname').val($('#username').val())
- $('[data-step="vcard"]').removeClass('uk-hidden')
- $('#fullname').focus()
-
-
-X.on 'v/done', ->
- $('[data-step="vcard"]').addClass('uk-hidden')
- location.href = '/'
-
-
-X.on 'v/failed', ->
- $('[data-msg="v/failed"]').removeClass('uk-hidden')
+ X.savevCard(data, okcb, failcb)
--- a/coffee/xmpp.coffee Mon Mar 21 10:29:04 2016 +0800
+++ b/coffee/xmpp.coffee Mon Mar 21 14:33:42 2016 +0800
@@ -36,7 +36,7 @@
finishRegistration: ->
@conn.authenticate()
- savevCard: (data) ->
+ savevCard: (data, okcb, failcb) ->
$vcard = $iq(type: 'set').c('vCard', xmlns: Strophe.NS.VCARD)
if data.nickname
@@ -58,63 +58,67 @@
.c('TYPE').t(type).up()
.c('BINVAL').t(binval)
- okcb = =>
- console.debug('vcard is set!', arguments)
- @trigger('v/done')
-
- failcb = =>
- console.warn('vcard is NOT set!', arguments)
- @trigger('v/failed')
-
@conn.sendIQ($vcard.tree(), okcb, failcb)
onConnect: (status, error) =>
switch status
when Strophe.Status.CONNECTING
console.debug('Strophe is connecting.')
+ @trigger('connecting')
when Strophe.Status.AUTHENTICATING
console.debug('Strophe is authenticating.')
+ @trigger('authenticating')
when Strophe.Status.AUTHFAIL
console.debug('Strophe failed to authenticate:', error)
+ @trigger('authfail')
when Strophe.Status.ERROR
console.debug('Strophe received an error:', error)
+ @trigger('error')
when Strophe.Status.CONNFAIL
console.debug('Strophe failed to connect:', error)
+ @trigger('connfail')
when Strophe.Status.DISCONNECTING
console.debug('Strophe is disconnecting.')
+ @trigger('disconnecting')
when Strophe.Status.DISCONNECTED
console.debug('Strophe is disconnected.')
+ @trigger('disconnected')
when Strophe.Status.CONNECTED
console.debug('Strophe is connected.')
console.info('My jid:', @conn.jid)
- @trigger('v/start')
+ @trigger('connected')
+
+ when Strophe.Status.ATTACHED
+ console.debug('Strophe is attached.')
+ console.info('My jid:', @conn.jid)
+ @trigger('attached')
when Strophe.Status.REGISTER
console.debug('Got registration prompt.')
- @trigger('r/start')
+ @trigger('register')
when Strophe.Status.REGISTERED
console.debug('Registered!')
- @trigger('r/done')
+ @trigger('registered')
when Strophe.Status.CONFLICT
console.debug('Contact already exists!')
- @trigger('r/conflict')
+ @trigger('conflict')
when Strophe.Status.NOTACCEPTABLE
console.debug('Registration form not properly filled out.')
- @trigger('r/failed')
+ @trigger('notacceptable')
when Strophe.Status.REGIFAIL
console.debug('The server does not support In-Band Registration.')
- @trigger('r/closed')
+ @trigger('regifail')
_(Tram.XMPPInterface.prototype).extend(Backbone.Events)
--- a/js/register.js Mon Mar 21 10:29:04 2016 +0800
+++ b/js/register.js Mon Mar 21 14:33:42 2016 +0800
@@ -2,6 +2,33 @@
(function() {
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 Tram.validation.setError($('#username'), 'A user with this username already exists.');
+ });
+
+ X.on('notacceptable', function() {
+ return $('[data-msg="registration-failed"]').removeClass('uk-hidden');
+ });
+
+ X.on('connected', function() {
+ $('#nickname').val($('#username').val());
+ $('[data-step="vcard"]').removeClass('uk-hidden');
+ return $('#fullname').focus();
+ });
+
X.startRegistration();
$('[data-form="registration"], [data-form="vcard"]').each(function() {
@@ -36,62 +63,35 @@
});
$('[data-form="vcard"] button').on('click', function() {
- var file, reader;
+ var data, failcb, file, okcb, reader;
+ data = {
+ fullname: $('#fullname').val(),
+ nickname: $('#nickname').val()
+ };
+ okcb = function() {
+ console.debug('vcard is set!', arguments);
+ $('[data-step="vcard"]').addClass('uk-hidden');
+ return location.href = '/';
+ };
+ failcb = function() {
+ console.warn('vcard is NOT set!', arguments);
+ return $('[data-msg="save-failed"]').removeClass('uk-hidden');
+ };
file = $('#avatar').get(0).files[0];
if (file) {
reader = new FileReader();
reader.onloadend = function() {
- return X.savevCard({
- fullname: $('#fullname').val(),
- nickname: $('#nickname').val(),
- avatar: this.result
+ _(data).extend({
+ avatar: reader.result
});
+ return X.savevCard(data, okcb, failcb);
};
return reader.readAsDataURL(file);
} else {
- return X.savevCard({
- fullname: $('#fullname').val(),
- nickname: $('#nickname').val()
- });
+ return X.savevCard(data, okcb, failcb);
}
});
- X.on('r/start', function() {
- return $('[data-step="registration"]').removeClass('uk-hidden');
- });
-
- X.on('r/done', function() {
- X.finishRegistration();
- 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');
- });
-
}).call(this);
//# sourceMappingURL=register.js.map
--- a/js/register.js.map Mon Mar 21 10:29:04 2016 +0800
+++ b/js/register.js.map Mon Mar 21 14:33:42 2016 +0800
@@ -6,5 +6,5 @@
"coffee/register.coffee"
],
"names": [],
- "mappings": ";AAAA;EAAA,MAAM,CAAC,CAAP,GAAe,IAAA,IAAI,CAAC,aAAL,CAAA;;EAGf,CAAC,CAAC,iBAAF,CAAA;;EAGA,CAAA,CAAE,iDAAF,CAAoD,CAAC,IAArD,CAA0D,SAAA;AACxD,QAAA;IAAA,KAAA,GAAQ,CAAA,CAAE,IAAF;WACR,KAAK,CAAC,IAAN,CAAW,OAAX,CAAmB,CAAC,EAApB,CAAuB,SAAvB,EAAkC,SAAC,CAAD;AAChC,UAAA;MAAA,IAAG,CAAC,CAAI,IAAC,CAAA,QAAL,IAAiB,IAAC,CAAA,KAAD,KAAY,EAA9B,CAAA,IAAsC,CAAC,CAAC,OAAF,KAAa,EAAtD;QACE,CAAC,CAAC,cAAF,CAAA;QACA,KAAA,GAAQ,KAAK,CAAC,IAAN,CAAW,OAAX,CAAmB,CAAC,KAApB,CAA0B,IAA1B;QACR,KAAA,GAAQ,KAAK,CAAC,IAAN,CAAW,OAAX,CAAmB,CAAC,EAApB,CAAuB,KAAA,GAAQ,CAA/B;QACR,IAAG,KAAK,CAAC,MAAN,KAAkB,CAArB;iBACE,KAAK,CAAC,KAAN,CAAA,EADF;SAAA,MAAA;iBAGE,KAAK,CAAC,IAAN,CAAW,QAAX,CAAoB,CAAC,OAArB,CAA6B,OAA7B,EAHF;SAJF;;IADgC,CAAlC;EAFwD,CAA1D;;EAaA,CAAA,CAAE,mCAAF,CAAsC,CAAC,EAAvC,CAA0C,OAA1C,EAAmD,SAAA;AACjD,QAAA;IAAA,EAAA,GAAK;IACL,IAAI,CAAC,UAAU,CAAC,UAAhB,CAA2B,CAAA,CAAE,mCAAF,CAA3B;IACA,EAAA,IAAM,IAAI,CAAC,UAAU,CAAC,gBAAhB,CAAiC,C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();
};
- XMPPInterface.prototype.savevCard = function(data) {
- var $vcard, b, bi, binval, bl, d, dl, failcb, okcb, type;
+ XMPPInterface.prototype.savevCard = function(data, okcb, failcb) {
+ var $vcard, b, bi, binval, bl, d, dl, type;
$vcard = $iq({
type: 'set'
}).c('vCard', {
@@ -69,56 +69,55 @@
binval = data.avatar.substr(bi + bl);
$vcard.c('PHOTO').c('TYPE').t(type).up().c('BINVAL').t(binval);
}
- okcb = (function(_this) {
- return function() {
- console.debug('vcard is set!', arguments);
- return _this.trigger('v/done');
- };
- })(this);
- failcb = (function(_this) {
- return function() {
- console.warn('vcard is NOT set!', arguments);
- return _this.trigger('v/failed');
- };
- })(this);
return this.conn.sendIQ($vcard.tree(), okcb, failcb);
};
XMPPInterface.prototype.onConnect = function(status, error) {
switch (status) {
case Strophe.Status.CONNECTING:
- return console.debug('Strophe is connecting.');
+ console.debug('Strophe is connecting.');
+ return this.trigger('connecting');
case Strophe.Status.AUTHENTICATING:
- return console.debug('Strophe is authenticating.');
+ console.debug('Strophe is authenticating.');
+ return this.trigger('authenticating');
case Strophe.Status.AUTHFAIL:
- return console.debug('Strophe failed to authenticate:', error);
+ console.debug('Strophe failed to authenticate:', error);
+ return this.trigger('authfail');
case Strophe.Status.ERROR:
- return console.debug('Strophe received an error:', error);
+ console.debug('Strophe received an error:', error);
+ return this.trigger('error');
case Strophe.Status.CONNFAIL:
- return console.debug('Strophe failed to connect:', error);
+ console.debug('Strophe failed to connect:', error);
+ return this.trigger('connfail');
case Strophe.Status.DISCONNECTING:
- return console.debug('Strophe is disconnecting.');
+ console.debug('Strophe is disconnecting.');
+ return this.trigger('disconnecting');
case Strophe.Status.DISCONNECTED:
- return console.debug('Strophe is disconnected.');
+ console.debug('Strophe is disconnected.');
+ return this.trigger('disconnected');
case Strophe.Status.CONNECTED:
console.debug('Strophe is connected.');
console.info('My jid:', this.conn.jid);
- return this.trigger('v/start');
+ return this.trigger('connected');
+ case Strophe.Status.ATTACHED:
+ console.debug('Strophe is attached.');
+ console.info('My jid:', this.conn.jid);
+ return this.trigger('attached');
case Strophe.Status.REGISTER:
console.debug('Got registration prompt.');
- return this.trigger('r/start');
+ return this.trigger('register');
case Strophe.Status.REGISTERED:
console.debug('Registered!');
- return this.trigger('r/done');
+ return this.trigger('registered');
case Strophe.Status.CONFLICT:
console.debug('Contact already exists!');
- return this.trigger('r/conflict');
+ return this.trigger('conflict');
case Strophe.Status.NOTACCEPTABLE:
console.debug('Registration form not properly filled out.');
- return this.trigger('r/failed');
+ return this.trigger('notacceptable');
case Strophe.Status.REGIFAIL:
console.debug('The server does not support In-Band Registration.');
- return this.trigger('r/closed');
+ return this.trigger('regifail');
}
};
--- a/js/xmpp.js.map Mon Mar 21 10:29:04 2016 +0800
+++ b/js/xmpp.js.map Mon Mar 21 14:33:42 2016 +0800
@@ -6,5 +6,5 @@
"coffee/xmpp.coffee"
],
"names": [],
- "mappings": ";AAAA;AAAA,MAAA;;EAAM,IAAI,CAAC;4BACT,IAAA,GAAM;;IAEO,uBAAA;;IAAA;;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,CA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d;iBACA,IAAC,CAAA,OAAD,CAAS,UAAT;AAzCJ,aA2CO,OAAO,CAAC,MAAM,CAAC,UA3CtB;UA4CI,OAAO,CAAC,KAAR,CAAc,aAAd;iBACA,IAAC,CAAA,OAAD,CAAS,YAAT;AA7CJ,aA+CO,OAAO,CAAC,MAAM,CAAC,QA/CtB;UAgDI,OAAO,CAAC,KAAR,CAAc,yBAAd;iBACA,IAAC,CAAA,OAAD,CAAS,UAAT;AAjDJ,aAmDO,OAAO,CAAC,MAAM,CAAC,aAnDtB;UAoDI,OAAO,CAAC,KAAR,CAAc,4CAAd;iBACA,IAAC,CAAA,OAAD,CAAS,eAAT;AArDJ,aAuDO,OAAO,CAAC,MAAM,CAAC,QAvDtB;UAwDI,OAAO,CAAC,KAAR,CAAc,mDAAd;iBACA,IAAC,CAAA,OAAD,CAAS,UAAT;AAzDJ;IADS;;;;;;EA6Db,CAAA,CAAE,IAAI,CAAC,aAAa,CAAC,SAArB,CAA+B,CAAC,MAAhC,CAAuC,QAAQ,CAAC,MAAhD;AA3HA"
}
\ No newline at end of file
--- a/register.html Mon Mar 21 10:29:04 2016 +0800
+++ b/register.html Mon Mar 21 14:33:42 2016 +0800
@@ -26,7 +26,7 @@
$('[data-step="noscript"]').addClass('uk-hidden');
</script>
- <div class="uk-alert uk-alert-danger uk-hidden" data-msg="r/closed">Registration is closed at the moment.</div>
+ <div class="uk-alert uk-alert-danger uk-hidden" data-msg="registration-closed">Registration is closed at the moment.</div>
<div class="uk-form uk-form-horizontal uk-hidden" data-step="registration" data-form="registration">
<div class="uk-form-row">
@@ -49,7 +49,7 @@
</div>
<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>
+ <div class="uk-alert uk-alert-danger uk-hidden" data-msg="registration-failed">Unspecified error, sorry.</div>
<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>
@@ -82,7 +82,7 @@
</div>
</div>
- <div class="uk-alert uk-alert-danger uk-hidden" data-msg="v/failed">Couldn't save the vCard.</div>
+ <div class="uk-alert uk-alert-danger uk-hidden" data-msg="save-failed">Couldn't save the vCard.</div>
</div>
<script src='/js/tram.js'></script>