//ajax/json cors跨域开关 $.support.cors = true; // (function () { firstUid = (+new Date()) + Math.random().toString(10).substring(2, 6) var tpopData = { list_log: 'list_item1', tabHTML: '', newsHtml: '', listBox: '', type: '1', //1下拉加载2上拉加载 limit: '10', cat_id: '34', page: 1, num360:1, firstRender: true, sliderIndex: 1, timer: null, imptk360: [], uid: firstUid, baidu_count:0, row: { 34: ["推荐", "", 0, true,0,0,"tuijian",[]], 14: ["社会", "", 0, true,0,0,"shehui",[]], 16: ["娱乐", "", 0, true,0,0,"yule",[]], 24: ["视频", "", 0, true,0,0,"shipin",[]], 17: ["体育", "", 0, true,0,0,"tiyu",[]], 28: ["汽车", "", 0, true,0,0,"qiche",[]], 20: ["军事", "", 0, true,0,0,"junshi",[]], 18: ["财经", "", 0, true,0,0,"caijin",[]], 25: ["时尚", "", 0, true,0,0,"shishang",[]], 31: ["旅游", "", 0, true,0,0,"lvyou",[]], 32: ["美文", "", 0, true,0,0,"meiwen",[]], 13: ["笑话", "", 0, true,0,0,"xiaohua",[]], 29: ["游戏", "", 0, true,0,0,"youxi",[]], 12: ["国际", "", 0, true,0,0,"guoji",[]], 19: ["科技", "", 0, true,0,0,"keji",[]], }, refresh: true, newsHtmlFn: function (i, item) { tpopData.row[tpopData.cat_id][2] = tpopData.row[tpopData.cat_id][2] + 1 tpopData.newsHtml += '

*title

*source

'.replace("*imgUrl", item.content_img_list[0]).replace("*title", item.title.substring(0, 21)).replace("*source", item.source).replace("*href", item.url + "&tag=image_url_" + (tpopData.row[tpopData.cat_id][2]) + "_" + tpopData.row[tpopData.cat_id][6] + "T"); }, videoHtmlFn: function (i, item) { tpopData.row[tpopData.cat_id][2] = tpopData.row[tpopData.cat_id][2] + 1 tpopData.newsHtml += '

*title

*source

'.replace("*imgUrl", item.cover).replace("*title", item.title.substring(0, 21)).replace("*source", item.source).replace("*href", item.url + "&tag=image_url_" + (tpopData.row[tpopData.cat_id][2]) + "_" + tpopData.row[tpopData.cat_id][6] + "T"); }, moreImgHtml:function (i, item) { tpopData.row[tpopData.cat_id][2] = tpopData.row[tpopData.cat_id][2] + 1; var _str = '

_dec

_source

'; tpopData.newsHtml += _str.replace(/(\w*)_href(.*)_dec(.*)_imgUrl1(.*)_imgUrl2(.*)_imgUrl3(.*)_source(.*)/g,"$1"+(item.url + "&tag=image_url_" + (tpopData.row[tpopData.cat_id][2]) + "_" + tpopData.row[tpopData.cat_id][6] + "T")+"$2"+item.title.substring(0, 21)+"$3"+item.content_img_list[0]+"$4"+item.content_img_list[1]+"$5"+item.content_img_list[2]+"$6"+item.source+"$7"); }, bigHtml:function(i,item){ tpopData.row[tpopData.cat_id][2] = tpopData.row[tpopData.cat_id][2] + 1; tpopData.newsHtml += '

*title*source

'.replace("*imgUrl", item.content_img_list[0]).replace("*title", item.title.substring(0, 19)).replace("*source", item.source).replace("*href", item.url + "&tag=image_url_" + (tpopData.row[tpopData.cat_id][2]) + "_" + tpopData.row[tpopData.cat_id][6] + "T"); } } //推荐 RequestData("34"); //滑动加载数据 //index_topic mCustomScrollBox $(".scroll").bind("scroll",function (e) { var _el = $(this).find(".row"); if (_el.eq(_el.length - 5).length > 0) { if (_el.eq(_el.length - 3)[0].getBoundingClientRect().top <= 560 && tpopData.refresh) { tpopData.refresh = false; RequestData(tpopData.cat_id); } } }); //更多新闻 $(".bar_top a").on("click",function(){ tpopData.firstRender = true; if($(this).hasClass("more")){ $(".bar_more").removeClass("hide") }else{ if($(this).hasClass("active")){ return; } $(".scroll").scrollTop(0,0) tpopData.row[tpopData.cat_id][7]=[] $(".bar_more").addClass("hide") $(".bar_more a").removeClass("onClick") $(this).addClass("active").siblings().removeClass("active"); tpopData.cat_id = $(this).data("catid") tpopData.row[tpopData.cat_id][3]=true; RequestData($(this).data("catid")); } }) $(".bar_top a").on("mouseenter",function(){ if($(this).hasClass("more")){ $(".bar_more").removeClass("hide") }else{ $(".bar_more").addClass("hide") } }) $(".bar_more a").on("click",function(){ tpopData.firstRender = true; $(".scroll").scrollTop(0,0) tpopData.row[tpopData.cat_id][7]=[] tpopData.cat_id = $(this).data("catid"); tpopData.row[tpopData.cat_id][3]=true; RequestData($(this).data("catid")); $(this).addClass("onClick").siblings().removeClass("onClick"); $(".bar_top a").removeClass("active") }) $(".bar_more").on("mouseleave",function(){ $(".bar_more").addClass("hide") }); //百度广告点击上报 window.addEventListener ? window.addEventListener('blur', detectFocus, true) : window.attachEvent('onfocusout', detectFocus); function detectFocus() { var $activeElement = $(document.activeElement); var activeName = $activeElement.get(0).tagName; if (activeName.toUpperCase() === 'IFRAME') { var _parent = getParent($activeElement);//返回iframe的上一级 $.getJSON("http://ad.kuaizip.com/advertise/userclick",{ time:new Date().getTime(), localUrl:$.base64.encode("kZip.com"+location.pathname), project:$.base64.encode("tpop"), position:$.base64.encode( $(_parent[0]).attr("position")) }).done(function(data) {}); function getParent(obj) { var _parent = obj.parents(); for (var i = 0; i < _parent.length; i++) { return _parent.eq(i); } } } setTimeout("window.focus()", 50); } function RequestData(cat_id) { $.ajax({ url: 'http://news.7654.com/api/tpop/list/' + conf.qid + '/' + tpopData.type + '/' + tpopData.cat_id + '/' + tpopData.limit + '/' + tpopData.row[cat_id][1], type: 'get', dataType: 'json', success: function (data) { if (parseInt(data.status) == 1) { tpopData.refresh = true; tpopData.newsHtml = ""; tpopData.row[cat_id][1] = data.data.last_row; //初始页面数据 $.each(data.data.list, function (i, item) { if(!item.content_img_list){ tpopData.videoHtmlFn(i,item); return; } if(i == 0 || i == 3){ if(item.content_img_list.length>3){ tpopData.moreImgHtml(i, item); } }else{ tpopData.newsHtmlFn(i, item); } }); if(tpopData.row[cat_id][3]){ $("." + tpopData.list_log).html(tpopData.newsHtml); tpopData.row[cat_id][3] = false; }else{ $("." + tpopData.list_log).append(tpopData.newsHtml); } render360(tpopData.page); tpopData.page++; } else { } }, error: function (data) { window.daa = data; } }); } // 广告 function render360() { UrlParam({ of: 4, newf: 1, type: 1, showid: conf.showId, uid: tpopData.uid, reqtimes: tpopData.page, impct: conf.impct }, function (data) { var _el = $(".media_log"); if (data) { $.each(data, function (i, item) { //大图 tpopData.row[tpopData.cat_id][4] = tpopData.row[tpopData.cat_id][4] + 1; if(parseInt(item.type) == 3){ _el.eq(i).addClass("big_s").html('

'+item.title.substring(0, 16)+'广告

'); tpopData.row[tpopData.cat_id][7].push(item.imptk); }else if(parseInt(item.type) == 2){ _el.eq(i).html('

' + (item.title.substring(0, 16))+'

广告'); tpopData.row[tpopData.cat_id][7].push(item.imptk); //单图 }else if(parseInt(item.type) == 1){ _el.eq(i).html('

' + (item.title.substring(0, 16)) + '

广告
'); tpopData.row[tpopData.cat_id][7].push(item.imptk); } }); _el.removeClass("media_log"); $(".scroll").scroll(function () { if ($("." + tpopData.list_log).find('.exposure').length > 0) { if ($("." + tpopData.list_log).find('.exposure').eq(0)[0].getBoundingClientRect().top <=$(".main").height()) { $("." + tpopData.list_log).find('.exposure').eq(0).removeClass("exposure"); var arr = tpopData.row[tpopData.cat_id][7][0]; tpopData.row[tpopData.cat_id][7] = tpopData.row[tpopData.cat_id][7].slice(1,tpopData.row[tpopData.cat_id][7].length); url_scroll(arr); } } }); if ($("." + tpopData.list_log).find('.exposure').length > 0) { var count = 0,arr=[]; for(var i = 0; i<3;i++){ if ($("." + tpopData.list_log).find('.exposure').eq(0).hasClass("content_med") && $("." + tpopData.list_log).find('.exposure').eq(0)[0].getBoundingClientRect().top <=$(".scroll").height()+28 && tpopData.firstRender) { count++; $("." + tpopData.list_log).find('.exposure').eq(0).removeClass("exposure"); $.each(tpopData.row[tpopData.cat_id][7][i],function(i,item){ arr.push(item) }) } } url_scroll(arr); tpopData.row[tpopData.cat_id][7] = tpopData.row[tpopData.cat_id][7].slice(count,tpopData.row[tpopData.cat_id][7].length); } }else{ for(var i = 0; i<10;i++){ tpopData.row[tpopData.cat_id][5] = tpopData.row[tpopData.cat_id][5] + 1; tpopData.baidu_count++; _el.eq(i).append('
'); loadPjs('//www.nkscdn.com/smu0/o.js', 'b-bigbaidu_'+tpopData.baidu_count, 'bigbaidu_'+tpopData.baidu_count, "d=p&s=b&u=u3641406&w=299&h=78"); } _el.removeClass("media_log"); } tpopData.firstRender = false; }); } function loadPjs(url, id, pid, op) { var _tag = $('
') var scriptAd = document.createElement("script"); scriptAd.type = "text/javascript"; scriptAd.src = url; scriptAd.setAttribute('smua', op); if ($('#' + pid).length > 0) { $('#' + pid)[0].appendChild(scriptAd); // $('#' + pid)[0].appendChild(_tag[0]) } scriptAd.id = id; } // })();