]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/url.js
1 var url_re
= /https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_
\.]*(\?\S
+)?)?)?/;
3 function urlificate(element
, text
) {
4 function appendText(text
) {
5 element
.appendChild(document
.createTextNode(text
));
7 function appendA(text
) {
8 var a
= document
.createElement("a");
11 a
.appendChild(document
.createTextNode(text
));
13 element
.appendChild(a
);
17 var index
= text
.search(url_re
);
22 var match
= text
.match(url_re
);
24 before
= text
.substring(0, index
);
26 after
= text
.substring(index
+ matched
.length
);
29 appendA(matched
, before
);