2013-08-29 23:38:28 -04:00
|
|
|
/*global app, me*/
|
|
|
|
"use strict";
|
2013-06-03 18:51:30 -04:00
|
|
|
|
2013-08-29 23:38:28 -04:00
|
|
|
var Backbone = require('backbone');
|
|
|
|
var MainPage = require('./pages/main');
|
|
|
|
var ChatPage = require('./pages/chat');
|
2013-06-03 18:51:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
module.exports = Backbone.Router.extend({
|
|
|
|
routes: {
|
2013-09-03 22:18:31 -04:00
|
|
|
'': 'main',
|
2013-09-05 19:53:23 -04:00
|
|
|
'chat/:jid': 'chat',
|
|
|
|
'logout': 'logout'
|
2013-06-03 18:51:30 -04:00
|
|
|
},
|
|
|
|
// ------- ROUTE HANDLERS ---------
|
2013-08-20 13:45:06 -04:00
|
|
|
main: function () {
|
2013-08-29 23:38:28 -04:00
|
|
|
app.renderPage(new MainPage({
|
2013-06-03 18:51:30 -04:00
|
|
|
model: me
|
|
|
|
}));
|
|
|
|
},
|
2013-08-23 19:07:37 -04:00
|
|
|
chat: function (jid) {
|
2013-08-20 13:45:06 -04:00
|
|
|
var contact = me.contacts.get(jid);
|
|
|
|
if (contact) {
|
2013-08-29 23:38:28 -04:00
|
|
|
app.renderPage(new ChatPage({
|
2013-08-20 13:45:06 -04:00
|
|
|
model: contact
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
app.navigate('/');
|
|
|
|
}
|
2013-09-05 19:53:23 -04:00
|
|
|
},
|
|
|
|
logout: function () {
|
|
|
|
localStorage.clear();
|
|
|
|
window.location = '/login';
|
2013-06-03 18:51:30 -04:00
|
|
|
}
|
|
|
|
});
|