欢迎语的表情替换

pull/23/head
taoshihan1991 3 years ago
parent 987088ae3a
commit ba8a90f048

@ -62,7 +62,10 @@ function placeFace() {
}
return faces;
}
function replaceContent (content) {// 转义聊天内容中的特殊字符
function replaceContent (content,baseUrl) {// 转义聊天内容中的特殊字符
if(typeof baseUrl=="undefined"){
baseUrl="";
}
var faces=placeFace();
var html = function (end) {
return new RegExp('\\n*\\[' + (end || '') + '(pre|div|span|p|table|thead|th|tbody|tr|td|ul|li|ol|li|dl|dt|dd|h2|h3|h4|h5)([\\s\\S]*?)\\]\\n*', 'g');
@ -71,7 +74,7 @@ function replaceContent (content) {// 转义聊天内容中的特殊字符
.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/'/g, '&#39;').replace(/"/g, '&quot;') // XSS
.replace(/face\[([^\s\[\]]+?)\]/g, function (face) { // 转义表情
var alt = face.replace(/^face/g, '');
return '<img alt="' + alt + '" title="' + alt + '" src="' + faces[alt] + '">';
return '<img alt="' + alt + '" title="' + alt + '" src="'+baseUrl + faces[alt] + '">';
})
.replace(/img\[([^\s\[\]]+?)\]/g, function (face) { // 转义图片
var src = face.replace(/^img\[/g, '').replace(/\]/g, '');;

@ -102,6 +102,7 @@ GOFLY.clickBtn=function (){
},4000);
}
GOFLY.getNotice=function(){
var _this=this;
$.get(this.GOFLY_URL+"/notice?kefu_id="+this.GOFLY_KEFU_ID,function(res) {
//debugger;
if (res.result != null) {
@ -116,7 +117,7 @@ GOFLY.getNotice=function(){
if(typeof content.content =="undefined"){
return;
}
$("#launchButtonNotice").html(replaceContent(content.content)).show();
$("#launchButtonNotice").html(replaceContent(content.content,_this.GOFLY_URL)).show();
}
}

Loading…
Cancel
Save