1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-22 17:22:22 -05:00
kaiwa/clientapp/router.js
2013-09-05 16:53:23 -07:00

36 lines
786 B
JavaScript

/*global app, me*/
"use strict";
var Backbone = require('backbone');
var MainPage = require('./pages/main');
var ChatPage = require('./pages/chat');
module.exports = Backbone.Router.extend({
routes: {
'': 'main',
'chat/:jid': 'chat',
'logout': 'logout'
},
// ------- ROUTE HANDLERS ---------
main: function () {
app.renderPage(new MainPage({
model: me
}));
},
chat: function (jid) {
var contact = me.contacts.get(jid);
if (contact) {
app.renderPage(new ChatPage({
model: contact
}));
} else {
app.navigate('/');
}
},
logout: function () {
localStorage.clear();
window.location = '/login';
}
});