');
}
//是否有图片,图片是否有alt
var img_num = 0;
$(content).find('img').each(function() {
var alt = $(this).attr('alt');
if (!alt) {
$("#error-tops").append('
' + $(this).attr('src') + '该图片没有alt关键字
');
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('
' + $(this).attr('src') + '该图片没有alt关键字
');
flag = false;
unsubmit_flag=false;
}
img_num++;
});
}
if (img_num < 1) {
$("#error-tops").append('
文章中没有使用图片
');
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... u67e5u770bu9519u8bef');
}
});
}
//自定义选项设置
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(//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('');
if (flag) {
var url = formid;
var data = {};
} else {
var url = $("#" + formid).attr('action');
var data = $("#" + formid).serialize();
}
$("#" + container).load(url + ' #' + container, data);
}