Fix the 'Show More' button
This commit is contained in:
parent
37b68b7bc4
commit
05a51f74a7
File diff suppressed because one or more lines are too long
@ -152,15 +152,18 @@ $(function() {
|
||||
]);
|
||||
});
|
||||
|
||||
socket.on("showMore", function(data) {
|
||||
socket.on("more", function(data) {
|
||||
var target = data.chan;
|
||||
chat.find("#chan-" + target)
|
||||
.find(".show-more")
|
||||
.remove()
|
||||
.end()
|
||||
var chan = chat
|
||||
.find("#chan-" + target)
|
||||
.find(".messages")
|
||||
.prepend(render("msg", {messages: data.messages}))
|
||||
.end();
|
||||
if (data.messages.length != 100) {
|
||||
var more = chan
|
||||
.find(".show-more")
|
||||
.remove();
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("network", function(data) {
|
||||
@ -412,7 +415,7 @@ $(function() {
|
||||
var self = $(this);
|
||||
var id = self.data("id");
|
||||
var count = self.next(".messages").children().length;
|
||||
socket.emit("showMore", {
|
||||
socket.emit("more", {
|
||||
target: id,
|
||||
count: count
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "shout",
|
||||
"description": "A web IRC client",
|
||||
"version": "0.21.3",
|
||||
"version": "0.21.4",
|
||||
"author": "Mattias Erming",
|
||||
"preferGlobal": true,
|
||||
"bin": {
|
||||
|
@ -193,6 +193,21 @@ Client.prototype.input = function(data) {
|
||||
});
|
||||
}
|
||||
|
||||
Client.prototype.more = function(data) {
|
||||
var client = this;
|
||||
var target = client.find(data.target);
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
var chan = target.chan;
|
||||
var count = chan.messages.length - (data.count || 0);
|
||||
var messages = chan.messages.slice(Math.max(0, count - 100), count);
|
||||
client.emit("more", {
|
||||
chan: chan.id,
|
||||
messages: messages
|
||||
});
|
||||
}
|
||||
|
||||
Client.prototype.quit = function() {
|
||||
this.networks.forEach(function(network) {
|
||||
var irc = network.irc;
|
||||
|
@ -65,9 +65,9 @@ function init(socket, client) {
|
||||
}
|
||||
);
|
||||
socket.on(
|
||||
"showMore",
|
||||
"more",
|
||||
function(data) {
|
||||
showMore(client, data);
|
||||
client.more(data);
|
||||
}
|
||||
);
|
||||
socket.on(
|
||||
@ -106,16 +106,3 @@ function auth(data) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showMore(client, data) {
|
||||
var target = client.find(data.target);
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
var chan = target.chan;
|
||||
var messages = chan.messages.slice(0, chan.messages.length - (data.count || 0));
|
||||
client.emit("showMore", {
|
||||
chan: chan.id,
|
||||
messages: messages
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user