Merge pull request #409 from kalaksi/fix_topic_on_ui

Fix topic on UI
This commit is contained in:
Jérémie Astori 2015-10-04 14:54:57 -04:00
commit df4a91fd05
3 changed files with 13 additions and 10 deletions

View File

@ -403,16 +403,14 @@ button {
line-height: 50px !important; line-height: 50px !important;
height: 48px; height: 48px;
padding: 0 20px; padding: 0 20px;
overflow: hidden;
} }
#windows .header .title { #windows .header .title {
font: 14px Lato; font: 14px Lato;
} }
#windows .header .topic { #windows .header .topic {
/* Hidden for now */
display: none;
color: #777; color: #777;
margin-left: 8px; margin-left: 8px;
text-transform: capitalize;
} }
#windows .header .right { #windows .header .right {
float: right; float: right;

View File

@ -314,6 +314,14 @@ $(function() {
} }
}); });
socket.on("topic", function(data) {
// .text() escapes HTML but not quotes. That only matters with text inside attributes.
var topic = $("#chan-" + data.chan).find(".header .topic");
topic.text(data.topic);
// .attr() is safe escape-wise but consider the capabilities of the attribute
topic.attr("title", data.topic);
});
socket.on("users", function(data) { socket.on("users", function(data) {
var users = chat.find("#chan-" + data.chan).find(".users").html(render("user", data)); var users = chat.find("#chan-" + data.chan).find(".users").html(render("user", data));
var nicks = []; var nicks = [];

View File

@ -9,27 +9,24 @@ module.exports = function(irc, network) {
return; return;
} }
var from = data.nick || chan.name; var from = data.nick || chan.name;
var self = false;
if (from.toLowerCase() == irc.me.toLowerCase()) {
self = true;
}
var topic = data.topic; var topic = data.topic;
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.TOPIC, type: Msg.Type.TOPIC,
mode: chan.getMode(from), mode: chan.getMode(from),
from: from, from: from,
text: topic, text: topic,
self: self self: (from.toLowerCase() === irc.me.toLowerCase())
}); });
chan.messages.push(msg); chan.messages.push(msg);
client.emit("msg", { client.emit("msg", {
chan: chan.id, chan: chan.id,
msg: msg msg: msg
}); });
chan.topic = topic chan.topic = topic;
client.emit("topic", { client.emit("topic", {
chan: chan.id, chan: chan.id,
topic: _.escape(topic) topic: chan.topic
}); });
}); });
}; };