* finish task #5337.

This commit is contained in:
wangyidong
2019-03-19 13:40:07 +08:00
parent a79b4ec70b
commit 2882633c31
+25
View File
@@ -721,6 +721,30 @@ function getFingerprint()
return fingerprint;
}
/**
* Convert plain text URLs into HTML hyperlinks
*
* @access public
* @return void
*/
function convertURL()
{
if($('.article-content, .article>.content').size() == 0) return;
var aTags = new Array();
var content = $('.article-content, .article>.content').html();
$('.article-content, .article>.content').find('a').each(function(i)
{
aTags[i] = $(this).prop('outerHTML');
content = content.replace(aTags[i], '<REPLACE_' + i + '>');
});
var regexp = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|\&|-|%|;)+)/g;
content = content.replace(regexp, function($url){ return "<a href='" + $url + "' target='_blank'>" + $url + "</a>";});
for(i in aTags) content = content.replace('<REPLACE_' + i + '>', aTags[i]);
$('.article-content, .article>.content').html(content);
}
/* Ping the server every some minutes to keep the session. */
needPing = true;
@@ -731,6 +755,7 @@ $(document).ready(function()
checkTutorial();
revertModuleCookie();
convertURL();
$(document).on('click', '#helpMenuItem .close-help-tab', function(){$('#helpMenuItem').prev().remove();$('#helpMenuItem').remove();});
});