]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/url.js
Merge pull request #305 from retropc/master
[irc/quakenet/qwebirc.git] / js / ui / url.js
index 3a841126f263750529043741335aec11b371490e..36634ad090b7106660c5f031c95468682286787b 100644 (file)
@@ -1,6 +1,7 @@
 qwebirc.ui.urlificate = function(element, text, execfn, cmdfn, window) {
-  var punct_re = /(\.*|\,|;|\])$/;
-
+  var punct_re = /[[\)|\]>]?(\.*|[\,;])$/;
+  var addedText = [];
+  
   var txtprocess = function(text, regex, appendfn, matchfn) {
     for(;;) {
       var index = text.search(regex);
@@ -23,15 +24,17 @@ qwebirc.ui.urlificate = function(element, text, execfn, cmdfn, window) {
   };
   
   var appendText = function(text) {
+    addedText.push(text);
     qwebirc.util.NBSPCreate(text, element);
   };
   
   var appendChan = function(text) {
     var newtext = text.replace(punct_re, "");
+    addedText.push(newtext);
     var punct = text.substring(newtext.length);
 
-    var a = new Element("a");
-    a.href = "#";
+    var a = new Element("span");
+    a.addClass("hyperlink-channel");
     a.addEvent("click", function(e) {
       new Event(e).stop();
       execfn("/JOIN " + newtext);
@@ -48,7 +51,7 @@ qwebirc.ui.urlificate = function(element, text, execfn, cmdfn, window) {
     
     var href = "";
     var fn = null;
-    var target = "new";
+    var target = "_blank";
     var disptext = url;
     var elementType = "a";
     var addClass;
@@ -94,6 +97,7 @@ qwebirc.ui.urlificate = function(element, text, execfn, cmdfn, window) {
       if(target)
         a.target = target;
     }
+    addedText.push(disptext);
     a.appendChild(document.createTextNode(disptext));
     
     element.appendChild(a);
@@ -106,4 +110,6 @@ qwebirc.ui.urlificate = function(element, text, execfn, cmdfn, window) {
   txtprocess(text, /\b((https?|ftp|qwebirc):\/\/|www\.)[^ ]+/, function(text) {
     txtprocess(text, /\B#[^ ,]+/, appendText, appendChan);
   }, appendURL);
+  
+  return addedText.join("");
 }