From 2882633c31a9584bd2dbc030042152c531ea3a16 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 19 Mar 2019 13:40:07 +0800 Subject: [PATCH] * finish task #5337. --- www/js/my.full.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/www/js/my.full.js b/www/js/my.full.js index 8153db2a05..90204584a3 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -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], ''); + }); + + var regexp = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|\&|-|%|;)+)/g; + content = content.replace(regexp, function($url){ return "" + $url + "";}); + for(i in aTags) content = content.replace('', 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();}); });