From 8d097aa99339ae8a9f43e062cf9d01dc128f47fd Mon Sep 17 00:00:00 2001 From: yomguy Date: Mon, 4 Feb 2013 14:48:43 +0100 Subject: [PATCH] fix urlize (no jquery stuff inducing bad loops) --- jqchat/static/jqchat/jqchat.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/jqchat/static/jqchat/jqchat.js b/jqchat/static/jqchat/jqchat.js index e26291b..5a2b2b1 100644 --- a/jqchat/static/jqchat/jqchat.js +++ b/jqchat/static/jqchat/jqchat.js @@ -40,11 +40,9 @@ $(document).ajaxSend(function(event, xhr, settings) { }); -jQuery.fn.urlize = function( base ) { - var x = this.html(); +var urlize = function(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; - var text = x.replace(exp,"$1"); - this.html(text); + return text.replace(exp,"$1"); }; // Chat client code. @@ -81,7 +79,7 @@ function processResponse(payload) { // Get the timestamp, store it in global variable to be passed to the server on next call. timestamp = payload.time; for(message in payload.messages) { - $("#chatwindow").append(payload.messages[message].text).urlize( "/" ); + $("#chatwindow").append(urlize(payload.messages[message].text)); } // Scroll down if messages fill up the div. var objDiv = document.getElementById("chatwindow"); -- 2.39.5