表情提交
This commit is contained in:
@@ -526,6 +526,7 @@ $(".commentReleaseBox a").on("click", function () {
|
||||
|
||||
function addComment(){
|
||||
var content = $(".commentReleaseBox input").val();
|
||||
content = utf16toEntities(content);
|
||||
axios.post("/rest/comment/add",{commentObjId : id, content:content, commentUserProvince:province, commentUserCity:city}).then(function (response) {
|
||||
var msg = response.data.message
|
||||
if(msg){
|
||||
@@ -540,6 +541,25 @@ function addComment(){
|
||||
});
|
||||
}
|
||||
|
||||
function utf16toEntities(str) {
|
||||
var patt = /[\ud800-\udbff][\udc00-\udfff]/g; // 检测utf16字符正则
|
||||
str = str.replace(patt, function(char) {
|
||||
var H, L, code;
|
||||
if (char.length === 2) {
|
||||
H = char.charCodeAt(0);
|
||||
// 取出高位
|
||||
L = char.charCodeAt(1);
|
||||
// 取出低位
|
||||
code = (H - 0xD800) * 0x400 + 0x10000 + L - 0xDC00;
|
||||
//转换算法
|
||||
return "&#" + code + ";";
|
||||
} else {
|
||||
return char;
|
||||
}
|
||||
});
|
||||
return str;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$('#commentInput').on('click', function () {
|
||||
var target = this;
|
||||
|
||||
Reference in New Issue
Block a user