Authored by 王水玲

帮助中心修改

... ... @@ -9,11 +9,16 @@ var cutStr = function(params) {
var strCut = '';
var i, curStr, addTxt, strLen;
params.str = params.str.replace(/\s/g, '');
params.str = params.str.replace(/<[^>]*>/g, '');
params.str = params.str.replace(/&nbsp;/ig, '');
params.str = params.str.replace(/(?=[^>]*(?=<))\s+/g, '');
params.str = params.str.replace(/<(?!a|\/a).*?>/g, '');
strLen = params.str.length || 0;
if (!strLen) {
return '';
}
if (params.type === 2) {
addTxt = '';
} else {
... ... @@ -22,7 +27,6 @@ var cutStr = function(params) {
for (i = 0; i < strLen; i++) {
curStr = params.str.charAt(i);
curStr = params.str.charAt(i);
strLength++;
if (escape(curStr).length > 4) {
// 中文字符的长度经编码之后大于4
... ... @@ -46,8 +50,12 @@ var cutStr = function(params) {
var keywordLabel = function(str, key) {
var reg = new RegExp(key, 'gm');
if (str === '') {
return str;
}
str = str.replace(reg, '<i class="keyword">' + key + '</i>');
return str.replace('www.yohobuy.com', '<a href="http://www.yohobuy.com" class="keyword">www.yohobuy.com</a>');
return str;
};
exports.cutStr = cutStr;
... ...
... ... @@ -38,14 +38,14 @@ if (keywords) {
s.problem = true;
}
if (s.secendCategoryId === '0') {
if (parseInt(s.secendCategoryId, 10) === 0) {
id = s.firstCategoryId;
} else {
id = s.secendCategoryId;
}
s.content = helper.cutStr({
str: s.content,
len: 380,
len: 375,
type: s.helperType,
url: '/help/detail?id=' + id + '&contId=' + s.id
});
... ...
... ... @@ -235,6 +235,10 @@
margin-top: 17px;
line-height: 22px;
}
img {
display: inline-block;
}
}
}
... ...