$.support.cors = true;
//load config
var configInfo = config[1];
var IframeOnClick = {
resolution: 200,
iframes: [],
interval: null,
Iframe: function() {
this.element = arguments[0];
this.cb = arguments[1];
this.hasTracked = false;
},
track: function(element, cb) {
this.iframes.push(new this.Iframe(element, cb));
if (!this.interval) {
var _this = this;
this.interval = setInterval(function() { _this.checkClick(); }, this.resolution);
}
},
checkClick: function() {
if (document.activeElement) {
var activeElement = document.activeElement;
for (var i in this.iframes) {
if (activeElement === this.iframes[i].element) {
if (this.iframes[i].hasTracked == false) {
this.iframes[i].cb.apply(window, []);
this.iframes[i].hasTracked = true;
}
} else {
this.iframes[i].hasTracked = false;
}
}
}
}
};
//Zhike曝光上报
function uploadZhike(uploadAction) {
var params = {
project:ProjectConfig.GetQueryString('project') || 'default',
data:ProjectConfig.GetQueryString('data') || 'default',
os:ProjectConfig.getSystem() || 'default',
browser:ProjectConfig.getBrowser() || 'default',
act:uploadAction.act || 'default',
ad_id:uploadAction.ad_id || '2299623',
ad_pos:uploadAction.ad_pos || 'kuaiya_tnews_1',
ad_time:new Date().getTime() || 'default',
ad_type:uploadAction.ad_type || 'dianshang',
strategy_id:uploadAction.strategy_id || '918',
idea_id:uploadAction.idea_id || '80',
plan_id:uploadAction.plan_id || '50',
product_category:uploadAction.product_category||'13'
};
var url = "http://sspreport.7654.com/ssp/user_click?code="+params.project + encodeURI('\t')+ params.data + encodeURI('\t')+params.os+ encodeURI('\t')+params.browser+ encodeURI('\t')+params.act+encodeURI('\t')+params.ad_id+encodeURI('\t')+params.ad_pos+encodeURI('\t')+params.ad_time+encodeURI('\t')+params.ad_type+encodeURI('\t')+params.strategy_id+encodeURI('\t')+params.idea_id+encodeURI('\t')+params.plan_id+encodeURI('\t')+params.product_category;
$.getJSON(url).done(function (data) {});
}
function newUpload(uploadAction) {
var params = {
project:ProjectConfig.GetQueryString('project') || 'default',
data:ProjectConfig.GetQueryString('data') || 'default',
os:ProjectConfig.getSystem() || 'default',
browser:ProjectConfig.getBrowser() || 'default',
act:uploadAction.act || 'default',
ad_id:uploadAction.ad_id || '',
ad_pos:uploadAction.ad_pos || 'kuaiya_tnews_1',
ad_time:new Date().getTime() || 'default',
ad_type:uploadAction.ad_type || 'dianshang',
strategy_id:uploadAction.strategy_id || '',
idea_id:uploadAction.idea_id || '',
plan_id:uploadAction.plan_id || '',
dspData:uploadAction.dspData || 'default',
product_category:uploadAction.product_category || 'undefined'
};
var objParams = params.project + '\t'+ params.data + '\t'+params.os+ '\t'+params.browser+ '\t'+params.act+'\t'+params.ad_id+'\t'+params.ad_pos+'\t'+params.ad_time+'\t'+params.ad_type+'\t'+params.strategy_id+'\t'+params.idea_id+'\t'+params.plan_id+'\t'+params.dspData+'\t'+params.product_category;
// console.log(objParams)
var newUrl = $.base64.encode(encodeURI(objParams));
var url = "http://adtj.kpzip.com/dsp/user_click?code="+ newUrl;
$.getJSON(url).done(function (data) {});
}
var currentCity = window.external.GetCity() || "";
var getJson = window.external.GetCloseButtonJson() || "";
var closeRule = "",otherRule ="";
if(getJson){
var allCloseRule = JSON.parse(getJson);
closeRule = allCloseRule[currentCity] || "";
otherRule = allCloseRule.others || "";
}
function getCloseImg(type){
var defaultImg = "14";
switch(type){
case "dianshang":
defaultImg = "14";
break;
case "dsp":
defaultImg = "8";
break;
case "zhike":
defaultImg = "8";
break;
default:
defaultImg = "14";
}
var imgName = defaultImg;
if(closeRule[type] && closeRule[type].level){
imgName = closeRule[type].level;
}else if(otherRule[type] && otherRule[type].level){
imgName = otherRule[type].level;
}else{
imgName = defaultImg;
}
var imgUrl = "../../libs/images/closebutton/"+imgName+".png"+"?v="+new Date().getTime();
return imgUrl;
}
(function () {
var ProjectConfig = {
GetQueryString: function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
},
Assign :function(target) {
target = Object(target);
for (var index = 1; index < arguments.length; index++) {
var source = arguments[index];
if (source != null) {
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
}
return target;
},
getBrowser:function () {
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
var isIE = userAgent.indexOf("compatible") > -1
&& userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
var isEdge = userAgent.indexOf("Edge") > -1; //判断是否IE的Edge浏览器
var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
var isSafari = userAgent.indexOf("Safari") > -1
&& userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
var isChrome = userAgent.indexOf("Chrome") > -1
&& userAgent.indexOf("Safari") > -1; //判断Chrome浏览器
if (isIE) {
var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
reIE.test(userAgent);
var fIEVersion = parseFloat(RegExp["$1"]);
if (fIEVersion == 7) {
return "IE7";
} else if (fIEVersion == 8) {
return "IE8";
} else if (fIEVersion == 9) {
return "IE9";
} else if (fIEVersion == 10) {
return "IE10";
} else if (fIEVersion == 11) {
return "IE11";
} else {
return "0";
}//IE版本过低
return "IE";
}
if (isOpera) {
return "Opera";
}
if (isEdge) {
return "Edge";
}
if (isFF) {
return "FF";
}
if (isSafari) {
return "Safari";
}
if (isChrome) {
return "Chrome";
}
},
getCookie: function () {
if (!$.cookie('dspUid')) {
var dspUid = new Date().getTime() + Math.random() * 100000 | 0;
$.cookie('dspUid', dspUid, {expires: 300, path: '/'});
}
return $.cookie('dspUid');
},
getSystem: function () {
var sUserAgent = navigator.userAgent;
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
if (isMac) return "Mac";
var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
if (isUnix) return "Unix";
var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
if (isLinux) return "Linux";
if (isWin) {
var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
if (isWin2K) return "Win2000";
var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;
if (isWinXP) return "WinXP";
var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1;
if (isWin2003) return "Win2003";
var isWinVista = sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1;
if (isWinVista) return "WinVista";
var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1;
if (isWin7) return "Win7";
var isWin10 = sUserAgent.indexOf("Windows NT 10") > -1 || sUserAgent.indexOf("Windows 10") > -1;
if (isWin10) return "Win10";
}
return "other";
},
loadBase: function () {
var dom='
'
$('.container').append(dom);
$(".close_big").html('');
uploadZhike(uploadConfig);
getNews();
document.getElementById("ak").onload = function () {
uploadConfig.act = 'show';
uploadConfig.product_category = '13';
uploadZhike(uploadConfig);
var page_size ='370,394';
$('head').append('');
if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') {
window.external.CppCall(page_size);
}
};
$("body").on('click','#ak',function(){
uploadConfig.act = 'click';
uploadConfig.product_category = '13';
uploadZhike(uploadConfig);
});
},
uploadUrl: function (url) {
var images = new Image();
images.src = url;
}
};
window.ProjectConfig = ProjectConfig;
window.uploadConfig = {};
})();
function loadDspAd(e) {
if (e.data && e.data.length > 0) {
uploadConfig.act = 'load';
uploadZhike(uploadConfig);
var data = e.data[0];
$('.container').html("");
$('.container').append('快压-广告');
$('.image-wrapper > img')[0].src = data.miniimg[0].src;
$('.image-wrapper')[0].href = data.url+"?needclose=1";
getNews();
document.getElementById("ak").onload = function () {
var page_size = "370," + document.getElementById('ak').offsetHeight;
$('head').append('');
if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') {
window.external.CppCall(page_size);
}
};
// 渲染
ProjectConfig.uploadUrl(data.showbackurls[0]);
uploadConfig.act = 'show';
uploadZhike(uploadConfig);
//进入可视区s域上报
if (data.isinviewbackurl) {
ProjectConfig.uploadUrl(data.inviewbackurls[0]);
}
//关闭上报
$('.close').on('click', function () {
ProjectConfig.uploadUrl(data.closebackurls[0])
});
//点击上报
$('.image-wrapper').on('click', function () {
ProjectConfig.uploadUrl(data.clickbackurls[0]);
uploadConfig.act = 'click';
uploadZhike(uploadConfig);
})
} else {
ProjectConfig.loadBase()
}
};
function closePanel() {
$('.close-panel').hide();
window.open('tag=boring');
}
function showPanel() {
if(ProjectConfig.GetQueryString('pop_menu') == 1){
$('.close-panel').show();
}else{
$('.close-panel').hide();
window.open('tag=close')
}
}
function closeWindow(){
window.open('tag=close');
}
//获取后台的数据
var url = '';
var urlOrigin=''
if(location.host == 'news.7654.com'){
url = 'http://ssp.7654.com/ssp/list?qid=';
urlOrigin='http://news.7654.com'
}else{
url = 'http://test-ssp.7654.com/ssp/list?qid=';
urlOrigin='http://test.gamma-minipage.news.7654.com'
}
$.ajax({
url: url + ProjectConfig.GetQueryString('project') + '&time='+new Date().getTime(),
type: 'get',
dataType: 'json',
success: function (obj) {
var render = true;
if(obj.data && obj.data.kuaiya_tnews_1){
var data = obj.data.kuaiya_tnews_1;
var product_category_url = ProjectConfig.GetQueryString('product_category');
if(data.script.length){
for(var i =0;i'
$('.container').append(dom);
$(".close_big").html('');
getNews();
render = false;
var height=parseInt(data.script[i].idea.main_img_h)+144;
var width=data.script[i].idea.main_img_w;
var page_size =''+width+','+height+'';
if(showType){
$('head').append('');
}else{
$('head').append('');
}
if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') {
window.external.CppCall(page_size);
}
// iframe 点击上报
$("body").on('click','#ak',function(){
uploadConfig.act = 'click';
uploadZhike(uploadConfig);
})
uploadConfig.act = 'show';
uploadZhike(uploadConfig);
}
}else if(data.script[i].type == 3){
//加载 dsp
if(data.script[i].ad_type==5){
var uploadUrl = '&ad_type=dsp' + '&ad_pos='+'kuaiya_tnews_1'+'&baidu_id='+ data.baidu_id +'&strategy_id='+data.script[i].strategy_id+'&idea_id='+data.script[i].idea_id+'&plan_id='+data.script[i].plan_id+'&product_category='+data.script[i].product_category;
var openUrl = urlOrigin + "/tnewsdsp/02/s11/sf.html?" + location.search.split('?')[1] + uploadUrl;
window.external.RedirectUrl(openUrl);
render = false;
}else if(data.script[i].ad_type==2){
var currentIndex = i;
if(data.script[i].content){
var sspConfig = JSON.parse(data.script[i].content);
// 展盟dsp上报
var zmDsp ={
requestId:1e18*Math.random(),
slot:{
proj:ProjectConfig.GetQueryString('project') || 'kuaizip',
mixData:ProjectConfig.GetQueryString('data') || '',
imageType: sspConfig.imageType || 3,
popType:'tnews'
}
};
var datas = encodeURI(JSON.stringify((zmDsp)));
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:'kuaiya_tnews_1',
ad_type:'dsp_zm',
strategy_id:data.script[i].strategy_id,
idea_id:data.script[i].idea_id,
plan_id:data.script[i].plan_id,
product_category:data.script[i].product_category
};
var url = sspConfig.url + $.base64.encode(datas);
render = false;
$.ajax({
url: url,
// url:'http://ads.7654.com/zcxxlxwerrorjson',
type: 'get',
dataType: 'json',
success: function (obj) {
if(obj.code == 0){
var ads = obj.result.ads[0];
var readStatus = ads.readStatus || '';
var dom ='';
$('.container').append(dom);
$(".close_big").html('');
getNews();
uploadConfig.act = 'load';
uploadConfig.dspData = JSON.stringify(ads);
newUpload(uploadConfig);
uploadZhike(uploadConfig);
document.getElementById("ak").onload = function () {
uploadConfig.act = 'show';
newUpload(uploadConfig);
uploadZhike(uploadConfig);
var page_size ='370,394';
$('head').append('');
if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') {
window.external.CppCall(page_size);
}
};
$("body").on('click','#ak',function(){
uploadConfig.act = 'click';
uploadConfig.dspData = JSON.stringify(ads);
newUpload(uploadConfig);
uploadZhike(uploadConfig);
});
if(readStatus == 1){
// showType 2 用阅读器打开
$('head').append('');
}else{
$('head').append('');
}
if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') {
window.external.CppCall(page_size);
}
}else{
var uploadUrl = '&ad_type=dsp' + '&ad_pos='+'kuaiya_tnews_1'+'&baidu_id='+ data.baidu_id +'&strategy_id='+data.script[currentIndex].strategy_id+'&idea_id='+data.script[currentIndex].idea_id+'&plan_id='+data.script[currentIndex].plan_id+'&product_category='+data.script[currentIndex].product_category;
var openUrl = urlOrigin + "/tnewsdsp/02/s11/sf.html?" + location.search.split('?')[1] + uploadUrl;
window.external.RedirectUrl(openUrl);
}
},
error:function () {
var uploadUrl = '&ad_type=dsp' + '&ad_pos='+'kuaiya_tnews_1'+'&baidu_id='+ data.baidu_id +'&strategy_id='+data.script[currentIndex].strategy_id+'&idea_id='+data.script[currentIndex].idea_id+'&plan_id='+data.script[currentIndex].plan_id+'&product_category='+data.script[currentIndex].product_category;
var openUrl = urlOrigin + "/tnewsdsp/02/s11/sf.html?" + location.search.split('?')[1] + uploadUrl;
window.external.RedirectUrl(openUrl);
}
});
}
}else{
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:'kuaiya_tnews_1',
ad_type:'dsp',
strategy_id:data.script[i].strategy_id,
idea_id:data.script[i].idea_id,
plan_id:data.script[i].plan_id,
product_category:data.script[i].product_category
};
var sspConfig = JSON.parse(data.script[i].content);
var params= {
uid: ProjectConfig.getCookie(),
os: ProjectConfig.getSystem(),
thisurl: location.href,
jsonpcallback:'loadDspAd'
};
params = ProjectConfig.Assign(params,sspConfig);
var configParams = {
url:params.url,
params:params
};
delete configParams.params.url;
$.ajax({
url: configParams.url,
type: 'get',
dataType: 'jsonp',
jsonp: 'jsonp',
timeout: 5000,
data: configParams.params,
jsonpCallback: 'loadDspAd',
success: function (e) {},
error: function (e) {
ProjectConfig.loadBase()
}
});
render = false;
}
}
}
}else{
}
}
}
}else{
ProjectConfig.loadBase()
}
}
},
error:function () {
ProjectConfig.loadBase()
}
});
function getNews(){
$.ajax({
url:'http://news.7654.com/api/tnews_news_list/tnews6/kuaiya101',
type:'get',
dataType:'json',
success:function(res){
var arr=res.data;
var newsDom='';
$.each(arr,function(index,val){
newsDom+=''+
''+val.title+'
新闻'
});
$(".box").append(newsDom);
}
})
}