页面中显示KE内容的地方都加上自动识别网址的函数

yuanke_org
yuanke 9 years ago
parent 0dd7aae08c
commit ded5f8f861

@ -141,6 +141,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
@ -215,5 +216,6 @@
var postContent = $("#message_description_<%= @article.id %>").html();
postContent = postContent.replace(/&nbsp;/g," ");
$("#message_description_<%= @article.id %>").html(postContent);
autoUrl('message_description_<%= @article.id %>');
});
</script>

@ -120,6 +120,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
@ -214,5 +215,6 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('message_description_<%= @article.id %>');
});
</script>

@ -1,6 +1,12 @@
<div style="padding-top: 10px">
<% if memos.any? %>
<% memos.each do |topic| %>
<script type="text/javascript">
$(function(){
showNormalImage('postDetailDes_<%= topic.id %>');
autoUrl('postDetailDes_<%= topic.id %>');
});
</script>
<div class="postDetailRow">
<div class="postDetailPortrait">
<!--<img src="images/homepageImage.jpg" width="50" height="50" alt="贴吧图片" /></a>-->
@ -16,7 +22,7 @@
<a href="javascript:void(0);" class="linkGrey2 disablePostLikeIcon ml10 mt20" style="cursor: default" title="点赞人数" > <%= get_praise_num(topic)%></a>
</div>
<div class="postDetailDes"><%= topic.content.html_safe%>
<div class="postDetailDes" id = "postDetailDes_<%= topic.id %>"><%= topic.content.html_safe%>
<!--<a href="javascript:void(0);" class="linkBlue2 underline ml8">显示全部</a>-->
</div>
<% author = topic.last_reply.try(:author)%>

@ -28,7 +28,7 @@
<%= render :partial => 'action_menu' %>
<div class="cl"></div>
<% if @issue.description? || @issue.attachments.any? -%>
<div class="talk_info mb10 issue_desc" style="word-break:break-all;">
<div class="talk_info mb10 issue_desc" id="issue_desc_<%= @issue.id %>" style="word-break:break-all;">
<% if @issue.description? %>
<%#= link_to l(:button_quote), quoted_issue_path(@issue.id), :remote => true, :method => 'post', :class => 'icon icon-comment' if authorize_for('issues', 'edit') %>
<%= textAreailizable @issue, :description, :attachments => @issue.attachments %>
@ -44,3 +44,10 @@
<%= render :partial => 'issues/attributes_show' %>
<div class="cl"></div>
</div>
<script type="text/javascript">
$(function(){
showNormalImage('issue_desc_<%= @issue.id %>');
autoUrl('issue_desc_<%= @issue.id %>');
});
</script>

@ -3,6 +3,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');
autoUrl('reply_content_<%= reply.id %>');
});
</script>
<% replies_all_i=replies_all_i + 1 %>

@ -99,7 +99,7 @@
</div>
<script type="text/javascript">
$(function(){
$("#activity_description_<%= reply.id %> p,#activity_description__<%= reply.id %> span,#activity_description_<%= reply.id %> em").each(function(){
$("#activity_description_<%= reply.id %> p,#activity_description_<%= reply.id %> span,#activity_description_<%= reply.id %> em").each(function(){
var postContent = $(this).html();
postContent = postContent.replace(/&nbsp;/g," ");
postContent= postContent.replace(/ {2}/g,"&nbsp; ");
@ -107,6 +107,7 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('activity_description_<%= reply.id %>');
description_show_hide(<%= reply.id %>);
});
</script>
@ -147,6 +148,7 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('activity_description_<%= @memo.id %>');
description_show_hide(<%= @memo.id %>);
});
</script>

@ -109,6 +109,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
@ -188,5 +189,6 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('message_description_<%= @topic.id %>');
});
</script>

@ -138,6 +138,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
@ -210,5 +211,6 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('message_description_<%= @topic.id %>');
});
</script>

@ -165,6 +165,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
@ -245,5 +246,6 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('message_description_<%= @topic.id %>');
});
</script>

@ -115,6 +115,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
@ -210,5 +211,6 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('message_description_<%= @news.id %>');
});
</script>

@ -97,6 +97,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
@ -185,5 +186,6 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('message_description_<%= @news.id %>');
});
</script>

@ -107,6 +107,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
@ -195,5 +196,6 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('message_description_<%= @news.id %>');
});
</script>

@ -84,6 +84,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<% user = User.find(reply.creator_id) %>
@ -158,6 +159,7 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('intro_content_<%= @document.id %>');
});
function expand_reply(container, btnid) {
var target = $(container);

@ -315,6 +315,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>

@ -100,6 +100,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');
autoUrl('reply_content_<%= reply.id %>');
});
</script>
<% replies_all_i=replies_all_i+1 %>

@ -69,6 +69,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>

@ -80,6 +80,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');
autoUrl('reply_content_<%= reply.id %>');
});
</script>
<% replies_all_i=replies_all_i + 1 %>

@ -105,6 +105,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');
autoUrl('reply_content_<%= reply.id %>');
});
</script>
<% replies_all_i=replies_all_i+1 %>

@ -89,6 +89,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>

@ -79,6 +79,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');
autoUrl('reply_content_<%= reply.id %>');
});
</script>
<% replies_all_i=replies_all_i+1 %>

@ -59,6 +59,7 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('intro_content_<%= @document.id %>');
function expand_reply(container, btnid) {
var target = $(container);
var btn = $(btnid);

@ -88,6 +88,12 @@
<ul>
<% reply_id = 0 %>
<% comments_for_doc.each do |comment| %>
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% reply_id += 1 %>
<li style="display:<%= reply_id > 3 ? 'none' : '' %>">
<div class="homepagePostReplyPortrait"><%= link_to image_tag(url_to_avatar(User.find(comment.creator_id)), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_id) %></div>
@ -104,7 +110,7 @@
</span>
</div>
<% unless comment.content.blank? %>
<div class="homepagePostReplyContent"><%= comment.content.html_safe %></div>
<div class="homepagePostReplyContent" id="reply_content_<%= comment.id %>"><%= comment.content.html_safe %></div>
<% end %>
</div>
<div class="cl"></div>

@ -69,6 +69,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>

@ -97,6 +97,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<% user = User.find(reply.creator_id) %>
@ -164,6 +165,7 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('intro_content_<%= @document.id %>');
var replyCount = $(".homepagePostReplyContainer").size();
if (replyCount >3){
for(var i= 3; i < replyCount+1; i++){

@ -321,6 +321,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>

@ -56,6 +56,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>

@ -117,6 +117,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');
autoUrl('reply_content_<%= reply.id %>');
});
</script>
<% replies_all_i=replies_all_i+1 %>

@ -94,6 +94,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>

@ -13,9 +13,7 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
// autoUrl('intro_content_<%#= user_activity_id%>');
autoUrl('intro_content_<%= user_activity_id%>');
description_show_hide(<%=user_activity_id %>);
});
</script>

@ -29,6 +29,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');
autoUrl('reply_content_<%= reply.id %>');
});
</script>
<% replies_all_i=replies_all_i + 1 %>

@ -112,6 +112,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= reply.id %>');
autoUrl('reply_content_<%= reply.id %>');
});
</script>
<% replies_all_i=replies_all_i+1 %>

@ -91,6 +91,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>

@ -75,6 +75,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>

@ -331,6 +331,7 @@
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>

@ -86,6 +86,12 @@
<div class="" id="reply_div_<%= user_activity_id %>">
<ul>
<% fetch_user_leaveWord_reply(activity).reorder("created_on desc").each do |comment| %>
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= user_activity_id %>');
autoUrl('reply_content_<%= user_activity_id %>');
});
</script>
<% replies_all_i = replies_all_i + 1 %>
<li class="homepagePostReplyContainer" nhname="reply_rec" onmouseover="$('#message_delete_<%= comment.id%>').show();" onmouseout="$('#message_delete_<%= comment.id%>').hide();" style="display:<%= replies_all_i > 3 ? 'none' : '' %>">
<div class="homepagePostReplyPortrait">

@ -1318,16 +1318,7 @@ function pop_up_box(value,tWidth,tTop,tLeft){
//yk 自动识别URL 并加上链接
var strRegex = '((https|http|ftp|rtsp|mms)?://)'
+ '?(([0-9a-z_!~*\'().&=+$%-]+: )?[0-9a-z_!~*\'().&=+$%-]+@)?' //ftp的user@
+ '(([0-9]{1,3}.){3}[0-9]{1,3}' // IP形式的URL- 199.194.52.184
+ '|' // 允许IP和DOMAIN域名
+ '([0-9a-z_!~*\'()-]+.)*' // 域名- www.
+ '([0-9a-z][0-9a-z-]{0,61})?[0-9a-z].' // 二级域名
+ '[a-z]{2,6})' // first level domain- .com or .museum
+ '(:[0-9]{1,4})?' // 端口- :80
+ '((/?)|' // a slash isn't required if there is no file name
+ '(/[0-9a-z_!~*\'().;?:@&=+$,%#-]+)+/?)';
//var strRegex = '((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+([a-z]{3}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?';
function autoUrl(id){
if ($("#"+id).children().length > 0 ){
@ -1335,17 +1326,20 @@ function autoUrl(id){
if ($(this).children().length == 0){
var html = $(this).text(); //.replace(/(^\s*)|(\s*$)/g, "")
console.log("html="+html);
var re=new RegExp(strRegex,"g");
html = html.replace(re,function(full) {
// var re=new RegExp(strRegex,"g");
html = html.replace(/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+([a-z]{3}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?/g,function(full) {
//没有://的都加上http://
if (full.indexOf("://") >= 0){
var reStr = "<a target='_Blank' href="+"'"+full+"'"+">"+full+"</a>";
var reStr = full;
if (full.length > 0){
if (full.indexOf("://") >= 0){
reStr = "<a target='_Blank' href="+"'"+full+"'"+">"+full+"</a>";
}
else{
reStr = "<a target='_Blank' href="+"'http://"+full+"'"+">"+full+"</a>";
}
console.log("reStr="+reStr);
}
else{
var reStr = "<a target='_Blank' href="+"'http://"+full+"'"+">"+full+"</a>";
}
console.log("reStr="+reStr);
return reStr;
return reStr ;
});
$(this).html(html);
}
@ -1353,18 +1347,21 @@ function autoUrl(id){
}
else{
var html = $("#"+id).text(); //.replace(/(^\s*)|(\s*$)/g, "")
console.log("html="+html);
var re=new RegExp(strRegex,"g");
html = html.replace(re,function(full) {
//没有://的都加上http://
if (full.indexOf("://") >= 0){
var reStr = "<a target='_Blank' href="+"'"+full+"'"+">"+full+"</a>";
}
else{
var reStr = "<a target='_Blank' href="+"'http://"+full+"'"+">"+full+"</a>";
console.log("!!!!html="+html);
// var re=new RegExp(strRegex,"g");
html = html.replace(/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+([a-z]{3}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?/g,function(full) {
//没有://的都加上http://
var reStr = full;
if (full.length > 0){
if (full.indexOf("://") >= 0){
reStr = "<a target='_Blank' href="+"'"+full+"'"+">"+full+"</a>";
}
else{
reStr = "<a target='_Blank' href="+"'http://"+full+"'"+">"+full+"</a>";
}
console.log("reStr="+reStr);
}
console.log("reStr="+reStr);
return reStr;
return reStr ;
});
$("#"+id).html(html);
}

@ -1457,7 +1457,7 @@ span.at a{color:#269ac9;text-decoration: none;}
.pic_edit2:hover{display:inline-block; background:url(../images/public_icon.png) -32px -32px no-repeat; width:20px; height:15px;}
.w70{ width:70px;}
.w80{ width:80px;}
.label03{ width:70px; text-align:right; display:block; float:left;}
.label03{ width:70px; text-align:right; display:block; float:left;white-space: nowrap;}
.pro_info_p{color:#0781b4 !important; float:left; width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; }
.proInfoP{color:#000000 !important; float:left; width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; }

@ -470,7 +470,7 @@ a:hover.st_add{ color:#ff8e15;}
.newpro_box select{ height:29px; float:left; margin-bottom:10px;}
/*.label{ width:80px; text-align:right; font-size:14 background-image: url(../images/true.png); }*/
.label02{ width:110px; text-align:right; font-size:14px; display:block; float:left;}
.label03{ width:70px; text-align:right; display:block; float:left;}
.label03{ width:70px; text-align:right; display:block; float:left;white-space: nowrap;}
.collapsible{ border-left:none;border-right:none;border-bottom:none; border-top:1px solid #e4e4e4; padding-top:10px; }
.icon-reload { background-image: url(../images/reload.png); }
.icon {

Loading…
Cancel
Save