mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-28 20:22:15 -05:00
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
/*global app, me, client*/
|
|
"use strict";
|
|
|
|
var Backbone = require('backbone');
|
|
var SettingsPage = require('./pages/settings');
|
|
var ChatPage = require('./pages/chat');
|
|
var GroupChatPage = require('./pages/groupchat');
|
|
|
|
|
|
module.exports = Backbone.Router.extend({
|
|
routes: {
|
|
'': 'settings',
|
|
'chat/:jid': 'chat',
|
|
'chat/:jid/:resource': 'chat',
|
|
'groupchat/:jid': 'groupchat',
|
|
'logout': 'logout'
|
|
},
|
|
// ------- ROUTE HANDLERS ---------
|
|
settings: function () {
|
|
app.renderPage(new SettingsPage({
|
|
model: me
|
|
}));
|
|
},
|
|
chat: function (jid) {
|
|
var contact = me.contacts.get(decodeURIComponent(jid));
|
|
if (contact) {
|
|
app.renderPage(new ChatPage({
|
|
model: contact
|
|
}));
|
|
} else {
|
|
app.navigate('/');
|
|
}
|
|
},
|
|
groupchat: function (jid) {
|
|
var contact = me.mucs.get(decodeURIComponent(jid));
|
|
if (contact) {
|
|
app.renderPage(new GroupChatPage({
|
|
model: contact
|
|
}));
|
|
} else {
|
|
app.navigate('/');
|
|
}
|
|
},
|
|
logout: function () {
|
|
if (client.sessionStarted) {
|
|
client.disconnect();
|
|
}
|
|
localStorage.clear();
|
|
window.location = '/login';
|
|
}
|
|
});
|