PageSourceSearch

https://0daybug.github.io/js/main.js

js 0daybug.github.io collected 2026-10-03 08:31:09 UTC 6,103 bytes, 152 lines download raw bytes

1require([], function (){
2
3    var isMobileInit = false;
4    var loadMobile = function(){
5        require(['/js/mobile.js'], function(mobile){
6            mobile.init();
7            isMobileInit = true;
8        });
9    }
10    var isPCInit = false;
11    var loadPC = function(){
12        require(['/js/pc.js'], function(pc){
13            pc.init();
14            isPCInit = true;
15        });
16    }
17
18    var browser={
19        versions:function(){
20        var u = window.navigator.userAgent;
21        return {
22            trident: u.indexOf('Trident') > -1, //IE内核
23            presto: u.indexOf('Presto') > -1, //opera内核
24            webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
25            gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
26            mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
27            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
28            android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
29            iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者安卓QQ浏览器
30            iPad: u.indexOf('iPad') > -1, //是否为iPad
31            webApp: u.indexOf('Safari') == -1 ,//是否为web应用程序,没有头部与底部
32            weixin: u.indexOf('MicroMessenger') == -1 //是否为微信浏览器
33            };
34        }()
35    }
36
37    $(window).bind("resize", function(){
38        if(isMobileInit && isPCInit){
39            $(window).unbind("resize");
40            return;
41        }
42        var w = $(window).width();
43        if(w >= 700){
44            loadPC();
45        }else{
46            loadMobile();
47        }
48    });
49
50    if(browser.versions.mobile === true || $(window).width() < 700){
51        loadMobile();
52    }else{
53        loadPC();
54    }
55
56    //是否使用fancybox
57    if(yiliaConfig.fancybox === true){
58        require(['/fancybox/jquery.fancybox.js'], function(pc){
59            var isFancy = $(".isFancy");
60            if(isFancy.length != 0){
61                var imgArr = $(".article-inner img");
62                for(var i=0,len=imgArr.length;i<len;i++){
63                    var src = imgArr.eq(i).attr("src");
64                    var title = imgArr.eq(i).attr("alt");
65                    imgArr.eq(i).replaceWith("<a href='"+src+"' title='"+title+"' rel='fancy-group' class='fancy-ctn fancybox'><img src='"+src+"' title='"+title+"'></a>");
66                }
67                $(".article-inner .fancy-ctn").fancybox();
68            }
69        });
70
71    }
72    //是否开启动画
73    if(yiliaConfig.animate === true){
74
75        require(['/js/jquery.lazyload.js'], function(){
76            //avatar
77            $(".js-avatar").attr("src", $(".js-avatar").attr("lazy-src"));
78            $(".js-avatar")[0].onload = function(){
79                $(".js-avatar").addClass("show");
80            }
81        });
82
83      if(yiliaConfig.isHome === true) {
84        // 滚动条监听使用scrollreveal.js
85        // https://github.com/jlmakes/scrollreveal.js
86        // 使用cdn[//cdn.bootcss.com/scrollReveal.js/3.0.5/scrollreveal.js]
87        require([
88          '//cdn.bootcss.com/scrollReveal.js/3.0.5/scrollreveal.js'
89        ], function (ScrollReveal) {
90          // 更多animation:
91          // http://daneden.github.io/animate.css/
92          var animationNames = [
93            "pulse", "fadeIn","fadeInRight", "flipInX", "lightSpeedIn","rotateInUpLeft", "slideInUp","zoomIn",
94            ],
95            len = animationNames.length,
96            randomAnimationName = animationNames[Math.ceil(Math.random() * len) - 1];
97
98          // ie9 不支持css3 keyframe动画, safari不支持requestAnimationFrame, 不使用随机动画,切回原来的动画
99          if (!window.requestAnimationFrame) {
100              $('.body-wrap > article').css({opacity: 1});
101
102              if (navigator.userAgent.match(/Safari/i)) {
103                  function showArticle(){
104                      $(".article").each(function(){
105                          if( $(this).offset().top <= $(window).scrollTop()+$(window).height() && !($(this).hasClass('show')) ) {
106                              $(this).removeClass("hidden").addClass("show");
107                              $(this).addClass("is-hiddened");
108                          }else{
109                              if(!$(this).hasClass("is-hiddened")){
110                                  $(this).addClass("hidden");
111                              }
112                          }
113                      });
114                  }
115                  $(window).on('scroll', function(){
116                      showArticle();
117                  });
118                  showArticle();
119              }
120              return;
121          }
122          // document.body有些浏览器不支持监听scroll,所以使用默认的document.documentElement
123          ScrollReveal({
124            duration: 0,
125            afterReveal: function (domEl) {
126              // safari不支持requestAnimationFrame不支持document.documentElement的onscroll所以这里不会执行
127              // 初始状态设为opacity: 0, 动画效果更平滑一些(由于脚本加载是异步,页面元素渲染后在执行动画,感觉像是延时)
128              $(domEl).addClass('animated ' + randomAnimationName).css({opacity: 1});
129            }
130          }).reveal('.body-wrap > article');
131
132        });
133      } else {
134        $('.body-wrap > article').css({opacity: 1});
135      }
136
137    }
138
139    //是否新窗口打开链接
140    if(yiliaConfig.open_in_new == true){
141        $(".article a[href]").attr("target", "_blank")
142    }
143    $(".archive-article-title, .github-widget a").attr("target", "_blank");
144
145    //随机颜色
146    var colorList = ["#6da336", "#ff945c", "#66CC66", "#99CC99", "#CC6666", "#76becc", "#c99979", "#918597", "#4d4d4d"];
147    var id = Math.ceil(Math.random()*(colorList.length-1));
148    //PC
149    $("#container .left-col .overlay").css({"background-color": colorList[id],"opacity": .3});
150    //移动端
151    $("#container #mobile-nav .overlay").css({"background-color": colorList[id],"opacity": .7});
152});

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.