123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- /**
- * [盒子下拉广告]
- * author: zikkeung
- */
- $(function(){
- var MODE_DEV='dev',
- MODE_RELEASE='release',
- optionsDev = {
- allowOrigin: [
- '127.0.0.1:8080'
- ],
- excludeList: [
- 'v',
- 'd',
- 's',
- 'tag',
- 'hezi',
- /\d{4}/
- ],
- imgRoot: 'http://127.0.0.1:8080/img/',
- swf: 'http://127.0.0.1:8080/img/adtop-on.swf',
- isShowTpAD: true,
- isShowFtAD: false
- },
- optionsRelease = {
- allowOrigin: [
- // 'lol.duowan.com',
- 'ls.duowan.com',
- 'dnf.duowan.com',
- // 'wow.duowan.com',
- 'bns.duowan.com',
- 'wot.duowan.com'
- ],
- excludeList: [
- 'v',
- 'd',
- 's',
- 'tag',
- 'hezi',
- /\d{4}/
- ],
- imgRoot: 'http://assets.dwstatic.com/game/dropdown/img/',
- swf: 'http://assets.dwstatic.com/game/dropdown/img/adtop-on.swf',
- isShowTpAD: true,
- isShowFtAD: false
- },
- options,
- mode;
- mode = MODE_DEV;
- options = (mode === MODE_RELEASE? optionsRelease:optionsDev);
- if (options.allowOrigin.join(',').indexOf(window.location.host) === -1){
- return ;
- }
- if(options.excludeList && options.excludeList.length>0){
- var isInExcludeList = false;
- subexcludeList= [],
- pageReg = /http:\/\/[^\/]*\/([^\/]*)/,
- pageMatch = pageReg.exec(window.location.href),
- pageType = pageMatch? pageMatch[1]:'';
- if (pageType!=='') {
- $.each(options.excludeList, function(i, item){
- isInExcludeList = isInExcludeList || (item.test? item.test(pageType):(item === pageType)) ;
- });
- if (isInExcludeList) { return; }
- };
- }
- if (options.isShowTpAD || options.isShowFtAD){
- var style = '<style type="text\/css">';
- style += 'body{padding-top: 36px !important;}';
- style += '.top-hezi-ad {position: relative;height:auto;_height:0; z-index: 12;background:#2f3646 url('+options.imgRoot+'adtop-bg.jpg) 50% no-repeat;}';
- style += '.top-hezi-ad-bd { height:0; width:1000px;margin: 0 auto; position: relative; overflow: hidden;}';
- style += '.top-hezi-ad .top-hezi-index { position: absolute; left:0; top:0; width:1000px; height:120px; }';
- style += '.top-hezi-ad .top-hezi-ios { position: absolute; left:642px; top:8px; width:216px; height:50px; }';
- style += '.top-hezi-ad .top-hezi-android { position: absolute; left:642px; top:62px; width:216px; height:50px; cursor: pointer;}';
- style += '.top-hezi-ad .top-hezi-qrcode { position: absolute; left:874px; top:7px; width:107px; height:107px; }';
- style += '.top-hezi-ad .top-hezi-ios:hover {background-position: -110px 0;}';
- style += '.top-hezi-ad .top-hezi-android:hover {background-position: -110px -36px;}';
- style += '.top-hezi-ad-trigger{width:140px; height:140px; position: absolute; top: 20px; left:54%; margin:0 0 0 290px; z-index: 10; overflow: hidden;}';
- style += '.top-hezi-ad-trigger a {display: block;height:100%; background: url('+options.imgRoot+'adtop-arrow.png) no-repeat center; _background: url('+options.imgRoot+'adtop-arrow.png) no-repeat center; display: none;}';
- style += '.top-hezi-ad-trigger embed { pointer-events: none;}';
- style += '.top-hezi-ad-trigger-opened a { display: block;}';
- style += '.top-hezi-ad-trigger-opened embed { display: none;}';
- style += '.top-hezi-ad-trigger img {position: absolute; width:100%; height:100%; cursor:pointer;left:0;top:0;}';
- style += '.qrcode-download-bar {background-color:transparent;background-color:rgba(0,0,0,0.85);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#d8000000,endColorstr=#d8000000);position: fixed;_position: absolute;bottom: 0;left: 0;width: 100%;_filter: none;_background-color: #4c4c4c;z-index: 444;}';
- style += '.qrcode-download-bar .qrcode-download-inner {height: 92px;width: 1000px;margin: 0 auto;overflow: hidden;}';
- style += ':root .qrcode-download-bar{filter:none\9}';
- style += '.qrcode-download-bar .close {position: absolute;left: 50%;top: 10px;margin-left: 480px;height: 15px;width: 15px;overflow: hidden;text-indent: -99em;background: url('+options.imgRoot+'qr_code_download_bar.png) no-repeat 0 -257px;_background-image: url('+options.imgRoot+'qr_code_download_bar_ie6.png);}';
- style += '.qrcode-download-bar .slogan {width: 446px;background: url('+options.imgRoot+'qr_code_download_bar.png) no-repeat 0 0;_background-image: url('+options.imgRoot+'qr_code_download_bar_ie6.png);margin: 10px 0 0 28px;height: 70px;float: left;color: #fff;line-height: 26px;}';
- style += '.qrcode-download-bar .slogan a {color: #fff;font-size: 16px;padding: 10px 0 0 86px;display: block;font-family: "Microsoft Yahei"!important;}';
- style += '.qrcode-download-bar .slogan a:hover {text-decoration: none;}';
- style += '.qrcode-download-bar .slogan em {color: #f5f74c;font-family: "Microsoft Yahei"!important;}';
- style += '.qrcode-download-bar .mo-download-btn {float: left;padding: 25px 0 0 0;}';
- style += '.qrcode-download-bar .mo-download-btn a{float: left;width: 197px;height: 46px;background: url('+options.imgRoot+'qr_code_download_bar.png) no-repeat 0 -116px;_background-image: url('+options.imgRoot+'qr_code_download_bar_ie6.png);text-indent: -99em;overflow:hidden;display: inline;}';
- style += '.qrcode-download-bar .mo-download-btn .bbs-android-dl:hover {background-position: 0 -70px;}';
- style += '.qrcode-download-bar .mo-download-btn .bbs-iphone-dl {background-position: 0 -180px;margin: 0 0 0 12px;}';
- style += '.qrcode-download-bar .mo-download-btn .bbs-iphone-dl:hover {background-position: 0 -92px;}';
- style += '.qrcode-download-bar .qrcode-block {float:left;}';
- style += '.qrcode-download-bar .qrcode-block .qrcode-tips{float: left;color: #fff;line-height: 15px;padding: 0 15px 0 16px;margin-top: 24px;font-family: "Microsoft Yahei"!important;}';
- style += '.qrcode-download-bar .qrcode-block .qrcode-tips a {color: #fff;line-height: 22px;}';
- style += '.qrcode-download-bar .qrcode-block .qrcode-tips a:hover {text-decoration: none;color: #fff;}';
- style += '.qrcode-download-bar .qrcode-block .qrcode-img{float: left;margin:10px 0 0 0;}';
- style += '.qrcode-download-bar .qrcode-block .qrcode-market{float: left;margin:10px 0 0 18px;width: 100px;height: 85px;background: url('+options.imgRoot+'qr_code_download_bar.png) no-repeat 0 -172px;_background-image: url('+options.imgRoot+'qr_code_download_bar_ie6.png);}';
- style += '.qrcode-download-bar .qrcode-block .qrcode-market a {display: block;height: 100%;}';
- style += '<\/style>';
- $('head').append(style);
- }
- if (options.isShowTpAD) {
- var fragment = format(
- String(function(){/*!
- <div class="top-hezi-ad" id="topHeziAd">
- <div class="top-hezi-ad-bd">
- <a href="http://shua.duowan.com/?icfa=1010#game" class="top-hezi-index" ></a>
- </div>
- <div class="top-hezi-ad-trigger" id="heziADTrigger"><embed src="#{options_swf}" width="100%" height="100%" border="0" wmode="transparent"><a href="javascript:void(0);"></a><img src="http://lol.duowan.com/s/v2/top-hezi-ad-trigger_bg.png" /></div>
- </div>
- */}).replace(/^[^\{]*\{\s*\/\*!?|\*\/[;|\s]*\}$/g, ''),
- {
- options_swf: options.swf
- }
- );
- $("body").prepend(fragment);
- var heziADTrigger = $("#heziADTrigger"),
- topHeziAd = $("#topHeziAd .top-hezi-ad-bd");
- heziADTrigger.on("click", function(event){
- event.preventDefault();
- var isOpened = heziADTrigger.data("opened");
- if(!!!isOpened){
- topHeziAd.stop().animate({height: "120px"}, 300);
- heziADTrigger
- .data("opened", true)
- .addClass('top-hezi-ad-trigger-opened')
- .animate({top: '140px'}, 300);
- }else{
- topHeziAd.stop().animate({height: 0}, 300);
- heziADTrigger
- .data("opened", false)
- .removeClass('top-hezi-ad-trigger-opened')
- .animate({top: '20px'}, 300);
- }
- });
- };
- if (options.isShowFtAD) {
- if (!$.cookie) {
- !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});
- };
- var fragment = format(
- String(function(){/*!
- <div class="qrcode-download-bar" id="qrcodeDownloadBar" style="display:none">
- <div class="qrcode-download-inner">
- <div class="slogan">
- <a href="http://m.duowan.com/?ref=DB">多玩游戏 安卓版首发!<br/>
- 大神攻略、美女囧图、解说视频 不再错过!</a>
- </div>
- <div class="mo-download-btn">
- <a href="http://szhuodong.duowan.com/s/duowanapp/apk/Duowan-DWbannercode.apk" class="bbs-android-dl" title="android lol 盒子下载">Android 下载</a>
- </div>
- <div class="qrcode-block">
- <div class="qrcode-tips"><a href="http://m.duowan.com/?ref=DB">多玩游戏安卓版<br/>点击或扫瞄下载</a></div>
- <div class="qrcode-img">
- <a href="http://bbs.duowan.com/thread-37619977-1-1.html" ><img src="#{options_imgRoot}apk_qrcode.png" alt="" /></a>
- </div>
- <div class="qrcode-market"><a href="http://m.duowan.com/?ref=DB"></a></div>
- </div>
- </div>
- <a href="javascript:void(0)" class="close">关闭</a>
- </div>
- */}).replace(/^[^\{]*\{\s*\/\*!?|\*\/[;|\s]*\}$/g, ''),
- {
- options_imgRoot: options.imgRoot
- }
- );
- $("body").prepend(fragment);
- $("#qrcodeDownloadBar .close").on("click", function(event){
- event.preventDefault();
- closeBar();
- });
- var isClose = $.cookie("qrcodeDownloadBar") ;
- if(!isClose){
- openBar();
- }
- // http://feilong.org/shortest-ie6-judge-js
- var isIE6 = !!window.ActiveXObject && !window.XMLHttpRequest;
- if (isIE6) {
- var timer = null;
- $(window).bind("scroll", function(){
- clearTimeout(timer);
- $("#qrcodeDownloadBar").hide();
- timer = setTimeout(function(){
- showBar();
- }, 200);
- });
- $(window).bind("resize", function(){
- showBar();
- });
- function showBar(){
- var isClose = $.cookie("qrcodeDownloadBar") ;
- if(!isClose){
- var top = document.documentElement.scrollTop - 92 + $(window).height();
- $("#qrcodeDownloadBar").css("top", top);
- $("#qrcodeDownloadBar").show();
- }
- }
- };
- function openBar(){
- $("#qrcodeDownloadBar").show();
- }
- function closeBar(){
- $.cookie('qrcodeDownloadBar', '1', { expires: 1, path: "/" });
- $("#qrcodeDownloadBar").hide();
- }
- };
- function format(template, json) {
- return template.replace(/#\{(.*?)\}/g, function(all, key) {
- return json && (key in json) ? json[key] : "";
- });
- }
- });
|