|
|
//function ordertour(code){
|
|
|
// var url='/orders/tour';
|
|
|
// $('#PostForm').empty();
|
|
|
// var myformObj = $("<form id="PostForm" method="POST" action=""+url+"" ></form>");
|
|
|
// myformObj.append("<input name='tour_code' type='hidden' value='"+code+"' />");
|
|
|
// myformObj.appendTo("body");
|
|
|
// setTimeout('$("#PostForm").submit()',1);
|
|
|
//}
|
|
|
function information_check() {
|
|
|
$("#error-tops").html('');
|
|
|
var flag = true;
|
|
|
var unsubmit_flag=true;
|
|
|
|
|
|
if ($("#ic_status").val() == 0) {
|
|
|
return true;
|
|
|
}
|
|
|
if ($("#ic_url").val() == '') {
|
|
|
return true;
|
|
|
}
|
|
|
var sitecode = $("#is_sitecode").val();
|
|
|
var siteurl = $("#site_url").val();
|
|
|
//title长度
|
|
|
var title = '';
|
|
|
title = $("#ic_seo_title").val();
|
|
|
var title_length = get_string_length(title);
|
|
|
if (sitecode == 'jp' || sitecode == 'ru') title_length = parseInt(title_length / 2);
|
|
|
if (title_length < 20 || title_length > 60) {
|
|
|
$("#error-tops").append('<li><small>SEO标题长度必须在20~60个字符之间[' + title_length + '个]</small></li>');
|
|
|
flag = false;
|
|
|
}
|
|
|
|
|
|
//description长度
|
|
|
var description = $("#ic_seo_description").val();
|
|
|
var description_length = get_string_length(description);
|
|
|
if (sitecode == 'jp' || sitecode == 'ru') description_length = parseInt(description_length / 2);
|
|
|
if (description_length < 80 || description_length > 160) {
|
|
|
$("#error-tops").append('<li><small>SEO描述长度必须在80~160个字符之间[' + description_length + '个]</small></li>');
|
|
|
flag = false;
|
|
|
}
|
|
|
|
|
|
//信息备注og:description长度
|
|
|
var og_description = $("#meta_note").val();
|
|
|
var og_description_length = get_string_length(og_description);
|
|
|
if (sitecode == 'jp' || sitecode == 'ru') og_description_length = parseInt(og_description_length / 2);
|
|
|
if (og_description_length < 80 || og_description_length > 160) {
|
|
|
$("#error-tops").append('<li><small>og:description信息备注长度必须在80~160个字符之间[' + og_description_length + '个]</small></li>');
|
|
|
flag = false;
|
|
|
}
|
|
|
|
|
|
//文章字数
|
|
|
var content_num = content_length;
|
|
|
if (content_num < 1500) {
|
|
|
$("#error-tops").append('<li><small>文章字数不能少于1500字[' + content_num + '字]</small></li>');
|
|
|
flag = false;
|
|
|
}
|
|
|
|
|
|
//链接数量a_num
|
|
|
var content = $("#ic_content").val();
|
|
|
var a_num = 0;
|
|
|
var inner_link = 0;
|
|
|
$(content).find('a').each(function() {
|
|
|
var nofollow = $(this).attr('nofollow');
|
|
|
if (!nofollow) {
|
|
|
a_num++;
|
|
|
}
|
|
|
var a_href = $(this).attr('href');
|
|
|
if (a_href) {
|
|
|
if (a_href.indexOf('http') == -1 || a_href.indexOf(siteurl) != -1)
|
|
|
inner_link++;
|
|
|
}
|
|
|
//是否空链接
|
|
|
var a_text = $(this).html().replace(/[ ]/g, "");;
|
|
|
if (a_text.length == 0) {
|
|
|
if (a_href) {
|
|
|
$("#error-tops").append('<li><small>"第' + a_num + '个链接href=' + a_href + '是空链接"</small></li>');
|
|
|
flag = false;
|
|
|
unsubmit_flag=false;
|
|
|
}
|
|
|
}
|
|
|
//url中是否有特殊字符
|
|
|
var reg = RegExp(/[(\!)(\^)(\()(\))(\[)(\])(\{)(\})(\|)(\;)(\')(\")(\,)(\<)(\>)( )]+/);
|
|
|
if (reg.test(a_href)) {
|
|
|
$("#error-tops").append('<li><small>"第' + a_num + '个链接href=' + a_href + '中有特殊字符"</small></li>');
|
|
|
flag = false;
|
|
|
}
|
|
|
});
|
|
|
if (a_num > 50) {
|
|
|
$("#error-tops").append('<li><small>链接数量不能超过50个[' + a_num + '个]</small></li>');
|
|
|
flag = false;
|
|
|
}
|
|
|
//有且只有一个H1标签
|
|
|
var h1_count = 0;
|
|
|
var img_alt_tips = '';
|
|
|
$(content).find('h1').each(function() {
|
|
|
h1_count++;
|
|
|
//H1与Title的第一个关键词一致
|
|
|
if (h1_count == 1) {
|
|
|
var h1_content = $(this).text();
|
|
|
h1_content = $.trim(h1_content);
|
|
|
title = title.split(',')[0];
|
|
|
title = $.trim(title);
|
|
|
if (h1_content.toLowerCase() != title.toLowerCase()) {
|
|
|
$("#error-tops").append('<li><small>H1与Title的第一个关键词不相同</small></li>');
|
|
|
flag = false;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
if (h1_count < 1) {
|
|
|
$(content).filter('h1').each(function() {
|
|
|
h1_count++;
|
|
|
//H1与Title的第一个关键词一致
|
|
|
if (h1_count == 1) {
|
|
|
var h1_content = $(this).text();
|
|
|
h1_content = $.trim(h1_content);
|
|
|
title = title.split(',')[0];
|
|
|
title = $.trim(title);
|
|
|
if (h1_content.toLowerCase() != title.toLowerCase()) {
|
|
|
img_alt_tips = '{"name":"h1_content","value":""},';
|
|
|
$("#error-tops").append('<li><small>H1与Title的第一个关键词不相同</small></li>');
|
|
|
flag = false;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
if (h1_count > 1) {
|
|
|
$("#error-tops").append('<li><small>有且只能有一个H1标签[' + h1_count + '个]</small></li>');
|
|
|
flag = false;
|
|
|
}
|
|
|
|
|
|
//非强制性、提醒检测
|
|
|
|
|
|
//文章内链数:500字的文章1-3个链接,1000字的文章2-6个链接,以此类推
|
|
|
var display_count = $("#display_count").text();
|
|
|
if (display_count <= 500 && (inner_link < 1 || inner_link > 3)) {
|
|
|
$("#error-tops").append('<li><small>内链数应该在1~3之间 [' + inner_link + '个]</small></li>');
|
|
|
} else if (500 < display_count && display_count <= 1000 && (inner_link < 2 || inner_link > 6)) {
|
|
|
$("#error-tops").append('<li><small>内链数应该在2~6之间 [' + inner_link + '个]</small></li>');
|
|
|
} else if (1000 < display_count && display_count <= 1500 && (inner_link < 4 || inner_link > 9)) {
|
|
|
$("#error-tops").append('<li><small>内链数应该在4~9之间 [' + inner_link + '个]</small></li>');
|
|
|
} else if (display_count > 1500 && (inner_link < 6 || inner_link > 12)) {
|
|
|
$("#error-tops").append('<li><small>内链数应该在6~12之间 [' + inner_link + '个]</small></li>');
|
|
|
}
|
|
|
|
|
|
//是否有图片,图片是否有alt
|
|
|
var img_num = 0;
|
|
|
$(content).find('img').each(function() {
|
|
|
var alt = $(this).attr('alt');
|
|
|
if (!alt) {
|
|
|
$("#error-tops").append('<li><small>' + $(this).attr('src') + '该图片没有alt关键字</small></li>');
|
|
|
flag = false;
|
|
|
unsubmit_flag=false;
|
|
|
}
|
|
|
img_num++;
|
|
|
});
|
|
|
if (img_num < 1) {
|
|
|
$(content).filter('img').each(function() {
|
|
|
var alt = $(this).attr('alt');
|
|
|
if (!alt) {
|
|
|
$("#error-tops").append('<li><small>' + $(this).attr('src') + '该图片没有alt关键字</small></li>');
|
|
|
flag = false;
|
|
|
unsubmit_flag=false;
|
|
|
}
|
|
|
img_num++;
|
|
|
});
|
|
|
}
|
|
|
if (img_num < 1) {
|
|
|
$("#error-tops").append('<li><small>文章中没有使用图片</small></li>');
|
|
|
flag = false;
|
|
|
}
|
|
|
//打开错误提示区域
|
|
|
if (!flag) {
|
|
|
$(".error-tips").removeClass('hide');
|
|
|
}
|
|
|
if (!unsubmit_flag) {
|
|
|
//alert('文章存在空链接或者有图片没有填写Alt关键字,请完成后再进行提交');
|
|
|
$("#rule_check_flag").val('0');
|
|
|
}else{
|
|
|
$("#rule_check_flag").val('1');
|
|
|
}
|
|
|
return unsubmit_flag;
|
|
|
}
|
|
|
|
|
|
//http://jquery.malsup.com/form/
|
|
|
function submitForm(form) {
|
|
|
$('#' + form).ajaxSubmit({
|
|
|
success:successfun,
|
|
|
error: errorfun,
|
|
|
dataType: 'json',
|
|
|
timeout: 30000
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
function errorfun(responseText, statusText, xhr, form) {
|
|
|
|
|
|
$.modaldialog.error('Action unsuccessful. Try again later.');
|
|
|
}
|
|
|
|
|
|
|
|
|
function successfun(responseText, statusText, xhr, form) {
|
|
|
|
|
|
for (var key in responseText) {
|
|
|
|
|
|
if (responseText[key].name == 'ok') {
|
|
|
//window.location.href=responseText[key].value;
|
|
|
//showTips(form.attr('id'),'ok');
|
|
|
|
|
|
//判断是否自动更新缓存
|
|
|
if ($("#rule_check_flag").val()==1 && $('#auto_update_cache_checkbox').attr("checked")) {
|
|
|
$.modaldialog.success(responseText[key].value + 'n' + '\u9759\u6001\u9875\u9762\u66f4\u65b0\u4e2d...');
|
|
|
updateCache($('#auto_update_cache_checkbox').val(), '');
|
|
|
} else {
|
|
|
$.modaldialog.success(responseText[key].value);
|
|
|
/*setTimeout(function() {
|
|
|
$("#dialog-close").trigger('click');
|
|
|
}, 1500);*/
|
|
|
}
|
|
|
} else if (responseText[key].name == 'ok_go') {
|
|
|
setTimeout(function() {
|
|
|
window.location.href = responseText[key].value;
|
|
|
}, 2000);
|
|
|
} else if (responseText[key].name == 'no') {
|
|
|
$.modaldialog.error(responseText[key].value);
|
|
|
} else if (responseText[key].name == 'go') {
|
|
|
window.location.href = responseText[key].value;
|
|
|
} else if (responseText[key].name == 'ok_modal') {
|
|
|
$('.modal').modal('hide');
|
|
|
$.modaldialog.success(responseText[key].value);
|
|
|
} else if (responseText[key].name == 'no_modal') {
|
|
|
$('.modal').modal('hide');
|
|
|
$.modaldialog.error(responseText[key].value);
|
|
|
} else {
|
|
|
var url = window.location.href;
|
|
|
window.location.href = url.replace(/#warning/g, '') + '#warning';
|
|
|
showTips(responseText[key].name, responseText[key].value);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
function showTips(objName, title) {
|
|
|
/*
|
|
|
$('#'+objName).poshytip({
|
|
|
content:title,
|
|
|
timeOnScreen:5000,
|
|
|
className: 'tip-yellow',
|
|
|
showOn: 'none',
|
|
|
alignTo: 'target',
|
|
|
alignX: 'right',
|
|
|
alignY:'center'
|
|
|
});
|
|
|
$('#'+objName).poshytip('show');
|
|
|
$('#'+objName).focus(function(){
|
|
|
$('#'+objName).poshytip('hide');
|
|
|
});
|
|
|
*/
|
|
|
$('#' + objName).tooltip({
|
|
|
title: title,
|
|
|
placement: 'top',
|
|
|
trigger: 'manual'
|
|
|
});
|
|
|
$('#' + objName).tooltip('show');
|
|
|
setTimeout(function() {
|
|
|
$('#' + objName).tooltip('hide');
|
|
|
}, 3000);
|
|
|
}
|
|
|
|
|
|
function updateCache(url, msg_obj) {
|
|
|
if (msg_obj == '') {
|
|
|
//$.modaldialog.error('\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u8054\u7cfbYCC');
|
|
|
} else {
|
|
|
$('#' + msg_obj).html('\u7a0d\u7b49...');
|
|
|
}
|
|
|
var updatecdn = $('#updatecdn_byhand').val();
|
|
|
$('#updatecdn_byhand').val('');
|
|
|
|
|
|
$.ajax({
|
|
|
type: "post",
|
|
|
dataType: "json",
|
|
|
url: "/info.php/information/update_cache/",
|
|
|
data: {
|
|
|
'cache_url': url,
|
|
|
'updatecdn': updatecdn
|
|
|
},
|
|
|
success: function(data, textStatus) {
|
|
|
for (var key in data) {
|
|
|
if (data[key].name == 'ok') {
|
|
|
if (msg_obj == '') {
|
|
|
$.modaldialog.success(data[key].value);
|
|
|
} else {
|
|
|
$('#' + msg_obj).html(data[key].value);
|
|
|
}
|
|
|
return true;
|
|
|
} else {
|
|
|
if (msg_obj == '') {
|
|
|
$.modaldialog.success(data[key].value);
|
|
|
} else {
|
|
|
$('#' + msg_obj).html(data[key].value);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},
|
|
|
error: function() {
|
|
|
if (msg_obj == '') {
|
|
|
$.modaldialog.error('\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u8054\u7cfbYCC');
|
|
|
} else {
|
|
|
$('#' + msg_obj).html('\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u8054\u7cfbYCC');
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
//主要用于跨域请求
|
|
|
function update_cache(domain, url, msg_obj) {
|
|
|
$('#' + msg_obj).html('\u7a0d\u7b49...');
|
|
|
|
|
|
var cache_url;
|
|
|
if (domain == 'http://www.chinahighlights.com') {
|
|
|
cache_url = url.replace("http://www.chinahighlights.com", "http://174.132.46.155:7788") + '@cache@refresh';
|
|
|
} else if (domain == 'http://www.chinarundreisen.com' || domain == 'http://www.voyageschine.com' || domain == 'http://www.arachina.com' || domain == 'http://www.chinahighlights.ru' || domain == 'http://www.viaje-a-china.com' || domain == 'http://www.viaggio-in-cina.it') {
|
|
|
cache_url = domain + '/index.php/welcome/update_cache?static_html_url=' + url.replace(domain, '');
|
|
|
} else {
|
|
|
cache_url = domain + url + '@cache@refresh';
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
url: cache_url,
|
|
|
type: "GET",
|
|
|
dataType: 'jsonp',
|
|
|
jsonp: 'callback',
|
|
|
timeout: 5000,
|
|
|
success: function(jsondata) {
|
|
|
for (var key in jsondata) {
|
|
|
if (jsondata[key].name == 'ok') {
|
|
|
$('#' + msg_obj).html('\u66f4\u65b0\u6210\u529f');
|
|
|
return true;
|
|
|
}
|
|
|
if (jsondata[key].name == 'no') {
|
|
|
$('#' + msg_obj).html(jsondata[key].value);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
$('#' + msg_obj).html('\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u8054\u7cfbYCC... <a href="' + cache_url + '" target="_blank">u67e5u770bu9519u8bef</a>');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
//自定义选项设置
|
|
|
function meta(meta_act, im_ic_id, im_key, im_value) {
|
|
|
if (meta_act == 'save') {
|
|
|
var url = "/info.php/information/save_meta";
|
|
|
}
|
|
|
if (meta_act == 'delete') {
|
|
|
if (confirm('\u662f\u5426\u5220\u9664?')) {
|
|
|
var url = "/info.php/information/delete_meta";
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
$.ajax({
|
|
|
type: "post",
|
|
|
dataType: "json",
|
|
|
url: url,
|
|
|
data: {
|
|
|
'im_ic_id': im_ic_id,
|
|
|
'im_key': im_key,
|
|
|
'im_value': im_value
|
|
|
},
|
|
|
success: function(data, textStatus) {
|
|
|
for (var key in data) {
|
|
|
if (data[key].name == 'ok') {
|
|
|
$.modaldialog.success(data[key].value);
|
|
|
return true;
|
|
|
} else {
|
|
|
$.modaldialog.error(data[key].value);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
$.modaldialog.error('\u53d1\u751f\u9519\u8bef\uff0c\u8bf7\u8054\u7cfbYCC...');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
function getWordCount(text) {
|
|
|
text = text.replace(/<img(.*)>/g, ' img '); //图片算一个字符
|
|
|
text = text.replace(/,/g, ' '); //标点换成分隔符
|
|
|
text = text.replace(/\./g, ' '); //标点换成分隔符
|
|
|
text = text.replace(/\?/g, ' '); //标点换成分隔符
|
|
|
text = text.replace(/\!/g, ' '); //标点换成分隔符
|
|
|
text = text.replace(/\:/g, ' '); //标点换成分隔符
|
|
|
text = text.replace(/[;]/g, ' '); //标点换成分隔符
|
|
|
|
|
|
text = text.replace(/\n|\r\s+$/g, ' '); //换行符换成分隔符
|
|
|
if ($("input[name='ic_sitecode']").val() != 'ru') {
|
|
|
text = text.replace(/[^\x00-\xff]/g, ' text '); //计算双字节字符(中文、日文)字数
|
|
|
};
|
|
|
|
|
|
text = text.replace(/(^\s*)|(\s*$)/g, ""); //去除两端空格
|
|
|
text = text.replace(/\s+/g, " "); //一个或多个空格换成一个分隔符
|
|
|
return text.split(' ').length; //计算字符数
|
|
|
}
|
|
|
|
|
|
function get_string_length(str) {
|
|
|
var realLength = 0,
|
|
|
len = str.length,
|
|
|
charCode = -1;
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
charCode = str.charCodeAt(i);
|
|
|
if (charCode >= 0 && charCode <= 128) realLength += 1;
|
|
|
else realLength += 2;
|
|
|
}
|
|
|
return realLength;
|
|
|
}
|
|
|
|
|
|
function change_seo_count(element) {
|
|
|
var length = get_string_length($("#" + element).val());
|
|
|
var sitecode = $("#is_sitecode").val();
|
|
|
if (sitecode == 'jp' || sitecode == 'ru') length = parseInt(length / 2);
|
|
|
$("#" + element + "_count").text(length);
|
|
|
}
|
|
|
|
|
|
//异步获取任务列表
|
|
|
function get_ajax_reviewed_list(formid, container, flag) {
|
|
|
$("#" + container).html('<img src="/css/images/loading.gif" >');
|
|
|
if (flag) {
|
|
|
var url = formid;
|
|
|
var data = {};
|
|
|
} else {
|
|
|
var url = $("#" + formid).attr('action');
|
|
|
var data = $("#" + formid).serialize();
|
|
|
}
|
|
|
$("#" + container).load(url + ' #' + container, data);
|
|
|
} |