only pull in data from GitHub pages to reduce risk of being down.
This commit is contained in:
33
external/autolink.js
vendored
Normal file
33
external/autolink.js
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// Generated by CoffeeScript 1.4.0
|
||||
(function() {
|
||||
var autoLink,
|
||||
__slice = [].slice;
|
||||
|
||||
autoLink = function() {
|
||||
var callbackThunk, key, link_attributes, option, options, url_pattern, value;
|
||||
options = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
link_attributes = '';
|
||||
option = options[0];
|
||||
url_pattern = /(^|\s)(\b(https?|ftp):\/\/[\-A-Z0-9+\u0026@#\/%?=~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~_|])/gi;
|
||||
if (!(options.length > 0)) {
|
||||
return this.replace(url_pattern, "$1<a href='$2'>$2</a>");
|
||||
}
|
||||
if ((option['callback'] != null) && typeof option['callback'] === 'function') {
|
||||
callbackThunk = option['callback'];
|
||||
delete option['callback'];
|
||||
}
|
||||
for (key in option) {
|
||||
value = option[key];
|
||||
link_attributes += " " + key + "='" + value + "'";
|
||||
}
|
||||
return this.replace(url_pattern, function(match, space, url) {
|
||||
var link, returnCallback;
|
||||
returnCallback = callbackThunk && callbackThunk(url);
|
||||
link = returnCallback || ("<a href='" + url + "'" + link_attributes + ">" + url + "</a>");
|
||||
return "" + space + link;
|
||||
});
|
||||
};
|
||||
|
||||
String.prototype['autoLink'] = autoLink;
|
||||
|
||||
}).call(this);
|
Reference in New Issue
Block a user