1$(function () { 2 let timer 3 $(window).on('scroll', function () { 4 const scrollTop = $(window).scrollTop() 5 const backTopDom = $('.back-top') 6 headerFixed() 7 //ç嬿å 载渲æ 8 timer && clearTimeout(timer) 9 timer = setTimeout(function () { 10 lazyRender() 11 }, 300) 12 13 //çå¬è¿å顶鍿¾ç¤º/éè 14 scrollTop >= 100 ? backTopDom.addClass('show') : backTopDom.removeClass('show') 15 }) 16 17 //导èªé«äº® 18 highLight(); 19 20 //æå è½½ 21 const bannerDom = $('.banner') 22 bannerDom.css('background-image', 'url("' + bannerDom.attr('data-src') + '")') 23 lazyRender() 24 25 //ç§»å¨ç«¯ä¾§æ æ¾ç¤º/éè 26 $('.nav-bar').on('click', function () { 27 if ($(this).hasClass('active')) { 28 $(this).removeClass('active') 29 $('.nav').removeClass('show') 30 $('.transparent-mark').remove() 31 } else { 32 $(this).addClass('active') 33 $('.nav').addClass('show') 34 $('.header').append('<div class="transparent-mark"></div>') 35 } 36 }) 37 38 //ç¹å»é®ç½©å±éè 39 $(document).on('click', '.transparent-mark', function () { 40 $('.nav-bar').removeClass('active') 41 $('.nav').removeClass('show') 42 $('.transparent-mark').remove() 43 }) 44 45 //忢æç´¢æ¹å¼ 46 const searchInputDom = $('.search-input'), 47 searchFormDom = $('.search-form'), 48 searchBtnDom = $('.search-btn') 49 searchInputDom.focus() 50 $('.search-type .item').on('click', function () { 51 $('.search-type .item').removeClass('active') 52 $(this).addClass('active') 53 searchInputDom.focus() 54 searchFormDom.attr('target', '_blank') 55 switch ($(this).attr('data-type')) { 56 case 'this': 57 searchFormDom.attr('action', '../').attr('target', '_self') 58 searchInputDom.attr('name', 'keyword') 59 searchBtnDom.text('æ¬ç«æç´¢') 60 break 61 case 'baidu': 62 searchFormDom.attr('action', 'https://www.baidu.com/s?tn=none') 63 searchInputDom.attr('name', 'wd') 64 searchBtnDom.text('ç¾åº¦ä¸ä¸') 65 break 66 case 'sogou': 67 searchFormDom.attr('action', 'https://www.sogou.com/sogou?pid=none') 68 searchInputDom.attr('name', 'query') 69 searchBtnDom.text('æçæç´¢'); 70 break 71 case '360': 72 searchFormDom.attr('action', 'https://www.so.com/s?ls=none') 73 searchInputDom.attr('name', 'q') 74 searchBtnDom.text('360æç´¢') 75 break 76 case 'bing': 77 searchFormDom.attr('action', 'https://cn.bing.com/search?from=none') 78 searchInputDom.attr('name', 'q') 79 searchBtnDom.text('å¿ åºæç´¢') 80 break 81 } 82 }) 83 84 //ç¹å»åç±»æ»å¨ 85 $('.sort .move').on('click', function (e) { 86 e.preventDefault() 87 const href = $(this).attr('href'), 88 pos = $(href).offset().top - ($(window).width() <= 767 ? 52 : 62) 89 $('html').animate({ 90 scrollTop: pos 91 }, 500) 92 }) 93 94}) 95headerFixed(); 96//导èªé«äº® 97function highLight() { 98 const urlStr = location.href 99 $('.nav > li > a').each(function () { 100 const href = $(this).attr('href') 101 if (urlStr === href && href !== '') { 102 $(this).parent('li').addClass('active') 103 } else { 104 $(this).parent('li').removeClass('active') 105 } 106 }) 107} 108function headerFixed() { 109 const headerDom = $('.header') 110 if (headerDom.next('.banner').length === 0) { 111 return 112 } 113 $(window).scrollTop() > 0 ? headerDom.addClass('fixed') : headerDom.removeClass('fixed') 114} 115//æå è½½ 116function lazyRender() { 117 $('.lazy-load').each(function () { 118 const scrollTop = $(window).scrollTop(), 119 windowHeight = $(window).height(), 120 offsetTop = $(this).offset().top 121 if (offsetTop < (scrollTop + windowHeight) && offsetTop > scrollTop && $(this).attr('data-src') !== $(this).attr('src')) { 122 $(this).animate({opacity: 'toggle'}, 300, function () { 123 $(this).attr('src', $(this).attr('data-src')) 124 $(this).animate({opacity: 'toggle'}, 300) 125 }) 126 } 127 }) 128} 129 130//è¿åé¡¶é¨ 131function backTop() { 132 $('html,body').animate({ 133 scrollTop: '0' 134 }, 500) 135} 136// ç¹èµæé®ç¹å» 137$('#agree-btn').on('click', function () { 138 $('#agree-btn').get(0).disabled = true; // ç¦ç¨ç¹èµæé® 139 // åé AJAX è¯·æ± 140 $.ajax({ 141 // è¯·æ±æ¹å¼ post 142 type: 'POST', 143 // url è·åç¹èµæé®çèªå®ä¹ url 屿§ 144 url: $('#agree-btn').attr('data-url'), 145 // åéçæ°æ® cidï¼ç´æ¥è·åç¹èµæé®ç cid 屿§ 146 data: 'agree=' + $('#agree-btn').attr('data-cid'), 147 148 // è¯·æ±æåç彿° 149 success: function (data) { 150 var re = /\d/; // å¹é æ°åçæ£åè¡¨è¾¾å¼ 151 // å¹é æ°å 152 if (re.test(data)) { 153 // æç¹èµæé®ä¸çç¹èµæ°éè®¾ç½®ä¸ºä¼ åçç¹èµæ°é 154 $('#agree-btn .agree-num').html(data.substr(data.length-1,1)); 155 $('#agree-btn .agree-text').html('å·²èµ'); 156 } 157 }, 158 error: function () { 159 // å¦æè¯·æ±åºéå°±æ¢å¤ç¹èµæé® 160 $('#agree-btn').get(0).disabled = false;
161 }, 162 }); 163});
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.