Clickable URLs in text messages

This commit is contained in:
Mattias Erming 2014-04-10 23:58:08 +02:00
parent 30ea34ffd3
commit b574c87028

View File

@ -64,7 +64,12 @@ $(function() {
.first() .first()
.addClass("active"); .addClass("active");
chat.find(".messages").scrollGlue({animate: 400}).scrollToBottom(); chat.find(".messages")
.scrollGlue({animate: 400})
.scrollToBottom()
.find(".text")
.uri()
.end();
chat.find(".window") chat.find(".window")
.find("input") .find("input")
.tabComplete(commands, {appendSpace: true}) .tabComplete(commands, {appendSpace: true})
@ -123,8 +128,13 @@ $(function() {
target = target.parent().find(".active"); target = target.parent().find(".active");
} }
var msg = $(render("#message", {messages: message}))
.find(".text")
.uri()
.end();
target = target.find(".messages"); target = target.find(".messages");
target.append(render("#message", {messages: message})); target.append(msg);
break; break;
} }
@ -247,7 +257,20 @@ $(function() {
.removeClass("active") .removeClass("active")
.end(); .end();
}; };
$.fn.uri = function() {
return this.each(function() {
var html = $(this).html();
return $(this).html(URI.withinString(html, function(url) {
return "<a href='" + url + "' target='_blank'>" + url + "</a>";
}));
}); });
};
});
function linkify(text) {
}
//Handlebars.registerHelper("link", function(text) { //Handlebars.registerHelper("link", function(text) {
// var text = Handlebars.Utils.escapeExpression(text); // var text = Handlebars.Utils.escapeExpression(text);