$(document).ready(function() {
var count =0;
var dat_1 =0;
var countplus = 0;
var htm = "";
// $.ajax({
// type : "get",
// url : "http://shouce.coolchuan.com/api/newarticles",
// data:"{}",
// dataType : "jsonp",
// jsonp : "callback",
// jsonpCallback:"get_artiles",
// async: false,
// success: function(dat){
// $.each(dat,function(key,val){
// count ++;
// //console.log(count);
// })
// if (dat) dat_1 = dat[1].id;
// if( count==0){ //没有新文章
// }else if(count==1){ //只有一篇新文章
// htm += ""+dat[1].title+""+dat[1].data.slice(5)+"";
// htm += "更多";
// }else if( count>=2){ //多篇新文章
// htm += ""+dat[1].title+""+dat[1].data.slice(5)+"";
// for (var i = 2; i <=Math.min(count,5) ; i++) {
// htm += ""+ dat[i].title +"" + dat[i].data.slice(5) + "";
// };
// htm += "更多";
// };
// $(".gengxinwenzhang").html(htm);
// //console.log(dat[1].id);
// if($.cookie('new_id')){
// //var mm = $.cookie('new_id');
// countplus = dat[1].id-$.cookie('new_id');
// if(countplus>99){countplus=99};
// if (countplus!=0) {
// $(".red_new").html(countplus).css('display','inline');
// $('#tuiguangshouce .smalltri').hide();
// }else{
// $(".red_new").html(countplus).css('display','none');
// $('#tuiguangshouce .smalltri').show();
// }
// }else{
// if(count>99){count=99};
// if (count!=0) {
// $(".red_new").html(count).css('display','inline');
// $('#tuiguangshouce .smalltri').hide();
// }else{
// $(".red_new").html(count).css('display','none');
// $('#tuiguangshouce .smalltri').show();
// }
// }
// //系统语言不是中文,跳转到英文页面
//
// }
// });
/* $("#shouce_hover").mouseenter(function(){
$(".gengxinwenzhang").stop().slideDown(100);
}).mouseleave(function(){
$(".gengxinwenzhang").stop().slideUp(100);
}).click(function(){
$.cookie('new_id',dat_1,{ expires:-1 });
$.cookie('new_id',dat_1,{ expires:30,path:'/',domain:'coolchuan.com' });
})*/
if (navigator.userLanguage) {
if (navigator.userLanguage!='zh-CN' && navigator.userLanguage!='zh-cn' && !($.cookie('foreinglang'))) {
// window.location.href="http://appstochina.com";
$.cookie('foreinglang','1',{expires:300,path:'/',domain:'coolchuan.com'})
}
}else if (navigator.languages && navigator.languages[1]!='zh' && !($.cookie('foreinglang'))) {
// window.location.href="http://appstochina.com";
$.cookie('foreinglang','1',{expires:300,path:'/',domain:'coolchuan.com'})
}
//应用推广服务
$("#yingyongtuiguang").mouseenter(function(){
$(".tuiguangfuwu").stop().slideDown(10);
}).mouseleave(function(){
$(".tuiguangfuwu").stop().slideUp(10);
})
$(".tuiguangfuwu").mouseenter(function(){
$(this).stop().slideDown(100)
}).mouseleave(function(){
$(this).stop().slideUp(100)
});
$("#tuiguangshouce").mouseenter(function(){
$(".gengxinwenzhang").stop().slideDown(10);
}).mouseleave(function(){
$(".gengxinwenzhang").stop().slideUp(10);
})
$(".gengxinwenzhang").click(function(){
$.cookie('new_id',dat_1,{ expires:-1 });
$.cookie('new_id',dat_1,{ expires:30,path:'/',domain:'coolchuan.com' });
}).mouseenter(function(){
$(this).stop().slideDown(10);
}).mouseleave(function(){
$(this).stop().slideUp(10);
})
//业务咨询
/* $('#fixpromote').hover(function() {
$(this).find('dl').removeClass('none')
},function() {
$(this).find('dl').addClass('none')
})*/
/* var uesrID = $(".big_notice").attr("data-uid");
$.get("/api/get_claimer?uid="+uesrID,function(res){
if (res.status == 200) {
$(".big_notice").show().find("b").html(res.title)
}
})
$(".big_notice .closenotice").click(function(){
$(".big_notice").hide()
$.get("/api/cancel_claim?uid="+uesrID)
})*/
var neihe = getBrowser("n"),
banben = getBrowser("v");
if (neihe=="ie" && banben<7){
setTimeout(function(){
if (!($.cookie('lowVersion'))) {
$.cookie('lowVersion',"1",{ expires:0.05,path:'/',domain:'coolchuan.com' });
K.alert("当前浏览器版本过低,升级浏览器后可正常使用酷传所有功能!")
}
},2000)
}
/*获取浏览器版本号+内核
var neihe = getBrowser("n"); 所获得的就是浏览器所用内核。
var banben = getBrowser("v"); 所获得的就是浏览器的版本号。
var browser = getBrowser(); 所获得的就是浏览器内核加版本号*/
function getBrowser(n) {
var ua = navigator.userAgent.toLowerCase(),
s,
name = '',
ver = 0;
//探测浏览器
(s = ua.match(/msie ([\d.]+)/)) ? _set("ie", _toFixedVersion(s[1])):
(s = ua.match(/firefox\/([\d.]+)/)) ? _set("firefox", _toFixedVersion(s[1])) :
(s = ua.match(/chrome\/([\d.]+)/)) ? _set("chrome", _toFixedVersion(s[1])) :
(s = ua.match(/opera.([\d.]+)/)) ? _set("opera", _toFixedVersion(s[1])) :
(s = ua.match(/version\/([\d.]+).*safari/)) ? _set("safari", _toFixedVersion(s[1])) : 0;
function _toFixedVersion(ver, floatLength) {
ver = ('' + ver).replace(/_/g, '.');
floatLength = floatLength || 1;
ver = String(ver).split('.');
ver = ver[0] + '.' + (ver[1] || '0');
ver = Number(ver).toFixed(floatLength);
return ver;
}
function _set(bname, bver) {
name = bname;
ver = bver;
}
return (n == 'n' ? name : (n == 'v' ? ver : name + ver));
}
});
/* 埋点,统计页面加载时间 */
function getLoadTime(appName,step) {
// 定义兼容的注册监听方法
var addEvent = (function (){
if(document.addEventListener){ // 火狐/谷歌
return function (ele,eventName,fn,isCapture) {
ele.addEventListener(eventName,fn,false);
};
}else{ //IE
return function (ele,eventName,fn) {
ele.attachEvent('on'+eventName,function () {
return fn.call(ele,window.event);
})
}
}
})();
var startTime = Date.now();
//注册事件,兼容IE
addEvent(window,'load',function () {
var endTime = Date.now();
var loadTime = endTime - startTime;
var pathName = window.location.pathname;
var params = {
type : 'pageloadtime',
label : '成功-' + loadTime
};
if (appName || step){
params.opra = pathName + '+' + appName + '+' + step;
} else {
params.opra = pathName;
}
$.ajax({
type:"get",
url:"http://publish.kuchuan.com/other/write-other-log",
data:params,
dataType: 'jsonp',
jsonp: 'callback',
success:function (data) {
//data = eval('('+data+')');
if(200 == data.status){
console.log('*******************' + JSON.stringify(params));
}else{
console.log("err")
}
}
});
});
}
getLoadTime()