Sprinkle some ES6 on it
This commit is contained in:
parent
518d3eaa07
commit
fca2985d9b
@ -32,10 +32,8 @@ var TabList = React.createClass({
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var self = this;
|
||||
|
||||
var tabs = _.map(this.state.channels, function(server, address) {
|
||||
var serverTabs = _.map(server, function(channel, name) {
|
||||
var tabs = _.map(this.state.channels, (server, address) => {
|
||||
var serverTabs = _.map(server, (channel, name) => {
|
||||
return (
|
||||
<TabListItem
|
||||
server={address}
|
||||
@ -45,7 +43,7 @@ var TabList = React.createClass({
|
||||
);
|
||||
});
|
||||
|
||||
_.each(self.state.privateChats[address], function(chat, nick) {
|
||||
_.each(this.state.privateChats[address], (chat, nick) => {
|
||||
serverTabs.push(
|
||||
<TabListItem
|
||||
server={address}
|
||||
|
@ -1,29 +1,21 @@
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
var _ = require('lodash');
|
||||
class Socket extends EventEmitter {
|
||||
constructor() {
|
||||
this.ws = new WebSocket('ws://' + window.location.host + '/ws');
|
||||
|
||||
var ws = new WebSocket('ws://' + window.location.host + '/ws');
|
||||
this.ws.onopen = () => this.emit('connect');
|
||||
this.ws.onclose = () => this.emit('disconnect');
|
||||
this.ws.onmessage = (e) => {
|
||||
var msg = JSON.parse(e.data);
|
||||
|
||||
var socket = {
|
||||
send: function(type, data) {
|
||||
ws.send(JSON.stringify({ type: type, request: data }));
|
||||
this.emit(msg.type, msg.response);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_.extend(socket, EventEmitter.prototype);
|
||||
send(type, data) {
|
||||
this.ws.send(JSON.stringify({ type: type, request: data }));
|
||||
}
|
||||
}
|
||||
|
||||
ws.onopen = function() {
|
||||
socket.emit('connect');
|
||||
};
|
||||
|
||||
ws.onclose = function() {
|
||||
socket.emit('disconnect');
|
||||
};
|
||||
|
||||
ws.onmessage = function(e) {
|
||||
var msg = JSON.parse(e.data);
|
||||
|
||||
socket.emit(msg.type, msg.response);
|
||||
};
|
||||
|
||||
module.exports = socket;
|
||||
module.exports = new Socket();
|
@ -23,9 +23,9 @@ var selectedTabStore = Reflux.createStore({
|
||||
this.listenTo(serverActions.load, 'loadServers');
|
||||
},
|
||||
|
||||
select: function(server, channel) {
|
||||
select: function(server, channel = null) {
|
||||
selectedTab.server = server;
|
||||
selectedTab.channel = channel || null;
|
||||
selectedTab.channel = channel;
|
||||
|
||||
if (channel) {
|
||||
selectedTab.name = channel;
|
||||
|
@ -16,9 +16,7 @@ exports.timestamp = function(date) {
|
||||
return h + ':' + m;
|
||||
};
|
||||
|
||||
exports.wrapMessages = function(messages, width, charWidth, indent) {
|
||||
indent = indent || 0;
|
||||
|
||||
exports.wrapMessages = function(messages, width, charWidth, indent = 0) {
|
||||
for (var j = 0, llen = messages.length; j < llen; j++) {
|
||||
var message = messages[j];
|
||||
var words = message.message.split(' ');
|
||||
|
Loading…
Reference in New Issue
Block a user