/*! * 版本:myui copyright © 2020 * 官网:https://www.uzhanw.com */ var mytheme = { 'browser': { url: document.url, domain: document.domain, title: document.title, language: (navigator.browserlanguage || navigator.language).tolowercase(), canvas: function() { return !!document.createelement("canvas").getcontext }(), useragent: function() { var a = navigator.useragent; return { mobile: !! a.match(/applewebkit.*mobile.*/), ios: !! a.match(/\(i[^;]+;( u;)? cpu.+mac os x/), android: -1 < a.indexof("android") || -1 < a.indexof("linux"), iphone: -1 < a.indexof("iphone") || -1 < a.indexof("mac"), ipad: -1 < a.indexof("ipad"), trident: -1 < a.indexof("trident"), presto: -1 < a.indexof("presto"), webkit: -1 < a.indexof("applewebkit"), gecko: -1 < a.indexof("gecko") && -1 == a.indexof("khtml"), weixin: -1 < a.indexof("micromessenger") } }() }, 'cookie': { 'set':function(name,value,days){ var expires; if (days) { expires = days; } else{ expires = ""; } $.cookie(name,value,{expires:expires,path:'/'}); }, 'get':function(name){ var styles = $.cookie(name); return styles; }, 'del':function(name,tips){ if(window.confirm(tips)){ $.cookie(name,null,{expires:-1,path: '/'}); location.reload(); }else{ return false; } } }, 'ajax':function(url,type,datatype,data,sfun,efun,cfun){ type=type||'get'; datatype=datatype||'json'; data=data||''; efun=efun||''; cfun=cfun||''; $.ajax({ url:url, type:type, datatype:datatype, data:data, timeout: 5000, beforesend:function(xhr){ }, error:function(xhr,textstatus,errorthrown){ if(efun) efun(xhr,textstatus,errorthrown); }, success:function(data){ sfun(data); }, complete:function(xhr, ts){ if(cfun) cfun(xhr, ts); } }) }, 'mobile': { 'nav': { 'init': function() { if($(".nav-slide").length){ $(".nav-slide").each(function(){ var $that = $(this); mytheme.mobile.nav.set($that,$that.attr('data-align')); }); } }, 'set': function(id,align) { $index = id.find('.active').index()*1; if($index > 3){ $index = $index-3; }else{ $index = 0; } id.flickity({ cellalign: align, freescroll: true, contain: true, prevnextbuttons: false, pagedots: false, percentposition: true, initialindex: $index }); } }, 'mshare': function() { $(".open-share").click(function() { mytheme.browser.useragent.weixin ? $("body").append('
') : $("body").append('
'); $(".mobile-share").click(function() { $(".mobile-share").remove(); $("body").removeclass("modal-open"); }); }); } }, 'images': { 'lazyload': function() { $(".lazyload").lazyload({ effect: "fadein", threshold: 200, failure_limit : 1, skip_invisible : false, }); }, 'qrcode': { 'init': function() { if($("#qrcode").length){ var $that = $("#qrcode"); mytheme.images.qrcode.set($that.attr('data-link'),$that.attr('data-dark'),$that.attr('data-light')); $that.attr("class","img-responsive"); } }, 'set': function(url,dark,light) { url=0||location.href; var qrcode = new qrcode('qrcode', { text: url, width: 120, height: 120, colordark : dark, colorlight : light, correctlevel : qrcode.correctlevel.h }); } }, 'flickity': { 'init': function() { if($(".flickity").length){ $(".flickity").each(function(){ var $that = $(this); mytheme.images.flickity.set($that,$that.attr('data-align'),$that.attr('data-dots'),$that.attr('data-next')); }); } }, 'set': function(id,align,dots,next) { dots=dots||false; next=next||false; id.flickity({ cellalign: align, wraparound: true, contain: true, pagedots: dots, percentposition: true, prevnextbuttons: next }); } } }, 'link': { 'copy': function(){ if($(".copy-link").length){ var clipboard = new clipboard('.copy-link', { text: function() { return $(".my-link").html(); } }); clipboard.on('success', function(e) { layer.msg('链接复制成功'); }); clipboard.on("error",function(e){ layer.msg('复制失败,请手动复制'); }); } }, 'short': function(){ if($(".short").length){ var shortid = $(".short"); var shorturl = shortid.attr("href"); $.ajax({ type : 'get', url : myui.shortapi+encodeuricomponent(shorturl), datatype : 'json', success : function(data) { url_short = data.urls[0].url_short; shortid.html(url_short); } }); } } }, 'layer': { 'img': function(title,src,text) { layer.open({ type: 1, title: title, skin: 'layui-layer-rim', content: '

'+text+'

' }); }, 'html': function(title,html) { layer.open({ type: 1, title: title, skin: 'layui-layer-rim', content: '
'+html+'
' }); }, 'div': function(id) { layer.open({ type: 1, title:false, skin: 'layui-layer-rim', content: $(id) }); }, 'popbody': function(name,title,html,day,wide,high) { var pop_is = mytheme.cookie.get(name); var html = $(html).html(); if(!pop_is){ layer.open({ type: 1, title: title, skin: 'layui-layer-rim', content: html, area: [wide+'px', high+'px'], cancel: function(){ mytheme.cookie.set(name,1,day); } }); } } }, 'other': { 'headroom': function() { if($("#header-top").length){ var header = document.queryselector("#header-top"); var headroom = new headroom(header, { tolerance: 5, offset: 205, classes: { initial: "top-fixed", pinned: "top-fixed-up", unpinned: "top-fixed-down" } }); headroom.init(); } $(".dropdown-hover").click(function(){ $(this).find(".dropdown-box").toggle(); }); }, 'popup': function(id) { $(id).addclass("popup-visible"); $("body").append('
').addclass("hidden"); $(".close-popup").click(function() { $(id).removeclass("popup-visible"); $(".mask").remove(); $("body").removeclass("hidden"); }); $(".mask").click(function() { $(id).removeclass("popup-visible"); $(this).remove(); $("body").removeclass("hidden"); }); }, 'bootstrap': function() { $('a[data-toggle="tab"]').on("shown.bs.tab", function(a) { var b = $(a.target).text(); $(a.relatedtarget).text(); $("span.active-tab").html(b); }); }, 'skin': function() { var skinnum = 0,act; var lengths = $("link[name='skin']").length; $('.btnskin').click(function() { skinnum+=1; if(skinnum==lengths){skinnum=0;} var skin = $("link[name='skin']").eq(skinnum).attr("href"); layer.msg("正在切换皮肤,请稍后...",{anim:5,time: 2000},function(){ $("link[name='default']").attr({href:skin}); }); mytheme.cookie.set('skincolor',skin,365); }); var color = mytheme.cookie.get('skincolor'); if(color){ $("link[name='default']").attr({href:color}); } }, 'sort': function() { $(".sort-button").each(function(){ $(this).on("click",function(e){ e.preventdefault(); $(this).parent().parent().parent().find(".sort-list").each(function(){ var playlist=$(this).find("li"); for(let i=0,j=playlist.length-1;i'); }else{ display.slidedown("slow"); $(this).html('收起 '); } }); }, 'history': { 'init':function(){ if($(".vod_history").length){ var $that = $(".vod_history"); mytheme.other.history.set($that.attr('data-name'),$that.attr('data-link'),$that.attr('data-pic'),$that.attr('data-part'),$that.attr('data-limit')); } }, 'set':function(name,link,pic,part,limit){ if(!link){ link = document.url;} var history = mytheme.cookie.get("history"); var len=0; var canadd=true; if(history){ history = eval("("+history+")"); len=history.length; $(history).each(function(){ if(name==this.name){ canadd=false; var json="["; $(history).each(function(i){ var temp_name,temp_img,temp_url,temp_part; if(this.name==name){ temp_name=name;temp_img=pic;temp_url=link;temp_part=part; }else{ temp_name=this.name;temp_img=this.pic;temp_url=this.link;temp_part=this.part; } json+="{\"name\":\""+temp_name+"\",\"pic\":\""+temp_img+"\",\"link\":\""+temp_url+"\",\"part\":\""+temp_part+"\"}"; if(i!=len-1) json+=","; }) json+="]"; mytheme.cookie.set('history',json,365); return false; } }); } if(canadd){ var json="["; var start=0; var isfirst="]"; isfirst=!len?"]":","; json+="{\"name\":\""+name+"\",\"pic\":\""+pic+"\",\"link\":\""+link+"\",\"part\":\""+part+"\"}"+isfirst; if(len>limit-1) len-=1; for(i=0;i0){ json+="{\"name\":\""+history[len-1].name+"\",\"pic\":\""+history[len-1].pic+"\",\"link\":\""+history[len-1].link+"\",\"part\":\""+history[len-1].part+"\"}]"; } mytheme.cookie.set('history',json,365); } } }, 'player': function() { if($("#player-left").length){ var playerleft = $("#player-left"); var playerside = $("#player-sidebar"); var leftheight = playerleft.outerheight(); var position = $("#playlist li.active").position().top; $("#player-sidebar-is").click(function() { playerside.toggle(); if(playerside.css("display")==='none') { playerleft.css("width","100%"); $(this).html(""); } if(playerside.css("display")==='block') { playerleft.css("width",""); $(this).html(""); } }); if(!mytheme.browser.useragent.mobile){ playerside.css({"height":leftheight,"overflow":"auto"}); playerside.scrolltop(position); if($(".player-fixed").length){ $(window).scroll(function(){ if($(window).scrolltop()>window.outerheight){ $(".player-fixed").addclass("fixed fadeindown"); $(".player-fixed-off").show(); }else if($(window).scrolltop()