1/** 2 * 广åä½æå ¥ 3 */ 4 5var hrefUrl = window.location.pathname, 6 screenWidth = $(window).width(); 7 8var hrefPath = hrefUrl.split('/')[1], 9 hrefPath2 = hrefUrl.split('/')[2]; 10 11/** 12 * å ¬ç¨ - APIè¯·æ± 13 */ 14function $Api(url, data, success) { 15 var host = window.location.host, 16 Api = ''; 17 if(host.indexOf('dev') > -1) { 18 Api = 'https://ad-dev-api.uogroup.com/' 19 }else if(host.indexOf('sit') > -1) { 20 Api = 'https://ad-sit-api.uogroup.com/' 21 }else { 22 Api = 'https://ad-api.uogroup.com/' 23 } 24 $.ajax({ 25 headers: { 26 'X-device': 'WEB', 27 'X-version': '1.0', 28 'access-token': $.cookie('token') || '' 29 }, 30 type: "post", 31 url: Api + url, 32 data: JSON.stringify(data), 33 dataType: "json", 34 contentType: 'application/json;charset=UTF-8', 35 success: function (res) { 36 success(res) 37 if(res.code != 0 && host.indexOf('sit') > -1) { 38 console.log('> [Api] ' + url, '\n> [Warning] ' + res.message) 39 } 40 }, 41 error: function(err) { 42 console.log(err); 43 } 44 }); 45} 46 47var device, device2, device3; 48var isPcSize = screenWidth >= 1024, 49 isPadSize = screenWidth >= 640 && screenWidth < 1024 50if(isPcSize) { 51 device = 'PC'; 52 device2 = 'PC'; 53 device3 = 'PC'; 54}else if(isPadSize) { 55 device = 'MB' // old screenWidth>=767æ¶æ¯MB 56 device2 = 'PC' // æç« èæ¯å¹¿å使ç¨ï¼å®åå ¶å®å¹¿åè§åä¸åãåå ¶é¡µé¢å±ç¤ºå¹¿åå¾çæ¯ä¾æå ³ 57 device3 = 'PC'; 58}else { 59 device = 'MB' 60 device2 = 'MB' 61 device3 = screenWidth > 480 ? 'PC' : 'MB' // ææºæ¨ªå±å ¼å®¹ï¼ ç»å广åçå¾ç尺寸é®é¢æä»¥ç¨åPCçæ°æ® è¯¥ä¸è¯¥è¿ä¹åä¹è¦çä¸çº§éæ± todo ä¸´æ¶ 62} 63 64 65var reload = true, // å·æ°é¡µé¢ 66 windowWidth = $(window).width(); // åå§å¤§å° 67$(window).resize(function() { 68 screenWidth = $(window).width(); 69 if(isPcSize) { 70 device = 'PC'; 71 device2 = 'PC'; 72 device3 = 'PC'; 73 }else if(isPadSize) { 74 device = 'MB' 75 device2 = 'PC' 76 device3 = 'PC'; 77 }else { 78 device = 'MB' 79 device2 = 'MB' 80 device3 = screenWidth > 480 ? 'PC' : 'MB' // ææºæ¨ªå±å ¼å®¹ï¼ ç»å广åçå¾ç尺寸é®é¢æä»¥ç¨åPCçæ°æ® è¯¥ä¸è¯¥è¿ä¹åä¹è¦çä¸çº§éæ± todo ä¸´æ¶ 81 } 82 83 // å¹³æ¿ä¸ï¼å¨åæ¢æ¨ªå±çæ¶åè½å¤èªå¨å·æ°é¡µé¢ 84 // if(windowWidth != screenWidth && screenWidth < 1024) { 85 // windowWidth = screenWidth 86 // window.location.reload() 87 // } 88}) 89 90$(window).on('orientationchange', function() { 91 window.location.reload() 92}); 93 94$(function() { 95 96 // 卿 ç®é¡µé¢åå¨ä½ç½®IDæ¶ï¼å°±å»è·åå ¶æ°æ® 97 var B_ADposition = '', // å¼¹çªå¹¿å 98 C_ADposition = '', // 䏿»å¹¿å 99 E_ADposition = '', // 对è广å 100 D_ADposition = ''; // ç»å广å/æ¬æµ®å¹¿å 101 102 // é¦é¡µ 103 if(hrefPath == '') { 104 // å·²å¼å¯çæ¨¡åæ§è¡å¹¿å使·»å 105 $('.home-section').each(function() { 106 var type = $(this).attr('data-adType'); 107 if(type) { 108 indexADpositionFunc(type); 109 } 110 }) 111 // å¹¿åæ°æ®è¯·æ± 112 getADcontentFunc('prefix', device + '-A-M', function(res) { 113 if(res.code == 0) { 114 var data = res.data; 115 AdInsertionFunc(data); // ç»ä¸HTMLæ ¼å¼æå ¥ 116 } 117 }) 118 119 // å¼¹çªå¹¿å 120 B_ADposition = `${device}-B-M0-1` 121 C_ADposition = `${device}-C-M0-1` 122 123 // 对è广å 124 coupletADpositionFunc('M', 0) 125 // E_ADposition = `${device}-E-M0` 126 127 // 页顶广å 128 $('#header-container').attr('data-position', `${device}-H-M0-1`); 129 } 130 131 // 峿¶æ°é» 132 if(hrefPath == 'hot') { 133 var lineNum; 134 if(isPcSize) { // screenWidth > 1200 old 135 // PC 136 lineNum = 3; 137 }else if(isPadSize) { 138 // ipad 139 lineNum = 2; 140 }else { 141 // mobile 142 lineNum = 1; 143 } 144 145 var listData = []; // ç½é¡µå¨ç´æ¥åæ¢å®½åº¦æ¶åï¼å·²ææ°æ®çæ¶åç´æ¥æ¸²æï¼å¦åè¯·æ±æ°æ°æ® 146 function hotADpositionFunc() { 147 var lineDiv = $('.col-lg-4.col-sm-6'); 148 var column = device + '-A-L1'; 149 $('.article_adposition_box .ad-img-show').remove(); 150 lineDiv.each(function(i) { 151 if(i != 0) 152 lineDiv.eq(i * lineNum-1).after(`<div class="ad-img-show" data-position="${column}-${i}" style="width:100%; clear:both;"></div>`) 153 }) 154 155 if(listData.length > 0) { 156 AdInsertionFunc(listData); 157 }else { 158 getADcontentFunc('prefix', column + '-', function(res) { 159 if(res.code == 0) { 160 var data = res.data; 161 listData = data; 162 AdInsertionFunc(data); // ç»ä¸HTMLæ ¼å¼æå ¥ 163 firstADshowFunc(column, data) 164 } 165 }) 166 } 167 } 168 169 hotADpositionFunc() 170 171 // 卿æºä¸ä¼æBUGï¼æä»¥æ æ³åå°åæ¢çªå£å¤§å°å°±éæ°å»æ¿å¼ï¼è¿ä¸ªä¼å¯¼è´å¨ææºä¸ä¸æ»å±æ¶ä¸åæ·»å æ°çä½ç½® 172 // $(window).resize(function() { 173 // // hot 174 // if(isPcSize) { 175 // // PC 176 // lineNum = 3; 177 // }else if(isPadSize) { 178 // // ipad 179 // lineNum = 2; 180 // }else { 181 // // mobile 182 // lineNum = 1; 183 // } 184 // hotADpositionFunc() 185 // }) 186 187 188 // å¼¹çªå¹¿å 189 B_ADposition = `${device}-B-L1-1` 190 C_ADposition = `${device}-C-L1-1` 191 192 // 页顶广å 193 $('#header-container').attr('data-position', `${device}-H-L1-1`); 194 // 对è广å
195 coupletADpositionFunc('L', 1) 196 // E_ADposition = `${device}-E-L1` 197 } 198 if(hrefPath == 'macau' || hrefPath == 'world' || hrefPath == 'china' || hrefPath == 'business' || hrefPath == 'sports' || hrefPath == 'leisure' || hrefPath == 'investment' || (hrefPath == 'supplement' && !hrefPath2) || (hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '9') || (hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '2') || (hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '5') || (hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '3') || (hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '7') || (hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '8')) { 199 var positionId = '' 200 if(hrefPath == 'macau') positionId = 3 // æ¾³é» - 仿¥åæ¥ 201 if(hrefPath == 'world') positionId = 4 // å½é - 仿¥åæ¥ 202 if(hrefPath == 'china') positionId = 5 // ä¸å½ - 仿¥åæ¥ 203 if(hrefPath == 'business') positionId = 6 // äº§ç» - 仿¥åæ¥ 204 if(hrefPath == 'sports') positionId = 7 // ä½è² - 仿¥åæ¥ 205 if(hrefPath == 'leisure') positionId = 8 // å¨±ä¹ - 仿¥åæ¥ 206 if(hrefPath == 'investment') positionId = 9 // æ¹¾åºæèµ - 仿¥åæ¥ 207 if(hrefPath == 'supplement' && !hrefPath2) positionId = 10 // å ¨é¨ - çæ´» 208 if(hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '9') positionId = 11 // æ¸¸æ¾³åæ - çæ´» 209 if(hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '2') positionId = 12 // é¥®é£ - çæ´» 210 if(hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '5') positionId = 13 // 汽车 - çæ´» 211 if(hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '3') positionId = 14 // æ æ¸¸ - çæ´» 212 if(hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '7') positionId = 15 // æ¶è´¹ - çæ´» 213 if(hrefPath == 'supplement' && !!hrefPath2 && hrefPath2 == '8') positionId = 16 // 䏿 - çæ´» 214 215 // çæ´»åå ¶å®æ ç®æ§è¡äºä»¶ä¸å 216 if(hrefPath == 'supplement') { 217 supplementADpositionFunc(positionId) 218 $(window).resize(function() { 219 supplementADpositionFunc(positionId) 220 }) 221 }else { 222 window.onload = articleADpositionFunc(positionId) 223 $(window).resize(function() { 224 articleADpositionFunc(positionId) 225 }) 226 } 227 228 229 // å¼¹çªå¹¿å 230 B_ADposition = `${device}-B-L${positionId}-1` 231 C_ADposition = `${device}-C-L${positionId}-1` 232 233 // 页顶广å 234 $('#header-container').attr('data-position', `${device}-H-L${positionId}-1`); 235 // 对è广å 236 coupletADpositionFunc('L', positionId) 237 // E_ADposition = `${device}-E-L${positionId}` 238 239 } 240 241 // å æ 两个æç« æ¨¡æ¿ 242 if(hrefPath == 'article' || (hrefPath == 'supplement' && hrefPath2 == 'article')) { 243 contentADpositionFunc() 244 245 // 页顶广å 246 $('#header-container').attr('data-position', `${articleColumnFunc(device, 'H')}-1`); 247 248 // æç« åºé¨æ¬æµ®å¹¿å 249 // articleBottomADFunc(); 250 251 // ç»å广å 252 // comeboADFunc(); 253 D_ADposition = articleColumnFunc(device3, 'D') + '-1'; 254 255 // 对è广å 256 // E_ADposition = articleColumnFunc(device, 'E'); 257 var articleColumnVar = articleColumnFunc(device, 'E'); 258 articleColumnVar = articleColumnVar.substr(3) 259 // 峿¶ 260 if(articleColumnVar == 'E-D1') coupletADpositionFunc('D', 1) 261 // 仿¥ 262 if(articleColumnVar == 'E-D2') coupletADpositionFunc('D', 2) 263 if(articleColumnVar == 'E-D3') coupletADpositionFunc('D', 3) 264 if(articleColumnVar == 'E-D4') coupletADpositionFunc('D', 4) 265 if(articleColumnVar == 'E-D5') coupletADpositionFunc('D', 5) 266 if(articleColumnVar == 'E-D6') coupletADpositionFunc('D', 6) 267 if(articleColumnVar == 'E-D7') coupletADpositionFunc('D', 7)
268 if(articleColumnVar == 'E-D8') coupletADpositionFunc('D', 8) 269 // çæ´» 270 if(articleColumnVar == 'E-D10') coupletADpositionFunc('D', 10) 271 if(articleColumnVar == 'E-D11') coupletADpositionFunc('D', 11) 272 if(articleColumnVar == 'E-D12') coupletADpositionFunc('D', 12) 273 if(articleColumnVar == 'E-D13') coupletADpositionFunc('D', 13) 274 if(articleColumnVar == 'E-D14') coupletADpositionFunc('D', 14) 275 if(articleColumnVar == 'E-D15') coupletADpositionFunc('D', 15) 276 } 277 278 279 /** 280 * 广å使 ·å¼ 281 */ 282 var style = ` 283 <style> 284 /* 广åä½ */ 285 .ad-jump-click {background: #e9e9e9; position: relative;} 286 .scale50 {transform: scale(.5);} 287 .ad-jump-click:after { 288 content: 'AD Position'; 289 position: absolute; 290 top: 50%; 291 left: 50%; 292 font-size: 28px; 293 color: #ddd; 294 white-space: nowrap; 295 transform: translate(-50%, -50%); 296 display: none; 297 } 298 </style>` 299 $('body').append(style); 300 301 302 /** 303 * B_ADpositionï¼å¼¹çªå¹¿å 304 * C_ADpositionï¼ä¸æ»å¹¿å 305 * D_ADpositionï¼ç»å/æ¬æµ®å¹¿å 306 * H_ADpositionï¼é¡µé¡¶å¹¿å 307 * E_ADpositionï¼å¯¹è广å 308 */ 309 var H_ADposition = $('#header-container').data('position') || ''; 310 var E_AD_1 = E_ADposition ? E_ADposition + '-1' : '', 311 E_AD_2 = E_ADposition ? E_ADposition + '-2' : ''; 312 var ADArray = [B_ADposition, C_ADposition, D_ADposition, H_ADposition, E_AD_1, E_AD_2], 313 submitArray = [] // è¿æ»¤ç©ºçä½ç½® 314 for(var i in ADArray) { 315 if(ADArray[i] != '') submitArray.push(ADArray[i]) 316 } 317 submitArray.length > 0 && getADcontentFunc('array', submitArray, function(res) { 318 if(res.code == 0) { 319 var data = res.data; 320 for (var k in data) { 321 var adItem = data[k] 322 // å¼¹çªå¹¿åå 容è·å 323 if(adItem.tagNo == B_ADposition) { 324 var dialogADhtml = `<div class="dialog_show_ad banner_mask"> 325 <div class="banner_top" style="max-width: ${adItem.adSizes ? adItem.adSizes[0].width + 'px' : 'auto'}"> 326 <span onclick="websiteAdCloseFunc()"><i>+</i>éé</span> 327 <div class="banner_top_img ad-img-show" data-position="${B_ADposition}" > 328 </div> 329 <p>é¤ä¸<font>0</font>ç§</p> 330 </div> 331 </div>` 332 333 $('#inner-container').prepend(dialogADhtml); 334 AdInsertionFunc([adItem]); // å ¬ç¨å¹¿åæå ¥ï¼é»è®¤æ²¡æä¸ºSVGå¾ 335 336 if(adItem.ads.length == 1) { 337 var intervalTime = adItem.ads[0].intervalTime / 1000, 338 keepTime = adItem.ads[0].keepTime / 1000; 339 // æå ¥æååç´æ¥å°å¾çæ¿æ¢åå ¶çå®å¾ç 340 $('.dialog_show_ad').find('img').each(function() { 341 var $img = $(this), 342 url = $img.attr('data-url'), 343 id = $img.parent('.ad-jump-click').attr('data-id'); 344 345 var img = new Image(); 346 img.src = url; 347 img.onload = function() { 348 $img.attr('src', url).removeClass('scale50'); 349 $img.parent('.ad-jump-click').attr('data-count', '1'); 350 B_websiteADFunc(intervalTime, keepTime) // å¾çå è½½æååææ§è¡å¼¹çªäºä»¶ 351 ADshowCountFunc(id, false, $img.parents('.ad-img-show').data('position') + ' å¼¹çªAD') 352 } 353 }) 354 }else { 355 // è½®ææ¶ todo è½®ææ¶æªèèè½®ææ¶é´åå¼¹çªçå±ç¤ºæ¶é´é®é¢ï¼å¼¹çªåè½ææ¶æ²¡æå¤å¼ éæ±å æ¾çå§åå 356 $('.dialog_show_ad').find('img').each(function() { 357 var $img = $(this), 358 url = $img.attr('data-url'), 359 id = $img.parent('.ad-jump-click').attr('data-id'), 360 hasOwl = $img.parents('.owl-item.active').length; // 夿å½åæ¯å¦æ¯æ¾ç¤ºçé£ä¸å¼ 361 362 $img.attr('src', url).removeClass('scale50'); 363 if(hasOwl > 0) { 364 $img.parent('.ad-jump-click').attr('data-count', '1'); 365 B_websiteADFunc(intervalTime, keepTime) // å¾çå è½½æååææ§è¡å¼¹çªäºä»¶ 366 ADshowCountFunc(id, false, $img.parent('.ad-img-show').data('position') + ' å¼¹çªAD') 367 } 368 }) 369 } 370 countImg(); // å¤æå ¶å¾ççæ¾ç¤ºå¤§å° 371 } 372 373 // 䏿»å¹¿åå 容è·å 374 if(adItem.tagNo == C_ADposition) { 375 var C_websiteHtml = ` 376 <div class="c_website_banner banner_bg"> 377 <div class="banner"> 378 <div class="banner_img ad-img-show" data-position="${C_ADposition}"></div> 379 <p>é¤ä¸<font>0</font>ç§</p> 380 </div> 381 </div> 382 ` 383 $('.column-container').before(C_websiteHtml) 384 AdInsertionFunc([adItem]); // å ¬ç¨å¹¿åæå ¥ï¼é»è®¤æ²¡æä¸ºSVGå¾ 385 $(`.banner_img[data-position="${C_ADposition}"]`).removeAttr('style'); 386 387 var intervalTime = adItem.ads[0].intervalTime / 1000, 388 keepTime = adItem.ads[0].keepTime / 1000; 389 if(adItem.ads.length == 1) { 390 // æå ¥æååç´æ¥å°å¾çæ¿æ¢åå ¶çå®å¾ç 391 $('.c_website_banner').find('img').each(function() { 392 var $img = $(this), 393 url = $img.attr('data-url'), 394 id = $img.parent('.ad-jump-click').attr('data-id'); 395 var img = new Image(); 396 img.src = url; 397 img.onload = function() { 398 $img.attr('src', url).attr('data-count', '1').removeClass('scale50'); 399 C_websiteADFunc(intervalTime, keepTime, id) 400 } 401 }) 402 }else { 403 // è½®ææ¶ 404 $('.c_website_banner').find('img').each(function() { 405 var $img = $(this), 406 url = $img.attr('data-url'), 407 id = $img.parent('.ad-jump-click').attr('data-id'), 408 hasOwl = $img.parents('.owl-item.active').length; // 夿å½åæ¯å¦æ¯æ¾ç¤ºçé£ä¸å¼ 409 410 $img.attr('src', url).removeClass('scale50'); 411 if(hasOwl > 0) { 412 $img.parent('.ad-jump-click').attr('data-count', '1'); 413 C_websiteADFunc(intervalTime, keepTime, id) 414 } 415 }) 416 } 417 } 418 419 // 页顶广å 420 if(adItem.tagNo == H_ADposition) { 421 $('#header-container').attr('style', `background-image: url(${adItem.ads[0].resources[0].url})`); 422 $('#header').attr('style', 'background-image: none')
423 ADshowCountFunc(adItem.ads[0].adId, false, H_ADposition + ' 页顶AD') 424 } 425 426 // 对è广å 427 if(adItem.tagNo == D_ADposition) { 428 var adsItem = adItem.ads[0]; 429 var maxImg, minImg 430 // çæ¼2çºçµå廣åï¼çæ¼1çºæ¸æµ®å»£å 431 if(adsItem.resources.length == 2) { 432 if(adsItem.resources[1].height > adsItem.resources[0].height) { 433 maxImg = adsItem.resources[1].url 434 minImg = adsItem.resources[0].url 435 }else { 436 maxImg = adsItem.resources[0].url 437 minImg = adsItem.resources[1].url 438 } 439 }else { 440 // maxImg = ''0 441 // minImg = adsItem.resources[0].url 442 443 // åå¼ çè¯æ§è¡æ¬æµ®çå¹¿åæ¹æ¡ articleBottomADFunc()æ¹æ³å·²åºå¼ï¼ç»ååæ¬æµ®åè½åå¹¶ 444 // ps: éæ±ä¸è¦å ³éæé® 445 var newsHTML = `<div class="bottomAD"> 446 <div class="bottomAD_box"> 447 <div class="img_box"> 448 <a class="ad-img-show" data-position="${D_ADposition}"></a> 449 <div class="close_AD hide" onclick="$('.bottomAD').remove();"></div> 450 </div> 451 </div> 452 </div>`; 453 $('body').append(newsHTML); 454 AdInsertionFunc(data) 455 try { 456 var thatImg = data[0].ads[0].resources[0] 457 var imgWidth = thatImg.width, 458 imgHeight = thatImg.height 459 var setHeight = imgHeight * $('body').width() / imgWidth 460 setHeight = setHeight.toFixed(0) 461 $('.img_box .ad-img-show').height(setHeight); 462 }catch(e) { 463 $('.bottomAD').remove(); 464 console.log('> error åºé¨æ¬æµ®dataæ°æ®æè¯¯'); 465 return 466 } 467 468 var $img = $('.bottomAD').find('img'), 469 url = $img.data('url') 470 var img = new Image(); 471 img.src = url; 472 img.onload = function() { 473 $img.parents('.ad-jump-click').attr('data-count', '1'); 474 $img.attr('src', url).removeClass('scale50'); 475 // å±ç¤ºåç»è®¡æ¬¡æ° 476 ADshowCountFunc($img.parents('.ad-jump-click').data('id'), false, 'æ¬æµ®AD') 477 } 478 return 479 } 480 481 var comboADImg = maxImg, 482 comboADBottomImg = minImg, 483 keepTime = adsItem.keepTime / 1000 484 intervalTime = adsItem.intervalTime / 1000, 485 id = adsItem.adId, 486 clickContent = JSON.stringify(adsItem.clickContent), 487 style = adsItem.adStyle; 488 489 var comboADHtml = ` 490 <div class="comboAD-box"> 491 <div class="comboAD-img"> 492 <img src="${comboADImg}" onclick='adJumpClickFunc(${id}, ${clickContent}, ${style})' /> 493 </div> 494 </div> 495 <div class="comboAD-bottom"> 496 <div class="comboAD-bottom-img"> 497 <img src="${comboADBottomImg}" onclick='adJumpClickFunc(${id}, ${clickContent}, ${style})' /> 498 <div class="comboAD-btn comboAD-close ${!comboADImg && 'hide'}"></div> 499 <div class="comboAD-btn comboAD-open ${!comboADImg && 'hide'}"></div> 500 </div> 501 </div> 502 `; 503 $('body').append(comboADHtml); 504 ADshowCountFunc(id); 505 506 var firstShow = true 507 $(window).scroll(function() { 508 var sTop = 0; 509 if (document.documentElement && document.documentElement.scrollTop) { 510 sTop = document.documentElement.scrollTop; 511 }else if (document.body) { 512 sTop = document.body.scrollTop; 513 } 514 if(sTop > 300 && firstShow) { 515 firstShow = false 516 // å½åcookieä¸ä¿ç䏿¬¡å©ä½æ¶é´æ¶ï¼å ç¨å®åæ¾ç¤º 517 // è§£å³ä¸æ¬¡å©ä½å ç§æ¶ï¼è¿æ¬¡è¿æ¥åæ¾ç¤ºå®ååçªç¶è¯»å®ä¸æ¬¡æ¶é´å次æ¾ç¤ºï¼ä¼æ¾ç¤ºå¾å¿« 518 if(!!getCookie('comboADTime') && getCookie('comboADTime') != intervalTime) { 519 var sec = parseInt(getCookie('comboADTime')); 520 var secTime = setInterval(() => { 521 sec --; 522 if(sec <= 0) clearInterval(secTime);
523 setCookie('comboADTime', sec); 524 console.log(`å©ä½${sec}så è½½ç»å广å`); 525 }, 1000); 526 setTimeout(() => { 527 showADfunc(); 528 setCookie('comboADTime', intervalTime); 529 }, getCookie('comboADTime')*1000); 530 }else { 531 showADfunc(); 532 } 533 } 534 }) 535 536 var img1 = false, 537 img2 = false, 538 t = true; 539 var returnTime, 540 timeout; 541 542 $('.comboAD-img img').load(function() { 543 img1 = true 544 }) 545 $('.comboAD-bottom-img img').load(function() { 546 img2 = true 547 }) 548 549 // å±ç¤ºå¤§å 550 function showADfunc() { 551 // æ¯ç§æéï¼ç²åå ©å¼µADæ¯å¦å è¼å®æ 552 var time = setInterval(() => { 553 if(img1 && img2 && t) { 554 t = false; 555 $('.comboAD-box').fadeIn(100); 556 $('.comboAD-bottom').fadeOut(); 557 $('#footer').css('margin-bottom', 0); 558 ADShowPosition(); // éç½®å ¶é¡¯ç¤ºä½ç½® 559 clearInterval(time); // æ£å¸¸é¡¯ç¤ºå¾ï¼å¯æ¸ é¤ç¶åçè¨æå¨ 560 var showTime = setTimeout(() => { 561 t = true; 562 $('.comboAD-box').fadeOut(); 563 $('.comboAD-bottom').fadeIn(); 564 $('#footer').css('margin-bottom', $('.comboAD-bottom').height()); 565 returnShowADfunc(); 566 567 var imgHeight = $('.comboAD-bottom-img').height(); 568 $('#footer.margin100').css('margin-bottom', imgHeight); 569 $('#back-to-top').css('bottom', imgHeight + 30); // 置顶æé®ä½ç½®ä¸ç§» 570 571 clearTimeout(showTime); 572 }, keepTime*1000); 573 } 574 }, 1000); 575 } 576 577 // AD position 578 function ADShowPosition() { 579 if(screenWidth > 640) { 580 var top = $('#header').height() + 100 581 // css topæä¸ªéæ±ï¼éè¦ä¸è½æ¡ä½æ ç® 582 $('.comboAD-box').css({'top': $('#header').height(), 'height': getClientHeight()-top}); 583 }else { 584 $('.comboAD-box').css({'top': '50%', 'transform': 'translateY(-50%)'}); 585 } 586 } 587 588 // ééæé 589 function returnShowADfunc() { 590 var comboTime = intervalTime; // åå§ 591 // ç¶cookieä¸å卿éååä¾ä½¿ç¨ 592 if(!!getCookie('comboADTime')) { 593 comboTime = getCookie('comboADTime'); 594 } 595 clearInterval(returnTime); // 調ç¨åå æ¸ é¤ä¸ä¸æ¬¡çè¨æ 596 returnTime = setInterval(() => { 597 comboTime --; 598 setCookie('comboADTime', comboTime); 599 // console.log('å³å°æ¾ç¤ºç»å广å', comboTime + 's'); 600 601 if(comboTime <= 0) {
602 setCookie('comboADTime', intervalTime); // ç¶0så¾éæ°è³¦å¼ææ°çæé 603 clearInterval(returnTime); 604 } 605 }, 1000); 606 // timeout = setTimeout(() => { 607 // // showADfunc() ä¸éè¦éæ°æ¾å¤§ 001 608 // }, comboTime*1000); 609 } 610 611 // æ¹è®å±å¹æéæ°è¨ç®å±ç¤ºåå¤§å° 612 $(window).resize(function() { 613 ADShowPosition(); 614 615 // if(screenWidth > 640) { 616 // var comboADImg = newsAD_IMG, 617 // comboADBottomImg = newsAD_Resizable_IMG; 618 // }else { 619 // var comboADImg = newsAD_IMG_Mb, 620 // comboADBottomImg = newsAD_Resizable_IMG_Mb; 621 // } 622 623 var imgHeight = $('.comboAD-bottom-img').height(); 624 $('#footer').css('margin-bottom', imgHeight); 625 }) 626 627 // close AD 628 $('.comboAD-close').on('click', function() { 629 $('.comboAD-bottom').hide(); 630 $('#footer').css('margin-bottom', '0'); 631 }) 632 633 // open AD 634 $('.comboAD-open').on('click', function() { 635 setCookie('comboADTime', intervalTime); // å±éADå¾éæ°è¨ç®å ¶éè·æé 636 637 $('.comboAD-box').fadeIn(100); 638 $('.comboAD-bottom').fadeOut(); 639 $('#footer').css('margin-bottom', '0'); 640 ADShowPosition(); // éç½®å ¶é¡¯ç¤ºä½ç½® 641 var openTime = setTimeout(() => { 642 $('.comboAD-box').fadeOut(); 643 $('.comboAD-bottom').fadeIn(); 644 $('#footer').css('margin-bottom', $('.comboAD-bottom').height()); 645 returnShowADfunc(); 646 clearTimeout(openTime); 647 }, keepTime*1000); 648 }) 649 } 650 651 // 对è广å 652 if(adItem.tagNo == E_AD_1 || adItem.tagNo == E_AD_2) { 653 // todo ææ¶ä¸ç§»è¿æ¥ 654 } 655 } 656 } 657 }) 658 659}) 660 661 662/** 663 * å ¬ç¨ - 页颿»å¨çå¬ å¹¿åæå è½½ 664 */ 665$(window).scroll(function() { 666 var viewHeight = getClientHeight(), 667 scrollTop = $(window).scrollTop(); 668 669 $('.ad-img-show').each(function() { 670 var that = $(this), 671 top = parseInt(that.offset().top); 672 that.attr('top', top); 673 674 // åå¨å¹¿åæ°æ®ç é¤å»å¹¿åä½ä¸ºç©ºç 675 if(that.html()) { 676 var $hasOwl = that.find('.owl-carousel'); // å½åå¾çæ¯å¦è½®æï¼åå¨ä¸ªæ°å°±æ¯æ 677 if($hasOwl.length > 0) { 678 // è½®æ - å¯è§çè½®ææ¨¡åæ§è¡ç¨åºï¼å夿å¯è§item 679 if(viewHeight + scrollTop > top) { // todo 页颿»å¨è¿å¤´çä¹è¦å¤æ 680 $hasOwl.find('.owl-item').each(function() { 681 var $item = $(this); 682 var imgUrl = $item.find('img').attr('data-url'), 683 $adJumpClick = $item.find('.ad-jump-click'), 684 id = $adJumpClick.attr('data-id'); 685 var currentClass = $item.hasClass('active'); // å½åéä¸çitem 686 687 // å½åè½®æä¸å¾çææå¯è§ 688 var img = new Image(); 689 img.src = imgUrl; 690 img.onload = function() { 691 $item.find('img').attr('src', imgUrl).removeClass('scale50'); 692 currentClass && $adJumpClick.attr('data-count') == '0' && ADshowCountFunc(id, false, that.data('position') + ' scroll') // 妿å½åæ¯ éä¸ çè½®æï¼åç»è®¡æ¬¡æ° 693 // å½ä¸å¯è§itemè®¡æ° 694 if(currentClass) { 695 $adJumpClick.attr('data-count', 1); 696 $item.siblings().find(`.ad-jump-click[data-id="${id}"]`).attr('data-count', 1); // ç±äºè½®ææä»¶çåå ï¼ç¸åIDçä¹è®¾ç½®ä¸º1ä¸è¢«éå¤ç»è®¡ 697 } 698 } 699 }) 700 } 701 }else { 702 if(that.find('.ad-jump-click').attr('data-style') == '2') { 703 // å¤æç¬¬ä¸æ¹å¹¿åç data-style为2 704 that.find('.ad-jump-click[data-style="2"]').each(function() { 705 var $adJumpClick = $(this), 706 id = $adJumpClick.attr('data-id'); 707 if($adJumpClick.attr('data-count') == '0' && viewHeight + scrollTop > top) { 708 $adJumpClick.attr('data-count', '1') 709 ADshowCountFunc(id, false, that.data('position') + ' GoogleAD') 710 } 711 }) 712 }else { 713 // åå¼ å¾çæ¶ï¼æ£å¸¸è®¡æ° 714 // 为1åä¸å¯åè¢«è®¡æ° 715 // å¾çè½è¢«å è½½æ¶åæ§è¡ç¸å ³äºä»¶ 716 var $img = $(this).find('img'), 717 $adJumpClick = that.find('.ad-jump-click'); 718 if($adJumpClick.attr('data-count') == '0' && viewHeight + scrollTop > top) { 719 $adJumpClick.attr('data-count', 1); 720 var imgUrl = $img.data('url'); 721 var img = new Image(); 722 img.src = imgUrl; 723 img.onload = function() { 724 $img.attr('src', imgUrl).removeClass('scale50'); 725 ADshowCountFunc($adJumpClick.data('id'), false, that.data('position') + ' scroll') 726 } 727 } 728 } 729 } 730 } 731 }) 732}) 733 734/** 735 * å ¬ç¨ - ç¹å»ç»è®¡äºä»¶/跳转 736 */ 737$(document).on('click', '.ad-jump-click', function() { 738 var that = $(this); 739 var id = that.data('id'), 740 data = that.data('clickcontent'); 741 742 // éè¿scale50ç±»å夿å¾ç为å¯è§ç¶æï¼ä¸æ¯èªéå¹¿åæ¶å¯æç¹å»ç»è®¡åäºä»¶ 743 if(!that.find('img').hasClass('scale50') && that.attr('data-style') == 1) { 744 ADshowCountFunc(id, true, that.parents('.ad-img-show').data('position')) 745 746 // 跳转æ§è¡æ¡ä»¶ 747 if(data.clickType == 1) { 748 window.open(data.url); 749 }else if(data.clickType == 6) { 750 if(data.category == 'subscribe') { 751 window.location.href = '/subscribe/subscribe_index' 752 }else if(data.category == 'hotarticle') { 753 window.location.href = '/hot' 754 }else if(data.category == 'article') { 755 window.location.href = '/macau' 756 }else { 757 window.location.href = '/' + data.category 758 } 759 }else if(data.clickType == 5){ 760 if(data.articleType == 'supplement') { 761 window.open(`/${data.articleType}/article/${data.articleId}.html`); 762 }else { 763 window.open(`/article/${data.articleId}.html`); 764 } 765 }else if(data.clickType == 2) { 766 if(IsPC()) { 767 alert(callText + "ï¼" + data.phone); 768 }else { 769 window.location.href = 'tel:' + data.phone; 770 } 771 }else if(data.clickType == 3) { 772 window.location.href = 'mailto:' + data.email; 773 }else { 774 var link = `https://wa.me/${data.phone}?text=${data.whatsApp}` 775 window.open(link); 776 } 777 } 778 // ç¬¬ä¸æ¹å¹¿åæ¶ï¼ä» ç»è®¡æ¬¡æ° 779 if(that.attr('data-style') == 2) { 780 ADshowCountFunc(id, true, that.data('position')) 781 } 782}) 783 784/** 785 * æç« èæ¯å¹¿åä¸ç¨çç¹å»ç»è®¡äºä»¶ / ç»å广å 786 * @param {*} id 787 * @param {*} data 788 * @param {*} style 789 */ 790function adJumpClickFunc(id, data, style) { 791 if(style == 1) { 792 ADshowCountFunc(id, true, 'èæ¯/ç»åAD') 793 // 跳转æ§è¡æ¡ä»¶ 794 if(data.clickType == 1) { 795 window.open(data.url); 796 }else if(data.clickType == 6) { 797 if(data.category == 'subscribe') { 798 window.location.href = '/subscribe/subscribe_index' 799 }else if(data.category == 'hotarticle') { 800 window.location.href = '/hot' 801 }else if(data.category == 'article') { 802 window.location.href = '/macau' 803 }else { 804 window.location.href = '/' + data.category 805 } 806 }else if(data.clickType == 5){ 807 if(data.articleType == 'supplement') { 808 window.open(`/${data.articleType}/article/${data.articleId}.html`); 809 }else { 810 window.open(`/article/${data.articleId}.html`); 811 } 812 }else if(data.clickType == 2) { 813 if(IsPC()) { 814 alert(callText + "ï¼" + data.phone); 815 }else { 816 window.location.href = 'tel:' + data.phone; 817 } 818 }else if(data.clickType == 3) { 819 window.location.href = 'mailto:' + data.email; 820 }else { 821 var link = `https://wa.me/${data.phone}?text=${data.whatsApp}` 822 window.open(link); 823 } 824 } 825} 826 827/** 828 * çæ´»é¢éå¹¿åæ¨¡åæ·»å 829 * -A-L âä¿¡æ¯æµ-å表é â 830 */ 831var supplementListData = []; 832function supplementADpositionFunc(col) { 833 var lineNum = screenWidth >= 992 ? 2 : 1;
834 var column = device + '-A-L' + col; 835 var lineDiv = $('.supplement-span-col'); 836 $('.article_adposition_box .ad-img-show').remove(); // æ·»å 忏 空åæå¯è½åå¨ç广åä½ç½®ï¼åè¿½å æ°ç 837 lineDiv.each(function(i) { 838 if(i != 0) 839 lineDiv.eq(i * lineNum-1).after(`<div class="col-md-6 ad-img-show" data-position="${column}-${i}" style="width:100%; clear:both;"></div>`) 840 }) 841 if(supplementListData.length > 0) { 842 AdInsertionFunc(supplementListData); 843 }else { 844 getADcontentFunc('prefix', column + '-', function(res) { 845 if(res.code == 0) { 846 var data = res.data; 847 supplementListData = data; 848 AdInsertionFunc(data); 849 firstADshowFunc(column, data) 850 } 851 }) 852 } 853} 854 855/** 856 * 仿¥åæ¥å¹¿åæ¨¡åæ·»å 857 * ç»åAPI请æ±è·åèµæºååæå ¥ç¸åºä½ç½®ï¼å¹¶è®¾å é« 858 * -A-L âä¿¡æ¯æµ-å表é â 859 */ 860function articleADpositionFunc(col) { 861 var column = device + '-A-L' + col; 862 // è·åæ¬é¡µå¹¿åä½ç½® 863 getADcontentFunc('prefix', column + '-', function(res) { 864 if(res.code == 0) { 865 var data = res.data; 866 $('.article_adposition_box .ad-img-show').remove(); 867 if(screenWidth >= 768) { 868 // æ·»å ç¼å· 869 var r_len = $('#column-right .article_adposition').length, 870 l_len = $('#column-left .article_adposition').length; 871 $('.article_adposition_box #column-right').prepend(`<div class="ad-img-show" data-position="${column}-1"></div>`) 872 $('.article_adposition_box #column-right').find('.article_adposition').each(function(n) { 873 var that = $(this), 874 position = `${(parseInt(n+1) * 2) + 1}`; 875 // 夿å¨å¤å°æ¶éå¤ 876 if(n > 3) { 877 position = `${(parseInt(n-4) * 2) + 1}`; 878 return false; // returnåï¼ä¼å¨å¹¿åæ°å°10çæ¶å忢æ°ç广åä½æå ¥ï¼éè¦éæ°è®¡æ°çè¯ææ¤è¡æ³¨éã 879 } 880 881 // å表个æ°ï¼å³å®å è½½å¤å°ä¸ªå¹¿åä½ç½® 882 if(l_len >= r_len) { 883 that.after(`<div class="ad-img-show" data-position="${column}-${position}"></div>`) 884 }else { 885 // å³ä¾§å¤äºå·¦ä¾§æ¶ï¼åä¸ä¸ª 886 if(n < r_len - 1) { 887 that.after(`<div class="ad-img-show" data-position="${column}-${position}"></div>`) 888 } 889 } 890 }) 891 892 $('.article_adposition_box #column-left').find('.article_adposition').each(function(n) { 893 var that = $(this), 894 position = `${(parseInt(n) * 2) + 2}`; 895 if(n > 4) { 896 position = `${(parseInt(n-5) * 2) + 2}`; // é夿¶éæ°è®¡æ° 897 } 898 899 // å³ä¾§å表å卿°é»æ¶ï¼å¦åç´æ¥æå ¥ä¸ä¸ª2ç广åä½å¾å¥æª 900 if(r_len > 0 && n < 5) { 901 that.after(`<div class="ad-img-show" data-position="${column}-${position}"></div>`) 902 } 903 }) 904 }else { 905 $('.article_adposition').each(function(i) { 906 var that = $(this); 907 that.attr('data-index', parseInt(i) + 1); 908 that.after(`<div class="ad-img-show" data-position="${column}-${parseInt(i) + 1}"></div>`) 909 }) 910 } 911 AdInsertionFunc(data); 912 firstADshowFunc(column, data) 913 } 914 }) 915} 916 917/** 918 * 第ä¸ä¸ªä½ç½®ç广åèªå¨å è½½åºæ¥ 919 * @param {string} column ä½ç½®ç¼å· ä¾ PC-A-L1 920 * @param {Array} data å½åç¼å·ä¸çææä½ç½®æ°æ® 921 */ 922function firstADshowFunc(column, data) { 923 for(var i in data) { 924 var item = data[i] 925 if(item.tagNo == `${column}-1`) { 926 var that = $(`.ad-img-show[data-position="${column}-1"]`); 927 var $hasOwl = that.find('.owl-carousel'); // å½åå¾çæ¯å¦è½®æï¼åå¨ä¸ªæ°å°±æ¯æ 928 if($hasOwl.length > 0) { 929 // è½®æ - å¯è§çè½®ææ¨¡åæ§è¡ç¨åºï¼å夿å¯è§item 930 $hasOwl.find('.owl-item').each(function() { 931 var $item = $(this); 932 var imgUrl = $item.find('img').attr('data-url'), 933 $adJumpClick = $item.find('.ad-jump-click'), 934 id = $adJumpClick.attr('data-id'); 935 var currentClass = $item.hasClass('active'); // å½åéä¸çitem 936 937 // å½åè½®æä¸å¾çææå¯è§ 938 var img = new Image(); 939 img.src = imgUrl; 940 img.onload = function() { 941 $item.find('img').attr('src', imgUrl).removeClass('scale50'); 942 currentClass && $adJumpClick.attr('data-count') == '0' && ADshowCountFunc(id, false, that.data('position') + ' é¦å¾å è½½') // 妿å½åæ¯ éä¸ çè½®æï¼åç»è®¡æ¬¡æ° 943 // å½ä¸å¯è§itemè®¡æ° 944 if(currentClass) { 945 $adJumpClick.attr('data-count', 1); 946 $item.siblings().find(`.ad-jump-click[data-id="${id}"]`).attr('data-count', 1); // ç±äºè½®ææä»¶çåå ï¼ç¸åIDçä¹è®¾ç½®ä¸º1ä¸è¢«éå¤ç»è®¡ 947 } 948 } 949 }) 950 }else { 951 // åå¼ å¾çæ¶ï¼æ£å¸¸è®¡æ° 952 // 为1åä¸å¯åè¢«è®¡æ° 953 // å¾çè½è¢«å è½½æ¶åæ§è¡ç¸å ³äºä»¶
954 // PS: åscrolläºä»¶ä¸å¤§è´ç¸åï¼åºå«å¨$imgä¸å¯¹è±¡ä¸ååifæ¡ä»¶ 470row 955 var $img = that.find('img'), 956 $adJumpClick = that.find('.ad-jump-click'); 957 if($adJumpClick.attr('data-count') == '0') { 958 $adJumpClick.attr('data-count', 1); 959 var imgUrl = $img.data('url'); 960 var img = new Image(); 961 img.src = imgUrl; 962 img.onload = function() { 963 $img.attr('src', imgUrl).removeClass('scale50'); 964 ADshowCountFunc($adJumpClick.data('id'), false, that.data('position') + ' scroll') 965 } 966 } 967 } 968 } 969 } 970} 971 972/** 973 * å ¬ç¨ - 广åæå ¥æå®ä½ç½®ï¼ç»ä¸ææå¹¿åå¾çæå ¥çå ç´ æ ¼å¼ 974 * æç« èæ¯å¹¿åé¤å¤ 975 * @param {Array} data å¹¿åæ°æ® 976 * @param {Array} count 计æ°ï¼è§£å³å¯¹è广å左峿»å ¥æ¶ï¼ä¼è¢«éå¤è®¡æ°é®é¢ 977 */ 978function AdInsertionFunc(data, count = 0) { 979 // éåæææ°æ® 980 for(var k in data) { 981 var item = data[k]; 982 var ads = item.ads || []; 983 var pos = item.tagNo; 984 985 // å¾çå ç´ ï¼åå¾çææ¯ä¸ªè½®æå¾ï¼ä¸¢è¿å¯¹åºç${pos}ä½ç½®ä¸ 986 var imgHtml = ''; 987 if(ads.length > 1) { 988 // è½®æ 989 var moreHtml = ''; 990 for(var j in ads) { 991 var adsItem = ads[j]; 992 if(adsItem.adStyle == 1) { 993 moreHtml += `<div class="ad-jump-click" 994 data-id="${adsItem.adId}" 995 data-style="${adsItem.adStyle}" 996 data-clickContent='${JSON.stringify(adsItem.clickContent)}' 997 data-count="${count}"> 998 <img 999 class="scale50" 1000 data-url="${adsItem.resources ? adsItem.resources[0].url : ''}" 1001 data-width="${adsItem.resources ? adsItem.resources[0].width : ''}" 1002 data-height="${adsItem.resources ? adsItem.resources[0].height : ''}" 1003 src="/img/svgLoading.svg" 1004 data-keeptime="${adsItem.keepTime}" 1005 data-intervaltime="${adsItem.intervalTime}" 1006 /> 1007 </div>`; 1008 1009 }else { 1010 // ç¬¬ä¸æ¹æ¯å¯ä¸ï¼ä¸å¯å¤ä¸ª 1011 if (!moreHtml) { 1012 moreHtml = `<div class="ad-jump-click" data-id="${adsItem.adId}" data-style="${adsItem.adStyle}" data-count="0"> 1013 ${adsItem.codeContent} 1014 </div>`; 1015 } 1016 } 1017 } 1018 imgHtml = `<div class="owl-carousel" id="owl-carousel-${pos}" data-ad> 1019 ${moreHtml} 1020 </div>`; 1021 }else { 1022 // åå¼ adStyleï¼ 1èªé广å / 2ç¬¬ä¸æ¹å¹¿å 1023 if(ads[0].adStyle == 1) { 1024 imgHtml = `<div class="ad-jump-click" 1025 data-id="${ads[0].adId}" 1026 data-style="${ads[0].adStyle}" 1027 data-clickContent='${JSON.stringify(ads[0].clickContent)}' 1028 data-count="${count}"> 1029 <img 1030 class="scale50" 1031 data-url="${ads[0].resources[0] ? ads[0].resources[0].url : ''}" 1032 data-width="${ads[0].resources[0] ? ads[0].resources[0].width : ''}" 1033 data-height="${ads[0].resources[0] ? ads[0].resources[0].height : ''}" 1034 src="/img/svgLoading.svg" 1035 width="100%" 1036 data-keeptime="${ads[0].keepTime}" 1037 data-intervaltime="${ads[0].intervalTime}" 1038 /> 1039 </div>`; 1040 }else { 1041 // google代ç ç 1042 imgHtml = `<div class="ad-jump-click" data-id="${ads[0].adI
1042d}" data-style="${ads[0].adStyle}" data-count="0"> 1043 ${ads[0].codeContent} 1044 </div>`; 1045 } 1046 } 1047 1048 var that = $(`.ad-img-show[data-position="${pos}"]`); 1049 that.append(imgHtml).not('.banner_top_img').css('margin-bottom', '20px'); // å½çªå»£åï¼.banner_top_imgï¼çä¸éè¦ä¸éè· 1050 } 1051 1052 // ç»å¤å¾æ·»å è½®æåè½ - ä¼å½±åé¦é¡µæ°é»è½®æå¾çé«åº¦ ï¼ï¼ 1053 $('.owl-carousel[data-ad]').each(function(i) { 1054 var id = $(this).attr('id'); 1055 var newId = id + '-' + i; 1056 $(this).attr('id', newId); 1057 1058 $(`#${newId}`).owlCarousel({ 1059 autoplay: true, 1060 autoplayTimeout: 5000, 1061 autoplayHoverPause: false, 1062 items: 1, 1063 loop: true, 1064 mouseDrag: !isIE(), 1065 margin: 10, 1066 nav: false, 1067 }); 1068 }) 1069} 1070 1071/** 1072 * é¦é¡µå¹¿åæ¨¡åæ·»å 1073 */ 1074function indexADpositionFunc(type) { 1075 $(`.home-section[data-adType="${type}"]`).find('.adposition').each(function(i) { 1076 var that = $(this), 1077 num = parseInt(i) + 1, 1078 position, forLen; 1079 1080 // æ¯ç»åæ°é - æ¾³é»æ¨¡å5个ä¸ç»ï¼å ¶å®ä¸º3个ä¸ç» 1081 if(type == '1') { 1082 forLen = 5; 1083 }else { 1084 forLen = 3; 1085 } 1086 1087 // ç»ä¸ªæ° - å¤æåºæå ç»ï¼æ°çä¸ç»ä»1å¼å§è®¡æ° 1088 var x = Math.ceil(num / forLen); 1089 if(x == 1) { 1090 position = `A-M${type}-${num}` 1091 }else { 1092 position = `A-M${type}-${num - (forLen * (x - 1))}` 1093 } 1094 1095 that.after(`<div class="ad-img-show" data-position="${device}-${position}"></div>`) 1096 }) 1097} 1098 1099/** 1100 * å ¬ç¨ - è·å广åå 容 1101 * @param {*} type 妿 type=array , æ¤å¼æ¯ä¸ä¸ªæ°ç»,å ç´ æ¯å¹¿åä½çæ è¯ç , 妿type=prefix åtagNoæ¯ä¸ä¸ªå符串, ä»£è¡¨äºæä¸ªé¡µé¢ææä¸ªåç±»ç广å使 è¯çåç¼ 1102 * @param {Array, string} tagNo ä½ç½®ç¼å· 1103 * @param {*} success åè°äºä»¶ 1104 */ 1105function getADcontentFunc(type, tagNo, success) { 1106 $Api('bin/v1/getAdContent', {type, tagNo}, function(res) { 1107 success(res); 1108 }) 1109} 1110 1111/** 1112 * å ¬ç¨ - å±ç¤ºãç¹å»è®¡æ°ç»è®¡ 1113 * @param {*} id 广åid 1114 * @param {*} type ç¹å»/å±ç¤º 1115 * @param {*} tagNo ä½ç½®ç¼å·ï¼å¯éå¡«ãè°è¯ä½ç¨ 1116 */ 1117function ADshowCountFunc(id, type, tagNo = '') { 1118 var changeType = type ? 'click' : 'show'; 1119 $Api('bin/v1/changeNum', { 1120 changeType, 1121 adIds: [id] 1122 }, function(res) { 1123 var host = window.location.host; 1124 if(host.indexOf('dev') > -1 || host.indexOf('sit') > -1) { 1125 // !type && console.log(`> å±ç¤ºå¾ç ${tagNo}ï¼${id}`); 1126 // type && console.log(`> ç¹å»å¾ç ${tagNo}ï¼${id}`); 1127 } 1128 }) 1129} 1130 1131/** 1132 * å¼¹çªå¹¿åçåè½JS -B 1133 * B_websiteADFunc(spacingTime, adTimes), B_showDisplayFunc(adTimes), websiteAdCloseFunc(), getClientHeight(), countImg() 1134 */ 1135var ad_time, 1136 spacing_time; 1137function B_websiteADFunc(spacingTime, adTimes){ 1138 ad_time = parseFloat(adTimes); 1139 spacing_time = parseFloat(spacingTime) + ad_time; 1140 1141 B_showDisplayFunc(ad_time) 1142 if(ad_time > 0) { 1143 var timecount = setInterval(function() { 1144 if(ad_time == 0) { 1145 // console.log('ADå ³éäº'); 1146 clearInterval(timecount); 1147 websiteAdCloseFunc(); 1148 }else { 1149 ad_time -- 1150 // console.log('ad_time', ad_time); 1151 } 1152 B_showDisplayFunc(ad_time) 1153 }, 1000) 1154 1155 var sp = setInterval(function() { 1156 if(spacing_time == 1) { 1157 clearInterval(sp); 1158 B_websiteADFunc(spacingTime, adTimes); 1159 // console.log('spacing_time return'); 1160 }else { 1161 spacing_time --; 1162 // console.log('spacing_time', spacing_time); 1163 } 1164 }, 1000) 1165 } 1166} 1167 1168function B_showDisplayFunc(adTimes){ 1169 var obj = $('.dialog_show_ad'); 1170 obj.addClass("banner_show"); 1171 1172 if (adTimes == 0){ 1173 obj.removeClass("banner_show"); 1174 }else{ 1175 obj.find("font").html(adTimes); 1176 } 1177} 1178 1179// website ad 廣åå ³é 1180function websiteAdCloseFunc() { 1181 $('.dialog_show_ad').removeClass("banner_show"); 1182 spacing_time = spacing_time - ad_time; 1183 ad_time = 0; // 䏿¸ 0ï¼å¨ç¹å»å ³éå¼¹çªæ¶ä¼æBUG 1184} 1185 1186// è·åå¯è§çªé«åº¦ 1187function getClientHeight() { 1188 var clientHeight = 0; 1189 if(document.body.clientHeight&&document.documentElement.clientHeight){ 1190 clientHeight = (document.body.clientHeight<document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight; 1191 }else{ 1192 clientHeight = (document.body.clientHeight>document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight; 1193 } 1194 return clientHeight; 1195} 1196 1197// å¼¹çªå¹¿åçæ¾ç¤ºå¾çç大å°å¤æ 1198function countImg() { 1199 // 夿·ç¶åå½åºå»£å大尿¯å¦è¶ åºå±å¹é«åº¦ 1200 var natImg = $('.banner_top_img').find('img'); 1201 var height = 0; 1202 natImg.each(function() { 1203 $(this).load(function() { 1204 if($(this).height() > height) { 1205 height = $(this).height(); 1206 } 1207 var b = natImg.width() / height; // 宽髿¯ 1208 var z = getClientHeight() * b - 110; 1209 if($(window).width() > z) { 1210 $('.banner_top').width(z); 1211 }else { 1212 $('.banner_top').width('85%'); 1213 } 1214 }) 1215 }) 1216 1217} 1218 1219// æå¨å±å¹å®½åº¦çæ¶åéæ°è®¡ç®å¼¹çªå¹¿åå¾ççå¤§å° 1220$(window).resize(function() { 1221 if(getClientHeight() < 200) return false;
1222 countImg(); 1223}) 1224 1225/** 1226 * æ»å¨å¹¿å -C 1227 * @param {*} spacingTime 廣ååºç¾çééæé 1228 * @param {*} adTimes 廣åå±ç¤ºæé 1229 * @param {*} id 1230 */ 1231function C_websiteADFunc(spacingTime, adTimes, id){ 1232 // é ç½®çæ¶é´ 1233 var spacingTime = parseInt(spacingTime); 1234 var adTimes = parseInt(adTimes); 1235 1236 // 䏿¬¡ä¿åå©ä½çæ¶é´ 1237 var showTime = parseInt($.cookie("C_showTime")) || 0; 1238 var hideTime = parseInt($.cookie("C_hideTime")) || 0; 1239 1240 // 妿æ¾ç¤ºæ¶é´å·²ç»ä¸º0ï¼é设é´éæ¾ç¤ºæ¶é´çcookieï¼å¦åç»§ç»è®¡æ° 1241 if(hideTime > 0 && showTime > 0) { 1242 C_showDisplayFunc(showTime, id); // ç»§ç»ä¸æ¬¡å©ä½çæ¶é´ 1243 var totalTime = hideTime + showTime; // å计æ¶é´ 1244 setInterval(() => { 1245 if(totalTime == 0) { 1246 totalTime = adTimes + spacingTime; // éç½®æ¶é´ 1247 $.cookie("C_hideTime", totalTime, { expires: 7 }); // cookieè®°å½æ¶é´ 1248 C_showDisplayFunc(adTimes, id); // ä½¿ç¨æ°è®¾ç½®çæ¶é´ 1249 }else { 1250 totalTime --; 1251 $.cookie("C_hideTime", totalTime, { expires: 7 }); 1252 } 1253 }, 1000); 1254 }else if(hideTime > 0 && showTime == 0) { 1255 setInterval(() => { 1256 if(hideTime == 0) { 1257 hideTime = adTimes + spacingTime; 1258 $.cookie("C_hideTime", hideTime, { expires: 7 }); 1259 C_showDisplayFunc(adTimes, id); 1260 }else { 1261 hideTime --; 1262 $.cookie("C_hideTime", hideTime, { expires: 7 }); 1263 } 1264 }, 1000); 1265 }else{ 1266 // å®å ¨åå§ï¼ç¬¬ä¸æ¬¡åºç°ä¸æ»å¹¿åçç¨æ·æ§è¡ä»¥ä¸ 1267 // æ¾ç¤ºæ¶é´å·²ç»æ¸ 0åï¼ä½¿ç¨æ°çæ¶é´è¿è¡è®¡æ° 1268 C_showDisplayFunc(adTimes, id) 1269 var totalTime = adTimes + spacingTime; 1270 setInterval(() => { 1271 if(totalTime == 0) { 1272 totalTime = adTimes + spacingTime; 1273 $.cookie("C_hideTime", totalTime, { expires: 7 }); 1274 C_showDisplayFunc(adTimes, id); 1275 }else { 1276 totalTime --; 1277 $.cookie("C_hideTime", totalTime, { expires: 7 }); 1278 } 1279 }, 1000); 1280 } 1281 1282} 1283// 䏿»å¹¿åæ¾ç¤ºæ¶é´è®¡æ¶ 1284var C_showCount = true; 1285function C_showDisplayFunc(adTimes, id){ 1286 var obj = $('.c_website_banner'); 1287 var objWidth = parseInt(obj.find('img').data('width')), 1288 objHeight = obj.find('img').data('height') 1289 var height = obj.find('.ad-jump-click').width() * objHeight / objWidth 1290 height = height.toFixed(0) 1291 1292 if ($('#header-menu-column-item-root').hasClass('header-menu-item-link-active')) $('#header-menu-column-sub').css({'top':'calc(100% + '+ height +'px)', 'transition':'all 0.6s ease'}); 1293 obj.find('.banner').height(height); 1294 obj.find('font').html(adTimes); 1295 1296 // å±ç¤ºæ¬¡æ°ç»è®¡ 1297 if(C_showCount) { 1298 ADshowCountFunc(id, false, `䏿»AD`); 1299 C_showCount = false; // 页é¢å·æ°åï¼åªä¼æ§è¡ä¸æ¬¡å±ç¤ºç»è®¡ 1300 } 1301 1302 var C_showADTime = setInterval(function(){ 1303 adTimes --; 1304 obj.find("font").html(adTimes); 1305     if (adTimes == 0){ 1306 clearInterval(C_showADTime); 1307 if ($('#header-menu-column-item-root').hasClass("header-menu-item-link-active")) $('#header-menu-column-sub').css("top","calc(100%)"); 1308 obj.find('.banner').height(0); 1309 $.cookie("C_showTime", 0, { expires: 7 }); 1310     }else{ 1311 $.cookie("C_showTime", adTimes, { expires: 7 }); 1312 } 1313 }, 1000); 1314} 1315 1316/** 1317 * å ¬å ± - 对è广å -E 1318 * @param {*} t 1319 * @param {*} col 1320 */ 1321function coupletADpositionFunc(t, col) { 1322 var column = device + '-E-' + t + col; 1323 getADcontentFunc('prefix', column + '-', function(res) { 1324 if(res.code == 0) { 1325 var data = res.data; 1326 var mol; // åºåå·¦å³ä¸¤ä¾§æ¾ç¤ºï¼è¿æ¯å·¦å³æ»å ¥æ¾ç¤º 1327 if(screenWidth > 1815) { 1328 mol = 1 1329 // å·¦å³ä¸¤ä¾§æ¾ç¤º 1330 var left_html = `<div class="couplet-ad couplet-left ad-img-show" data-position="${column}-1"></div>` 1331 var right_html = `<div class="couplet-ad couplet-right ad-img-show" data-position="${column}-2"></div>` 1332 $('#inner-container').prepend(left_html, right_html); 1333 1334 var coupletStyle = `<style> 1335 .couplet-ad {position: fixed; left: 50%; top: 214px; z-index: 1999; width: 300px; height: auto;} 1336 .couplet-left {margin-left: -${$('.container').width() / 2 + 320}px;} 1337 .couplet-right {margin-left: ${$('.container').width() / 2 + 20}px;} 1338 </style>` 1339 $('body').append(coupletStyle) 1340 AdInsertionFunc(data); 1341 }else { 1342 mol = 2 1343 // 左峿»å¨è¿å ¥ 1344 var left_html = `<div class="couplet-ad couplet-left"> 1345 <div class="ad-img-show" data-position="${column}-1"></div> 1346 </div>` 1347 var right_html = `<div class="couplet-ad couplet-right"> 1348 <div class="ad-img-show" data-position="${column}-2"></div> 1349 </div>` 1350 $('#inner-container').prepend(left_html, right_html); 1351 1352 var coupletStyle = `<style> 1353 .couplet-ad {position: fixed; top: 0; z-index: 2000; width: 100%; height: 100%; background: rgba(0,0,0,.5)} 1354 .couplet-ad .ad-img-show {position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);} 1355 .couplet-left {left: -100%; transition: all 0.5s} 1356 .couplet-left.on {left: 0;} 1357 1358 .couplet-right {right: -100%; transition: all 0.5s} 1359 .couplet-right.on {right: 0;} 1360 </style>` 1361 $('body').append(coupletStyle) 1362 AdInsertionFunc(data, 1); 1363 } 1364 1365 // éåè·åå®ä»¬çå¾çæ¾ç¤ºæ¶é´åé´éæ¶é´ PSï¼é´éæ¶é´æ²¡ç¨ä¸ 1366 var keepTime_1 = $(`.couplet-left img`).data('keeptime') || 0, 1367 intervalTime_1 = $(`.couplet-left img`).data('intervaltime') || 0, 1368 keepTime_2 = $(`.couplet-right img`).data('keeptime') || 0, 1369 intervalTime_2 = $(`.couplet-right img`).data('intervaltime') || 0; 1370 console.log('keepTime_1/2', keepTime_1, keepTime_2); 1371 1372 $('.couplet-ad').each(function(i) { 1373 var $img = $(this).find('img'), 1374 url = $img.attr('data-url'), 1375 id = $img.parent('.ad-jump-click').attr('data-id'); 1376 1377 // å½é¡µé¢å¯ç´æ¥å±ç¤ºå¯¹è广åä¸éè¦å¼¹åºæ¾ç¤ºæ¶ï¼ç´æ¥å±ç¤ºå¹¶è®¡æ° 1378 if(mol == 1 && url) { 1379 var img = new Image(); 1380 img.src = url; 1381 1382 img.onload = function() { 1383 $img.attr('src', url).removeClass('scale50'); 1384 $img.parent('.ad-jump-click').attr('data-count', '1'); 1385 // å±ç¤ºåç»è®¡æ¬¡æ° 1386 ADshowCountFunc(id, false, $img.parents('.ad-img-show').data('position') + ' 对èAD') 1387 } 1388 } 1389 1390 // if(i == 0) { 1391 // // left 1392 // keepTime_1 = $img.attr('data-keeptime'); 1393 // intervalTime_1 = $img.attr('data-intervaltime'); 1394 // }else { 1395 // // right 1396 // keepTime_2 = $img.attr('data-keeptime'); 1397 // intervalTime_2 = $img.attr('data-intervaltime'); 1398 // } 1399 }) 1400 console.log('mol', mol); 1401 if(mol == 2) { 1402 var hasLeftImg = $(`.couplet-ad .ad-img-show[data-position="${column}-1"]`).find('img').length > 0 ? true : false, 1403 hasRightImg = $(`.couplet-ad .ad-img-show[data-position="${column}-2"]`).find('img').length > 0 ? true : false;
1404 1405 if(hasLeftImg) { 1406 console.log('hasLeftImg'); 1407 img_1 = new Image(); 1408 img_1.src = $('.couplet-left img').attr('data-url'); 1409 img_1.onload = function() { 1410 $('.couplet-left img').attr('src', img_1.src).removeClass('scale50'); 1411 $('.couplet-left').addClass('on'); 1412 ADshowCountFunc($('.couplet-left .ad-jump-click').attr('data-id'), false, $('.couplet-left .ad-img-show').data('position') + ' 对èAD'); 1413 setTimeout(() => { 1414 $('.couplet-left').removeClass('on'); 1415 }, keepTime_1); 1416 } 1417 } 1418 if(hasRightImg) { 1419 console.log('hasRightImg'); 1420 // å³è¾¹å¯¹èæ»å¨åºæ¥æ¶éè¦å å¤æå·¦è¾¹æ¯å¦åå¨å¹¿åï¼è¿è¡å»¶è¿å±ç¤º 1421 img_2 = new Image(); 1422 img_2.src = $('.couplet-right img').attr('data-url'); 1423 img_2.onload = function() { 1424 $('.couplet-right img').attr('src', img_2.src).removeClass('scale50'); 1425 // 妿1ä½ç½®æå¾çå»¶è¿æ§è¡ï¼åä¹ç´æ¥æ§è¡ 1426 setTimeout(() => { 1427 $('.couplet-left').removeClass('on'); 1428 $('.couplet-right').addClass('on'); 1429 ADshowCountFunc($('.couplet-right .ad-jump-click').attr('data-id'), false, $('.couplet-right .ad-img-show').data('position') + ' 对èAD'); 1430 setTimeout(() => { 1431 $('.couplet-right').removeClass('on'); 1432 }, keepTime_2); 1433 }, keepTime_1); 1434 } 1435 } 1436 } 1437 1438 // todo è¿éæBUGï¼æ²¡æèèå°å¯è½åªæä¸¤ä¸ªä½ç½®å¹¶ä¸ä¼åæ¶ææ°æ® å¨å¯¼è´é¡µé¢è¯·æ±undefinedå°å 201127 1439 // if(mol == 2) { 1440 // // è·åå·¦ä¾§çæ¯å¦å è½½å® 1441 // var img_1 = new Image(); 1442 // img_1.src = $('.couplet-left img').attr('data-url'); 1443 1444 // $('.couplet-left img').parent('.ad-img-show').attr('data-count', '1'); 1445 // $('.couplet-right img').parent('.ad-img-show').attr('data-count', '1'); 1446 // img_1.onload = function() { 1447 // $('.couplet-left img').attr('src', img_1.src).removeClass('scale50'); 1448 1449 // // 临æ¶å¤çäº æ1没æ2ä½ç½®çåºæ¯ line1156åé®é¢ 1450 // if (!$('.couplet-right img').attr('data-url')) { 1451 // console.log(1); 1452 // $('.couplet-left').addClass('on'); 1453 // setTimeout(() => { 1454 // $('.couplet-right').removeClass('on'); 1455 // }, keepTime_1); 1456 // }else { 1457 // console.log(2); 1458 // // å³è¾¹çå¾çä¹å è½½å®æ¯ 1459 // var img_2 = new Image(); 1460 // img_2.src = $('.couplet-right img').attr('data-url'); 1461 // console.log('img_2.src', img_2.src); 1462 // img_2.onload = function() { 1463 // $('.couplet-right img').attr('src', img_2.src).removeClass('scale50'); 1464 // $('.couplet-left').addClass('on'); 1465 // ADshowCountFunc($('.couplet-left .ad-jump-click').attr('data-id'), false, $('.couplet-left .ad-img-show').data('position') + ' 对èAD'); 1466 // setTimeout(() => { 1467 // $('.couplet-left').removeClass('on'); 1468 // $('.couplet-right').addClass('on'); 1469 // ADshowCountFunc($('.couplet-right .ad-jump-click').attr('data-id'), false, $('.couplet-right .ad-img-show').data('position') + ' 对èAD'); 1470 // setTimeout(() => { 1471 // $('.couplet-right').removeClass('on'); 1472 // }, keepTime_2); 1473 // }, keepTime_1); 1474 // } 1475 // } 1476 // } 1477 // } 1478 } 1479 }) 1480} 1481 1482/**
1483 * å ¬å ± - å å®¹é¡µèæ¯å¹¿å/æç« å 容åºé¨å¹¿å -D 1484 */ 1485function contentADpositionFunc() { 1486 var articleType = $('.articleContent').data('type'); 1487 if(!articleType) return; // ä¸å卿¶åæ¢æ§è¡ 1488 1489 var column = articleColumnFunc(device2, 'A'); 1490 1491 // æç« 页é¢å ¼å®¹å¤ç 1492 // å ¼å®¹åå¥é é¢ï¼å¨Pæ¨ç±¤å¤åå¨å ¶ä»æ¨ç±¤ï¼æå°è´ç¡æ³æ£ç¢ºç²åä½ç½® 1493 var $strong = $('.article-content>strong'); 1494 if($strong.length > 0) { 1495 // 鲿¢æå¤åstrongå¨ä¸åä½ç½® 1496 $strong.each(function() { 1497 var $strong_p = $(this).children('p'); 1498 $strong_p.css('font-weight', '600'); 1499 $(this).after($strong_p); // å°è£é¢çå §å®¹ç§»å°å ¶å¾ 1500 $(this).remove(); // ç§»åå¾åªé¤éå空ç 1501 }) 1502 } 1503 var $em = $('.article-content>em'); 1504 if($em.length > 0) { 1505 // 鲿¢æå¤åemå¨ä¸åä½ç½® 1506 $em.each(function() { 1507 var $em_p = $(this).children('p'); 1508 $em_p.css('font-style', 'italic'); 1509 $(this).after($em_p); // å°è£é¢çå §å®¹ç§»å°å ¶å¾ 1510 $(this).remove(); // ç§»åå¾åªé¤éå空ç 1511 }) 1512 } 1513 var $del = $('.article-content>del'); 1514 if($del.length > 0) { 1515 // 鲿¢æå¤ådelå¨ä¸åä½ç½® 1516 $del.each(function() { 1517 var $del_p = $(this).children('p'); 1518 $del_p.css('text-decoration', 'line-through'); 1519 $(this).after($del_p); // å°è£é¢çå §å®¹ç§»å°å ¶å¾ 1520 $(this).remove(); // ç§»åå¾åªé¤éå空ç 1521 }) 1522 } 1523 1524 // åå°ç¨æ¨¡ç³æç´¢ï¼å½åæ¯d1å 容ï¼å好d11ææ°æ®ï¼ä¼æé£ä¸ªä¹æåºæ¥æä»¥è¦å 个'-'æªä½å® 1525 getADcontentFunc('prefix', column + '-', function(res) { 1526 if(res.code == 0) { 1527 var data = res.data; 1528 1529 // èªå®ä¹æ°ç广åå¡«å ä½ç½®ï¼æ¿æ¢AdInsertionFunc(data) 1530 var hasBackgroundAD = false; 1531 var imgUrl = '', 1532 clickContent = '', 1533 id = '', 1534 adStyle = ''; 1535 for(var k in data) { 1536 var item = data[k]; 1537 // åºå®èæ¯å¹¿å 1538 if(item.tagNo == column + '-1') { 1539 imgUrl = item.ads[0].resources[0].url; 1540 clickContent = JSON.stringify(item.ads[0].clickContent); 1541 id = item.ads[0].adId; 1542 adStyle = item.ads[0].adStyle; 1543 hasBackgroundAD = true; 1544 } 1545 // æç« å 容åºé¨å¹¿å 1546 if(item.tagNo == column + '-2') { 1547 var articleBottomAD = `<div class="ad-img-show" data-position="${column + '-2'}"></div>` 1548 $('.article-content').append(articleBottomAD) 1549 AdInsertionFunc([item]); 1550 } 1551 } 1552 1553 // åå¨æç« èæ¯å¹¿åæ°æ®ææ§è¡ 1554 if(hasBackgroundAD) { 1555 // 广åä½ç½®æå ¥ è¿éçdata-positionå®é ä½ç¨åªæ¯åèä½ç½® 1556 var agent = navigator.userAgent; 1557 if(screenWidth > 480) { 1558 if(agent.indexOf('WOW64') > -1) { 1559 // çµèç微信æå¼æ¶ 1560 var newWidth = $('.article-content').width(), 1561 mLeft = $('.article-content').offset().left; 1562 var newsHTML = `<div class="newsAD"> 1563 <div class="ad_tips_top"><span>[è´å©] å §ææªå®è«å䏿»¾å</span></div> 1564 <div class="newsAD_clip" 1565 onclick='adJumpClickFunc(${id}, ${clickContent}, ${adStyle})' 1566 data-count="0" 1567 style="background: url(${imgUrl}) no-repeat ${mLeft}px center; background-size: ${newWidth}px auto; background-attachment:fixed;" 1568 data-position="${column}-1" 1569 ></div> 1570 <div class="ad_tips_bottom"></div> 1571 </div>`; 1572 $(window).resize(function() { 1573 newWidth = $('.article-content').width(); 1574 mLeft = $('.article-content').offset().left; 1575 $('.newsAD_clip').css({'background-position': mLeft + 'px center', 'background-size': newWidth + 'px auto'}); 1576 }) 1577 }else { 1578 var newsHTML = `<div class="newsAD"> 1579 <div class="ad_tips_top"><span>[è´å©] å §ææªå®è«å䏿»¾å</span></div> 1580 <div class="newsAD_clip"> 1581 <div class="newsAD_box"> 1582 <div class="newsAD_main" onclick='adJumpClickFunc(${id}, ${clickContent}, ${adStyle})' data-count="0"> 1583 <a data-position="${column}-1"> 1584 <img class="PCshow" src="${imgUrl}" data-position="${column}-1"> 1585 </a> 1586 </div> 1587 </div> 1588 </div> 1589 <div class="ad_tips_bottom"></div> 1590 </div>`; 1591 } 1592 }else { 1593 var newsHTML = `<div class="newsAD"> 1594 <div class="ad_tips_top"><span>[è´å©] å §ææªå®è«å䏿»¾å</span></div> 1595 <a onclick='adJumpClickFunc(${id}, ${clickContent}, ${adStyle})' data-count="0"></a> 1596 <div class="ad_tips_bottom"></div> 1597 </div>`; 1598 var imgAD = `<img class="imgAD" src="${imgUrl}" data-position="${column}-1">` 1599 } 1600 1601 // 夿æç« æ¯å¦è¶ è¿3è¡ 1602 var $p = $('.article-content > *'); 1603 $('#article-img-set img, .article-content img').addClass('news-img'); 1604 $('.news-img').error(function () { //å è½½å¾ç åºç°404ç¶ææ¶è§¦å 1605 $(this).attr("src", "/img/noImg.png"); //å°å è½½ä¸å°çå¾ç çsrc屿§ ä¿®æ¹æé»è®¤ å¾ç ï¼æ³¨æï¼é»è®¤å¾çå¿ é¡»ä¿è¯åå¨ï¼å¦å ä¼ä¸ç´ è°ç¨ æ¤å½æ° 1606 }); 1607 if($p.length >= 3){ 1608 // PCæ¾ç¤ºä¸ç广åå¾æå ¥ä½ç½® 1609 if(screenWidth > 480) { 1610 1611 // 夿å¾çå è½½ç彿° 1612 var mulitImg = [], 1613 img = []; 1614 $('.news-img').each(function (i) { 1615 mulitImg[i] = $(this).attr('src'); 1616 }); 1617 1618 $p.each(function() { 1619 var that = $(this); 1620 if(that.html() == '') { 1621 that.remove();
1621 // æç« æå伿ä¸ä¸ªç©ºç½çpæ ç¾ï¼ä¸æ¸ é¤ä¼å½±åæå ¥ä½ç½® 1622 } 1623 }) 1624 $.each(mulitImg,function(i){ 1625 img[i] = new Image(); 1626 img[i].src = mulitImg[i]; 1627 img[i].onload = function() { 1628 if(i == mulitImg.length-1) { 1629 setTimeout(() => { 1630 $p.each(function(i) { 1631 var that = $(this); 1632 var top = that.offset().top; 1633 var stopEach = false; 1634 // å½åçPå¿ é¡»é«äºå±å¹é«åº¦ ä¸ è¦å¨å¤§äº2个Pæ¶æå ¥ 1635 if(top > document.documentElement.clientHeight && i >= 2) { 1636 stopEach = true; 1637 if(that.find('img').length > 0){ 1638 if(i == $('.article-content p').length - 1) { 1639 that.after(newsHTML); // å·²æ¯æåä¸ä¸ªpæ¶è¿å å«å¾çï¼ä¸éè¦å»¶ååæå ¥äº 1640 // console.log('å·²æ¯æåä¸ä¸ªpæ¶è¿å å«å¾çï¼ä¸éè¦å»¶ååæå ¥äº'); 1641 }else { 1642 that.next().after(newsHTML); 1643 // console.log('å»¶åä¸ä¸ªPæå ¥å¹¿å'); 1644 } 1645 }else{ 1646 that.after(newsHTML); 1647 } 1648 return false; 1649 } 1650 if(stopEach) return false; 1651 }) 1652 // ç»æå¾ªç¯æ¶æªææå ¥çï¼ç´æ¥æå ¥æåä¸ä¸ªp 1653 if($('.newsAD').length == 0) { 1654 $p.eq(-1).after(newsHTML); 1655 } 1656 }, 500); 1657 } 1658 } 1659 }) 1660 1661 }else { 1662 // mobile 1663 if($p.eq(2).find('img').length>0){ 1664 if($p.length==3){ 1665 $p.eq(-1).after(newsHTML); 1666 }else{ 1667 $p.eq(3).after(newsHTML); 1668 } 1669 }else{ 1670 $p.eq(2).after(newsHTML); 1671 } 1672 1673 if($('.newsAD').length > 0) { 1674 $('#inner-container').append(imgAD); // åç 1675 $('#article-container .gutter-20 .col-sm-8').prepend('<div class="section_bgf"></div>') 1676 $('.article-sub-title, .article-main-title, .article-action').appendTo($('.section_bgf')); 1677 1678 $('.article-content > *:not(".newsAD")').css('background', '#f1f1f1'); 1679 $('.article-content p, .article-content h1, .article-content h2, .article-content h3, .article-content h4, .article-content h5').css({'margin': '0','padding-bottom': '10px'}); 1680 // 徿³¨éå§ï¼æç« 編輯æå¯è½æåºç¾æ²ææ¨ç±¤ç段è½ï¼æ²è¾¦æ³é䏿¾å¨ä¸åå ç´ ä¸ 210225 1681 // var index = $('.newsAD').index(); 1682 // $('.article-content').prepend('<div class="part1"></div>'); 1683 // $p.eq(index).after('<div class="part2"></div>'); 1684 1685 // $p.each(function(i) { 1686 // if(i < index) { 1687 // $(this).appendTo($('.part1')); 1688 // }else { 1689 // $(this).appendTo($('.part2')); 1690 // } 1691 // }) 1692 articleBgSet() 1693 } 1694 } 1695 }else{ 1696 $p.eq(-1).after(newsHTML); 1697 if(screenWidth <= 480) { 1698 // å½é¡µé¢æ²¡æè¶ è¿3个Pï¼ä¸åæ¯ææºæ¶ï¼éè¦æå ¥å¹¿åå¾ç 1699 $('#inner-container').append(imgAD); // åç 1700 $('#article-container .gutter-20 .col-sm-8').prepend('<div class="section_bgf"></div>') 1701 $('.article-sub-title, .article-main-title, .article-action').appendTo($('.section_bgf')); 1702 1703 $('#article-container p').css('background', '#f1f1f1'); 1704 // 徿³¨éå§ï¼æç« 編輯æå¯è½æåºç¾æ²ææ¨ç±¤ç段è½ï¼æ²è¾¦æ³é䏿¾å¨ä¸åå ç´ ä¸ 210225 1705 // var index = $('.newsAD').index(); 1706 // $('.article-content').prepend('<div class="part1"></div>'); 1707 // $p.eq(index).after('<div class="part2"></div>'); 1708 // $p.each(function(i) { 1709 // if(i < index) { 1710 // $(this).appendTo($('.part1')); 1711 // }else { 1712 // $(this).appendTo($('.part2')); 1713 // } 1714 // }) 1715 articleBgSet 1716 } 1717 } 1718
1719 // 給廣åä½ä¸ä¸å ©å段è½å §å®¹æ·»å åºè²ï¼è§£æ±ºé¨åæ²ææ¨ç±¤æåç¡åºè²åé¡ 1720 function articleBgSet() { 1721 var $ad = $('.newsAD') 1722 if($ad.length > 0) { 1723 var top = $ad.position().top, 1724 bottom = top + $ad.height(), 1725 articleHeight = $('.article-content').height() - bottom; 1726 $('.article-content').append('<div class="part1"></div><div class="part2"></div>'); 1727 $('.part1').height(top); 1728 $('.part2').css({'top': bottom, 'height': articleHeight}) 1729 } 1730 } 1731 1732 var showOne = true 1733 $(window).scroll(function() { 1734 if($('.newsAD').length > 0) { 1735 var scrollTop = document.documentElement.scrollTop || document.body.scrollTop, 1736 height = document.documentElement.clientHeight; 1737 // console.log(scrollTop, height, $('.newsAD').offset().top); 1738 var newsAdHeight = $('.newsAD').height() || 0; 1739 var newsADTop_offset = $('.newsAD').offset().top || 0; 1740 1741 if(screenWidth > 480) { 1742 if(scrollTop > newsADTop_offset-500) { 1743 if(showOne) ADshowCountFunc(id); 1744 showOne = false;
1745 } 1746 }else { 1747 var adTop = $('.imgAD').length > 0 ? $('.imgAD').offset().top : 0; 1748 if(scrollTop > newsADTop_offset - height && adTop-newsAdHeight < newsADTop_offset) { 1749 $('.imgAD').css('opacity', '1'); 1750 }else { 1751 $('.imgAD').css('opacity', '0'); 1752 } 1753 // çå°å¤§åå¼ å¾çæ¶æç®è¢«å±ç¤ºï¼ç»è®¡æè®¡æ° 1754 if(scrollTop > newsADTop_offset-200) { 1755 if(showOne) ADshowCountFunc(id); 1756 showOne = false; 1757 } 1758 1759 if($('.fix_icon_url').length > 0) { 1760 var fixTop = $('.fix_icon_url').offset().top; 1761 var fixPosTop = $('.fix_icon_url').position().top; 1762 if(fixTop+62 > newsADTop_offset && fixTop < newsADTop_offset+newsAdHeight) { 1763 $('.fix_icon_url a').hide(); 1764 }else { 1765 $('.fix_icon_url a').show(); 1766 } 1767 } 1768 } 1769 1770 } 1771 }) 1772 1773 $(window).resize(function() { 1774 if(screenWidth > 767) { 1775 $('.articleContent').next('.imgAD').hide(); 1776 }else { 1777 $('.articleContent').next('.imgAD').show(); 1778 } 1779 }) 1780 } 1781 } 1782 }) 1783} 1784 1785/** 1786 * å ¬å ± - è·åå½åæç« 详æ 页ç广åä½ç½® 1787 * PS: å å®¹èæ¯å¹¿åç¨çæ¯device2ï¼è§ååå ¶å®ä¸å 1788 */ 1789function articleColumnFunc(device, type) { 1790 var col = '-', // é»èªå¥ä¹ä¸è¦ 1791 articleType = $('.articleContent').data('type'), 1792 articleColumn = $('.articleContent').data('column'); 1793 1794 if(articleType == 'article') { 1795 // 仿¥åæ¥ 1796 if(articleColumn == 'macau') col = 2 1797 if(articleColumn == 'world') col = 3 1798 if(articleColumn == 'china') col = 4 1799 if(articleColumn == 'business') col = 5 1800 if(articleColumn == 'sports') col = 6 1801 if(articleColumn == 'leisure') col = 7 1802 if(articleColumn == 'investment') col = 8 1803 }else if(articleType == 'supplement') { 1804 // çæ´» 1805 if(articleColumn == '9') col = 10 // æ¸¸æ¾³åæ 1806 if(articleColumn == '2') col = 11 // é¥®é£ 1807 if(articleColumn == '5') col = 12 // 汽车 1808 if(articleColumn == '3') col = 13 // æ æ¸¸ 1809 if(articleColumn == '7') col = 14 // æ¶è´¹ 1810 if(articleColumn == '8') col = 15 // 䏿 1811 }else if(articleType == 'hotarticle') { 1812 col = 1 1813 } 1814 return `${device}-${type}-D${col}` 1815} 1816 1817/** 1818 * æç« 详æ 页 - æç« åºé¨æ¬æµ®å¹¿å -F 1819 */ 1820function articleBottomADFunc(){ 1821 var column = articleColumnFunc(device, 'F') + '-1'; 1822 getADcontentFunc('prefix', column, function(res) { 1823 if(res.code == 0) { 1824 var data = res.data; 1825 var newsHTML = `<div class="bottomAD"> 1826 <div class="bottomAD_box"> 1827 <div class="img_box"> 1828 <a class="ad-img-show" data-position="${column}"></a> 1829 <div class="close_AD" onclick="$('.bottomAD').remove();"></div> 1830 </div> 1831 </div> 1832 </div>`; 1833 $('body').append(newsHTML); 1834 AdInsertionFunc(data) 1835 var $img = $('.bottomAD').find('img'), 1836 url = $img.data('url') 1837 var img = new Image(); 1838 img.src = url; 1839 img.onload = function() { 1840 $img.attr('src', url).attr('data-count', '1').removeClass('scale50'); 1841 // å±ç¤ºåç»è®¡æ¬¡æ° 1842 ADshowCountFunc($img.data('id')) 1843 } 1844 } 1845 }) 1846} 1847 1848/** 1849 * æç« 详æ 页 - ç»å广å -D 1850 */ 1851function comeboADFunc() { 1852 var column = articleColumnFunc(device3, 'D') + '-1'; 1853 getADcontentFunc('prefix', column, function(res) { 1854 if(res.code == 0) { 1855 var data = res.data; 1856 var adsItem = data[0].ads[0]; 1857 1858 var maxImg, minImg 1859 // çæ¼2çºçµå廣åï¼çæ¼1çºæ¸æµ®å»£å 1860 if(adsItem.resources.length == 2) { 1861 if(adsItem.resources[1].height > adsItem.resources[0].height) { 1862 maxImg = adsItem.resources[1].url 1863 minImg = adsItem.resources[0].url 1864 }else { 1865 maxImg = adsItem.resources[0].url 1866 minImg = adsItem.resources[1].url 1867 } 1868 }else { 1869 // maxImg = ''0 1870 // minImg = adsItem.resources[0].url 1871
1872 // åå¼ çè¯æ§è¡æ¬æµ®çå¹¿åæ¹æ¡ articleBottomADFunc()æ¹æ³å·²åºå¼ï¼ç»ååæ¬æµ®åè½åå¹¶ 1873 // ps: éæ±ä¸è¦å ³éæé® 1874 var newsHTML = `<div class="bottomAD"> 1875 <div class="bottomAD_box"> 1876 <div class="img_box"> 1877 <a class="ad-img-show" data-position="${column}"></a> 1878 <div class="close_AD hide" onclick="$('.bottomAD').remove();"></div> 1879 </div> 1880 </div> 1881 </div>`; 1882 $('body').append(newsHTML); 1883 AdInsertionFunc(data) 1884 try { 1885 var thatImg = data[0].ads[0].resources[0] 1886 var imgWidth = thatImg.width, 1887 imgHeight = thatImg.height 1888 var setHeight = imgHeight * $('body').width() / imgWidth 1889 setHeight = setHeight.toFixed(0) 1890 $('.img_box .ad-img-show').height(setHeight); 1891 }catch(e) { 1892 $('.bottomAD').remove(); 1893 console.log('> error åºé¨æ¬æµ®dataæ°æ®æè¯¯'); 1894 return 1895 } 1896 1897 var $img = $('.bottomAD').find('img'), 1898 url = $img.data('url') 1899 var img = new Image(); 1900 img.src = url; 1901 img.onload = function() { 1902 $img.parents('.ad-jump-click').attr('data-count', '1'); 1903 $img.attr('src', url).removeClass('scale50'); 1904 // å±ç¤ºåç»è®¡æ¬¡æ° 1905 ADshowCountFunc($img.parents('.ad-jump-click').data('id'), false, 'æ¬æµ®AD') 1906 } 1907 return 1908 } 1909 1910 var comboADImg = maxImg, 1911 comboADBottomImg = minImg, 1912 keepTime = adsItem.keepTime / 1000 1913 intervalTime = adsItem.intervalTime / 1000, 1914 id = adsItem.adId, 1915 clickContent = JSON.stringify(adsItem.clickContent), 1916 style = adsItem.adStyle; 1917 1918 var comboADHtml = ` 1919 <div class="comboAD-box"> 1920 <div class="comboAD-img"> 1921 <img src="${comboADImg}" onclick='adJumpClickFunc(${id}, ${clickContent}, ${style})' /> 1922 </div> 1923 </div> 1924 <div class="comboAD-bottom"> 1925 <div class="comboAD-bottom-img"> 1926 <img src="${comboADBottomImg}" onclick='adJumpClickFunc(${id}, ${clickContent}, ${style})' /> 1927 <div class="comboAD-btn comboAD-close ${!comboADImg && 'hide'}"></div> 1928 <div class="comboAD-btn comboAD-open ${!comboADImg && 'hide'}"></div> 1929 </div> 1930 </div> 1931 `; 1932 $('body').append(comboADHtml); 1933 ADshowCountFunc(id); 1934 1935 var firstShow = true 1936 $(window).scroll(function() { 1937 var sTop = 0; 1938 if (document.documentElement && document.documentElement.scrollTop) { 1939 sTop = document.documentElement.scrollTop; 1940 }else if (document.body) { 1941 sTop = document.body.scrollTop; 1942 } 1943 if(sTop > 300 && firstShow) { 1944 firstShow = false 1945 // å½åcookieä¸ä¿ç䏿¬¡å©ä½æ¶é´æ¶ï¼å¾ç¨å®åæ¾ç¤º 1946 // è§£å³ä¸æ¬¡å©ä½å ç§æ¶ï¼è¿æ¬¡è¿æ¥åæ¾ç¤ºå®ååçªç¶è¯»å®ä¸æ¬¡æ¶é´å次æ¾ç¤ºï¼ä¼æ¾ç¤ºå¾å¿« 1947 if(!!getCookie('comboADTime') && getCookie('comboADTime') != intervalTime) { 1948 var sec = parseInt(getCookie('comboADTime')); 1949 var secTime = setInterval(() => { 1950 sec --; 1951 if(sec <= 0) clearInterval(secTime); 1952 console.log(`å©ä½${sec}så è½½ç»å广å`); 1953 }, 1000); 1954 setTimeout(() => { 1955 showADfunc();
1956 setCookie('comboADTime', intervalTime); 1957 }, getCookie('comboADTime')*1000); 1958 }else { 1959 showADfunc(); 1960 } 1961 } 1962 }) 1963 1964 var img1 = false, 1965 img2 = false, 1966 t = true; 1967 var returnTime, 1968 timeout; 1969 1970 $('.comboAD-img img').load(function() { 1971 img1 = true 1972 }) 1973 $('.comboAD-bottom-img img').load(function() { 1974 img2 = true 1975 }) 1976 1977 // å±ç¤ºå¤§å 1978 function showADfunc() { 1979 // æ¯ç§æéï¼ç²åå ©å¼µADæ¯å¦å è¼å®æ 1980 var time = setInterval(() => { 1981 if(img1 && img2 && t) { 1982 t = false; 1983 $('.comboAD-box').fadeIn(100); 1984 $('.comboAD-bottom').fadeOut(); 1985 $('#footer').css('margin-bottom', 0); 1986 ADShowPosition(); // éç½®å ¶é¡¯ç¤ºä½ç½® 1987 clearInterval(time); // æ£å¸¸é¡¯ç¤ºå¾ï¼å¯æ¸ é¤ç¶åçè¨æå¨ 1988 var showTime = setTimeout(() => { 1989 t = true; 1990 $('.comboAD-box').fadeOut(); 1991 $('.comboAD-bottom').fadeIn(); 1992 $('#footer').css('margin-bottom', $('.comboAD-bottom').height()); 1993 returnShowADfunc(); 1994 1995 var imgHeight = $('.comboAD-bottom-img').height(); 1996 $('#footer.margin100').css('margin-bottom', imgHeight); 1997 $('#back-to-top').css('bottom', imgHeight + 30); // 置顶æé®ä½ç½®ä¸ç§» 1998 1999 clearTimeout(showTime); 2000 }, keepTime*1000); 2001 } 2002 }, 1000); 2003 } 2004 2005 // AD position 2006 function ADShowPosition() { 2007 if(screenWidth > 640) { 2008 var top = $('#header').height() + 100 2009 // css topæä¸ªéæ±ï¼éè¦ä¸è½æ¡ä½æ ç® 2010 $('.comboAD-box').css({'top': $('#header').height(), 'height': getClientHeight()-top}); 2011 }else { 2012 $('.comboAD-box').css({'top': '50%', 'transform': 'translateY(-50%)'}); 2013 } 2014 } 2015 2016 // ééæé 2017 function returnShowADfunc() { 2018 var comboTime = intervalTime; // åå§ 2019 // ç¶cookieä¸å卿éååä¾ä½¿ç¨ 2020 if(!!getCookie('comboADTime')) { 2021 comboTime = getCookie('comboADTime'); 2022 } 2023 clearInterval(returnTime); // 調ç¨åå æ¸ é¤ä¸ä¸æ¬¡çè¨æ 2024 returnTime = setInterval(() => { 2025 comboTime --; 2026 setCookie('comboADTime', comboTime); 2027 // console.log('å³å°æ¾ç¤ºç»å广å', comboTime + 's'); 2028 2029 if(comboTime <= 0) { 2030 setCookie('comboADTime', intervalTime); // ç¶0så¾éæ°è³¦å¼ææ°çæé 2031 clearInterval(returnTime); 2032 } 2033 }, 1000); 2034 // timeout = setTimeout(() => { 2035 // // showADfunc() ä¸éè¦éæ°æ¾å¤§ 001 2036 // }, comboTime*1000); 2037 } 2038 2039 // æ¹è®å±å¹æéæ°è¨ç®å±ç¤ºåå¤§å° 2040 $(window).resize(function() { 2041 ADShowPosition(); 2042 2043 // if(screenWidth > 640) { 2044 // var comboADImg = newsAD_IMG, 2045 // comboADBottomImg = newsAD_Resizable_IMG; 2046 // }else { 2047 // var comboADImg = newsAD_IMG_Mb, 2048 // comboADBottomImg = newsAD_Resizable_IMG_Mb; 2049 // } 2050 2051 var imgHeight = $('.comboAD-bottom-img').height(); 2052 $('#footer').css('margin-bottom', imgHeight); 2053 }) 2054 2055 // close AD 2056 $('.comboAD-close').on('click', function() { 2057 $('.comboAD-bottom').hide(); 2058 $('#footer').css('margin-bottom', '0'); 2059 }) 2060 2061 // open AD 2062 $('.comboAD-open').on('click', function() {
2063 setCookie('comboADTime', intervalTime); // å±éADå¾éæ°è¨ç®å ¶éè·æé 2064 2065 $('.comboAD-box').fadeIn(100); 2066 $('.comboAD-bottom').fadeOut(); 2067 $('#footer').css('margin-bottom', '0'); 2068 ADShowPosition(); // éç½®å ¶é¡¯ç¤ºä½ç½® 2069 var openTime = setTimeout(() => { 2070 $('.comboAD-box').fadeOut(); 2071 $('.comboAD-bottom').fadeIn(); 2072 $('#footer').css('margin-bottom', $('.comboAD-bottom').height()); 2073 returnShowADfunc(); 2074 clearTimeout(openTime); 2075 }, keepTime*1000); 2076 }) 2077 2078 } 2079 }) 2080}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.