]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/url.js
1 var url_re
= /https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_
\.]*(\?\S
+)?)?)?/;
2 var chan_re
= /\B
#[^ ,]+/;
4 function txtprocess(text
, regex
, appendfn
, matchfn
) {
6 var index
= text
.search(regex
);
11 var match
= text
.match(regex
);
13 var before
= text
.substring(0, index
);
14 var matched
= match
[0];
15 var after
= text
.substring(index
+ matched
.length
);
23 function urlificate(element
, text
, execfn
) {
24 function appendText(text
) {
25 chanficate(element
, text
, execfn
);
27 function appendA(text
) {
28 var a
= document
.createElement("a");
31 a
.appendChild(document
.createTextNode(text
));
33 element
.appendChild(a
);
35 txtprocess(text
, url_re
, appendText
, appendA
);
38 function chanficate(element
, text
, execfn
) {
39 function appendText(text
) {
40 element
.appendChild(document
.createTextNode(text
));
42 function appendA(text
) {
43 var a
= document
.createElement("a");
45 a
.addEvent("click", function(e
) {
47 execfn("/JOIN " + text
);
49 a
.appendChild(document
.createTextNode(text
));
51 element
.appendChild(a
);
53 txtprocess(text
, chan_re
, appendText
, appendA
);