Merge pull request #382 from SolarisFox/patch-5

linking to pullreqs
This commit is contained in:
Guangcong Luo
2015-05-18 20:58:28 +00:00

View File

@@ -396,21 +396,12 @@ var Tools = {
'" target="_blank" onclick="' + onclick + '">' + uri + '</a>';
});
// google [blah]
// google[blah]
// Google search for 'blah'
str = str.replace(/\bgoogle ?\[([^\]<]+)\]/ig, function(p0, p1) {
p1 = Tools.escapeHTML(encodeURIComponent(Tools.unescapeHTML(p1)));
return '<a href="http://www.google.com/search?ie=UTF-8&q=' + p1 +
'" target="_blank">' + p0 + '</a>';
});
// gl [blah]
// gl[blah]
// Google search for 'blah' and visit the first result ("I'm feeling lucky")
str = str.replace(/\bgl ?\[([^\]<]+)\]/ig, function(p0, p1) {
p1 = Tools.escapeHTML(encodeURIComponent(Tools.unescapeHTML(p1)));
return '<a href="http://www.google.com/search?ie=UTF-8&btnI&q=' + p1 +
'" target="_blank">' + p0 + '</a>';
});
// wiki [blah]
// Search Wikipedia for 'blah' (and visit the article for 'blah' if it exists)
str = str.replace(/\bwiki ?\[([^\]<]+)\]/ig, function(p0, p1) {
@@ -418,6 +409,20 @@ var Tools = {
return '<a href="http://en.wikipedia.org/w/index.php?title=Special:Search&search=' +
p1 + '" target="_blank">' + p0 + '</a>';
});
// server issue #pullreq
// Links to github Pokemon Showdown server pullreq number
str = str.replace(/\bserver issue ?#(\d+)/ig, function(p0, p1) {
p1 = Tools.escapeHTML(encodeURIComponent(Tools.unescapeHTML(p1)));
return '<a href="https://github.com/Zarel/Pokemon-Showdown/pull/' +
p1 + '" target="_blank">' + p0 + '</a>';
});
// client issue #pullreq
// Links to github Pokemon Showdown client pullreq number
str = str.replace(/\bclient issue ?#(\d+)/ig, function(p0, p1) {
p1 = Tools.escapeHTML(encodeURIComponent(Tools.unescapeHTML(p1)));
return '<a href="https://github.com/Zarel/Pokemon-Showdown-Client/pull/' +
p1 + '" target="_blank">' + p0 + '</a>';
});
// [[blah]]
// Short form of gl[blah]
str = str.replace(/\[\[([^< ](?:[^<`]*?[^< ])??)\]\]/ig, function(p0, p1) {