Skip to content

Commit f548bf7

Browse files
committed
reindent
1 parent f376867 commit f548bf7

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

logviewer/static/chat.js

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
function ChatSession(options) {
2-
this.options = options;
3-
this.from = options.from || 0;
4-
this.onUpdate = options.onUpdate || function(){};
2+
this.options = options;
3+
this.from = options.from || 0;
4+
this.onUpdate = options.onUpdate || function(){};
55
}
66

77
ChatSession.prototype = {
8-
start: function() {
8+
start: function() {
99
this.socket = io.connect(this.options.url);
1010
var self = this;
1111
this.socket.on('update', function() {
12-
self.update(self.onUpdate);
12+
self.update(self.onUpdate);
1313
});
1414
},
1515

1616
send: function(msg) {
1717
this.socket.emit('msg', {
18-
nick: this.options.nickname,
19-
channel: this.options.channel,
20-
msg: msg
18+
nick: this.options.nickname,
19+
channel: this.options.channel,
20+
msg: msg
2121
});
2222
},
2323

2424
update: function(next) {
25-
var self = this;
26-
$.getJSON('?from=' + this.from, function(data) {
27-
if (!data.html) return;
25+
var self = this;
26+
$.getJSON('?from=' + this.from, function(data) {
27+
if (!data.html) return;
2828
self.from = data.last_no + 1;
2929
if (next) next.call(self, data.html);
3030
});
3131
}
3232
};
3333

3434
function LogView(el) {
35-
this.el = el;
35+
this.el = el;
3636
}
3737

3838
LogView.prototype = {
39-
append: function(data) {
39+
append: function(data) {
4040
this.el.append(data);
4141
apply_noreferrer(this.el);
4242
},
@@ -53,70 +53,70 @@ LogView.prototype = {
5353
};
5454

5555
function ChatController(options) {
56-
this.options = options;
57-
this.session = options.session;
58-
this.session.onUpdate = $.proxy(this.onUpdate, this);
56+
this.options = options;
57+
this.session = options.session;
58+
this.session.onUpdate = $.proxy(this.onUpdate, this);
5959

6060
var self = this;
61-
this.options.startChatView.on('click', function() {
62-
self.startChat();
63-
return false;
61+
this.options.startChatView.on('click', function() {
62+
self.startChat();
63+
return false;
6464
});
6565
this.options.inputFormView.on('submit', function() {
66-
self.sendMessage();
67-
return false;
66+
self.sendMessage();
67+
return false;
6868
});
6969
}
7070

7171
ChatController.prototype = {
72-
startChat: function() {
73-
this.options.startChatView.slideUp();
74-
this.options.inputFormView.slideDown();
75-
var self = this;
72+
startChat: function() {
73+
this.options.startChatView.slideUp();
74+
this.options.inputFormView.slideDown();
75+
var self = this;
7676

7777
this.normalTitle = document.title;
78-
observeWindowVisibility(function(visible) {
78+
observeWindowVisibility(function(visible) {
7979
self.setWindowVisible(visible);
8080
});
8181

82-
this.session.update(function(data) {
83-
self.appendLog(data);
82+
this.session.update(function(data) {
83+
self.appendLog(data);
8484
self.options.logView.scrollToBottom();
8585
});
8686
this.session.start();
8787
},
8888

8989
onUpdate: function(data) {
9090
var willScroll = this.options.logView.shouldScrollToBottom();
91-
this.appendLog(data);
92-
if (willScroll)
93-
this.options.logView.scrollToBottom();
94-
if (!this._windowVisible)
95-
this.notifyPendingLog();
91+
this.appendLog(data);
92+
if (willScroll)
93+
this.options.logView.scrollToBottom();
94+
if (!this._windowVisible)
95+
this.notifyPendingLog();
9696
},
9797

9898
appendLog: function(data) {
99-
this.options.logView.append(data);
99+
this.options.logView.append(data);
100100
},
101101

102102
sendMessage: function() {
103-
var msg = this.options.inputView.val();
104-
if (msg) {
105-
this.session.send(msg);
106-
this.options.inputView.val('');
103+
var msg = this.options.inputView.val();
104+
if (msg) {
105+
this.session.send(msg);
106+
this.options.inputView.val('');
107107
}
108108
},
109109

110110
setWindowVisible: function(visible) {
111-
if (!this._windowVisible && visible) {
112-
// Become visible
113-
document.title = this.normalTitle;
111+
if (!this._windowVisible && visible) {
112+
// Become visible
113+
document.title = this.normalTitle;
114114
}
115-
this._windowVisible = visible;
115+
this._windowVisible = visible;
116116
},
117117

118118
notifyPendingLog: function() {
119-
document.title = '+ ' + this.normalTitle;
119+
document.title = '+ ' + this.normalTitle;
120120
}
121121
};
122122

@@ -137,15 +137,15 @@ ChatController.prototype = {
137137
}
138138

139139
exports.isWindowVisible = function() {
140-
return !document[hidden];
140+
return !document[hidden];
141141
};
142142

143143
exports.observeWindowVisibility = function(callback) {
144144
if (typeof document.addEventListener !== "undefined" &&
145145
typeof hidden !== "undefined") {
146146
callback(exports.isWindowVisible());
147147
document.addEventListener(visibilityChange, function() {
148-
callback(exports.isWindowVisible());
148+
callback(exports.isWindowVisible());
149149
}, false);
150150
}
151151
};

0 commit comments

Comments
 (0)