PageSourceSearch

https://www.92kdh.com/usr/themes/AutoAdd/js/main.js

js 92kdh.com collected 2026-10-09 03:21:12 UTC 4,941 bytes, 163 lines download raw bytes

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.