PageSourceSearch

https://noshore.github.io/js/main.js

js noshore.github.io collected 2026-10-03 09:41:44 UTC 23,661 bytes, 781 lines download raw bytes

1$(function () {
2  const isSnackbar = GLOBAL_CONFIG.Snackbar !== undefined
3  const $pageHead = $('#page-header')
4  const $rightside = $('#rightside')
5  const $body = $('body')
6
7  /**
8   * 當menu過多時,自動適配,避免UI錯亂
9    * 傳入 1 sidebar打開時
10   * 傳入 2 正常狀態下
11   */
12  var blogNameWidth = $('#blog_name').width()
13  var menusWidth = $('.menus').width()
14  var sidebarWidth = $('#sidebar').width()
15
16  function isAdjust (n) {
17    var t
18    if (n === 1) {
19      t = blogNameWidth + menusWidth > $pageHead.width() - sidebarWidth - 20
20    } else if (n === 2) {
21      t = blogNameWidth + menusWidth > $pageHead.width() - 20
22    }
23
24    if (t) headerAdjust()
25    else headerAdjustBack()
26  }
27
28  function headerAdjust () {
29    $pageHead.find('.toggle-menu').addClass('is-visible-inline')
30    $pageHead.find('.menus_items').addClass('is_invisible')
31    $pageHead.find('#search_button span').addClass('is_invisible')
32  }
33
34  function headerAdjustBack () {
35    $pageHead.find('.toggle-menu').removeClass('is-visible-inline')
36    $pageHead.find('.menus_items').removeClass('is_invisible')
37    $pageHead.find('#search_button span').removeClass('is_invisible')
38  }
39
40  // 初始化header
41  function initAjust () {
42    if (window.innerWidth < 768) headerAdjust()
43    else isAdjust(2)
44  }
45
46  initAjust()
47  $('#page-header').css({ opacity: '1', animation: 'headerNoOpacity 1s' })
48
49  $(window).on('resize', function () {
50    if ($('#sidebar').hasClass('tocOpenPc') && $pageHead.hasClass('fixed')) {
51      isAdjust(1)
52    } else {
53      initAjust()
54    }
55  })
56
57  /**
58   * windows時 設置主頁top_img 為 fixed
59   */
60  if (GLOBAL_CONFIG_SITE.isHome) {
61    var isSafari = /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)
62    if (!isSafari && isDesktop()) {
63      $('#nav').css('background-attachment', 'fixed')
64    }
65  }
66
67  /**
68   * 進入post頁sidebar處理
69   */
70  if (GLOBAL_CONFIG_SITE.isPost) {
71    if (window.innerWidth > 1024 && $('#toggle-sidebar').hasClass('on')) {
72      setTimeout(function () {
73        openSidebar()
74      }, 400)
75    }
76  }
77
78  /**
79   * 點擊左下角箭頭,顯示sidebar
80   */
81
82  function closeSidebar () {
83    $('#sidebar').removeClass('tocOpenPc')
84    $('.menus').animate({
85      paddingRight: 0
86    }, 400)
87    $('#body-wrap').animate({
88      paddingLeft: 0
89    }, 400)
90    $('#sidebar').animate({
91      left: '-300px'
92    }, 400)
93    $('#toggle-sidebar').css({
94      transform: 'rotateZ(0deg)',
95      color: '#1F2D3D',
96      opacity: '1'
97    })
98    setTimeout(function () {
99      isAdjust(2)
100    }, 400)
101  }
102
103  function openSidebar () {
104    $('#sidebar').addClass('tocOpenPc')
105    $('.menus').animate({
106      paddingRight: 300
107    }, 400)
108    $('#body-wrap').animate({
109      paddingLeft: 300
110    }, 400)
111    $('#sidebar').animate({
112      left: 0
113    }, 400)
114    $('#toggle-sidebar').css({
115      transform: 'rotateZ(180deg)',
116      color: '#99a9bf',
117      opacity: '1'
118    })
119    var isAdjustTimeCount = window.setInterval(function () {
120      if ($pageHead.hasClass('fixed')) isAdjust(1)
121      else isAdjust(2)
122    }, 100)
123    setTimeout(function () {
124      clearInterval(isAdjustTimeCount)
125    }, 400)
126  }
127
128  $('#toggle-sidebar').on('click', function () {
129    var isOpen = $(this).hasClass('on')
130    isOpen ? $(this).removeClass('on') : $(this).addClass('on')
131    if (isOpen) {
132      closeSidebar()
133    } else {
134      openSidebar()
135    }
136  })
137
138  /**
139   * 手機menu和toc按鈕點擊
140   * 顯示menu和toc的sidebar
141   */
142
143  var $toggleMenu = $('.toggle-menu')
144  var $mobileSidevarMenus = $('#mobile-sidebar-menus')
145  var $mobileTocButton = $('#mobile-toc-button')
146  var $menuMask = $('#menu_mask')
147
148  function openMobileSidebar (name) {
149    sidebarPaddingR()
150    $('body').css('overflow', 'hidden')
151    $menuMask.fadeIn()
152
153    if (name === 'menu') {
154      $toggleMenu.removeClass('close').addClass('open')
155      $mobileSidevarMenus.css('transform', 'translate3d(-100%,0,0)')
156      var $mobileSidevarMenusChild = $mobileSidevarMenus.children()
157      for (let i = 0; i <= $mobileSidevarMenusChild.length; i++) {
158        const duration = i / 5 + 0.2
159        $mobileSidevarMenusChild.eq(i).css('animation', 'sidebarItem ' + duration + 's')
160      }
161    }
162
163    if (name === 'toc') {
164      $mobileTocButton.removeClass('close').addClass('open')
165      $('#sidebar').addClass('tocOpenMobile')
166      $('#sidebar').css({ transform: 'translate3d(-100%,0,0)', left: '' })
167    }
168  }
169
170  function closeMobileSidebar (name) {
171    $('body').css({ overflow: '', 'padding-right': '' })
172    $menuMask.fadeOut()
173
174    if (name === 'menu') {
175      $toggleMenu.removeClass('open').addClass('close')
176      $mobileSidevarMenus.css('transform', '')
177      $('#mobile-sidebar-menus > div,#mobile-sidebar-menus > hr').css('animation', '')
178    }
179
180    if (name === 'toc') {
181      $mobileTocButton.removeClass('open').addClass('close')
182      $('#sidebar').removeClass('tocOpenMobile')
183      $('#sidebar').css({ transform: '' })
184    }
185  }
186
187  $toggleMenu.on('click', function () {
188    openMobileSidebar('menu')
189  })
190
191  $mobileTocButton.on('click', function () {
192    openMobileSidebar('toc')
193  })
194
195  $menuMask.on('click touchstart', function (e) {
196    if ($toggleMenu.hasClass('open')) {
197      closeMobileSidebar('menu')
198    }
199    if ($mobileTocButton.hasClass('open')) {
200      closeMobileSidebar('toc')
201    }
202  })
203
204  $(window).on('resize', function (e) {
205    if (!$toggleMenu.is(':visible')) {
206      if ($toggleMenu.hasClass('open')) closeMobileSidebar('menu')
207    }
208  })
209
210  const mql = window.matchMedia('(max-width: 1024px)')
211  mql.addListener(function (ev) {
212    if (ev.matches) {
213      if ($('#sidebar').hasClass('tocOpenPc')) closeSidebar()
214    } else {
215      if ($('#toggle-sidebar').hasClass('on')) openSidebar()
216      if ($mobileTocButton.hasClass('open')) closeMobileSidebar('toc')
217    }
218  })
219
220  /**
221   * 首頁top_img底下的箭頭
222   */
223  $('#scroll_down').on('click', function () {
224    scrollTo('#content-inner')
225  })
226
227  /**
228   * BOOKMARK 書簽
229   */
230  $('#bookmark-it').on('click', function () {
231    if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark
232      window.sidebar.addPanel(document.title, window.location.href, '')
233    } else if (window.external && ('AddFavorite' in window.external)) { // IE Favorite
234      window.external.AddFavorite(location.href, document.title)
235    } else if (window.opera && window.print) { // Opera Hotlist
236      this.title = document.title
237      return true
238    } else { // webkit - safari/chrome
239      if (isSnackbar) {
240        var bookmarkText = GLOBAL_CONFIG.Snackbar.bookmark.message_prev + ' ' + (navigator.userAgent.toLowerCase().indexOf('mac') !== -1 ? 'Command/Cmd' : 'CTRL') + '+ D ' + GLOBAL_CONFIG.Snackbar.bookmark.message_next + '.'
241        snackbarShow(bookmarkText)
242      } else {
243        alert(GLOBAL_CONFIG.bookmark.message_prev + ' ' + (navigator.userAgent.toLowerCase().indexOf('mac') !== -1 ? 'Command/Cmd' : 'CTRL') + '+ D ' + GLOBAL_CONFIG.bookmark.message_next + '.')
244      }
245    }
246  })
247
248  /**
249   * 代碼
250   * 只適用於Hexo默認的代碼渲染
251   */
252  const $figureHighlight = $('figure.highlight')
253
254  if ($figureHighlight.length) {
255    const isHighlightCopy = GLOBAL_CONFIG.highlightCopy
256    const isHighlightLang = GLOBAL_CONFIG.highlightLang
257    const isHighlightShrink = GLOBAL_CONFIG.highlightShrink
258
259    if (isHighlightCopy || isHighlightLang || isHighlightShrink !== 'none') {
260      $figureHighlight.wrap('<div class="code-area-wrap"></div>').before('<div class="highlight-tools"></div>')
261    }
262
263    /**
264   * 代碼收縮
265   */
266    const $highlightTools = $('.highlight-tools')
267    if (isHighlightShrink === 'true') {
268      $highlightTools.append('<i class="fa fa-angle-down code-expand code-closed" aria-hidden="true"></i>')
269    } else if (isHighlightShrink === 'false') {
270      $highlightTools.append('<i class="fa fa-angle-down code-expand" aria-hidden="true"></i>')
271    }
272
273    $(document).on('click', '.highlight-tools >.code-expand', function () {
274      var $table = $(this).parent().next()
275      if ($(this).hasClass('code-closed')) {
276        $table.css('display', 'block')
277        $(this).removeClass('code-closed')
278      } else {
279        $table.css('display', 'none')
280        $(this).addClass('code-closed')
281      }
282    })
283
284    /**
285    * 代碼語言
286  */
287    if (isHighlightLang) {
288      var langNameIndex, langName
289      $figureHighlight.each(function () {
290        langNameIndex = langName = $(this).attr('class').split(' ')[1]
291        if (langNameIndex === 'plain') langName = 'Code'
292        $(this).prev().append('<div class="code-lang">' + langName + '</div>')
293      })
294    }
295    /**
296   * 代碼copy
297   * copy function
298   */
299    if (isHighlightCopy) {
300      $highlightTools.append('<div class="copy-notice"></div><i class="fa fa-clipboard" aria-hidden="true"></i>')
301      var copy = function (text, ctx) {
302        if (document.queryCommandSupported && document.queryCommandSupported('copy')) {
303          try {
304            document.execCommand('copy') // Security exception may be thrown by some browsers.
305            if (isSnackbar) {
306              snackbarShow(GLOBAL_CONFIG.copy.success)
307            } else {
308              $(ctx).prev('.copy-notice')
309                .text(GLOBAL_CONFIG.copy.success)
310                .animate({
311                  opacity: 1,
312                  right: 30
313                }, 450, function () {
314                  setTimeout(function () {
315                    $(ctx).prev('.copy-notice').animate({
316                      opacity: 0,
317                      right: 0
318                    }, 650)
319                  }, 400)
320                })
321            }
322          } catch (ex) {
323            if (isSnackbar) {
324              snackbarShow(GLOBAL_CONFIG.copy.success)
325            } else {
326              $(ctx).prev('.copy-notice')
327                .text(GLOBAL_CONFIG.copy.error)
328                .animate({
329                  opacity: 1,
330                  right: 30
331                }, 650, function () {
332                  setTimeout(function () {
333                    $(ctx).prev('.copy-notice').animate({
334                      opacity: 0,
335                      right: 0
336                    }, 650)
337                  }, 400)
338                })
339              return false
340            }
341          }
342        } else {
343          if (isSnackbar) {
344            snackbarShow(GLOBAL_CONFIG.copy.noSupport)
345          } else {
346            $(ctx).prev('.copy-notice').text(GLOBAL_CONFIG.copy.noSupport)
347          }
348        }
349      }
350
351      // click events
352      $(document).on('click', '.highlight-tools>.fa-clipboard', function () {
353        var selection = window.getSelection()
354        var range = document.createRange()
355        range.selectNodeContents($(this).parent().next().find('.code pre')[0])
356        selection.removeAllRanges()
357        selection.addRange(range)
358        var text = selection.toString()
359        copy(text, this)
360        selection.removeAllRanges()
361      })
362    }
363  }
364
365  /**
366 * PhotoFigcaption
367 */
368  function addPhotoFigcaption () {
369    var images = $('#article-container img')
370    images.each(function (i, o) {
371      var $this = $(o)
372      if ($this.attr('alt')) {
373        var t = $('<div class="img-alt is-center">' + $this.attr('alt') + '</div>')
374        $this.after(t)
375      }
376    })
377  }
378  if (GLOBAL_CONFIG.isPhotoFigcaption) addPhotoFigcaption()
379
380  /**
381   * justified-gallery 圖庫排版
382   */
383  var $justifiedGallery = $('.justified-gallery')
384  var isJustifiedGallery = false
385  if ($justifiedGallery.length) {
386    isJustifiedGallery = true
387    var $imgList = $justifiedGallery.find('img')
388    $imgList.unwrap()
389    if ($imgList.length) {
390      $imgList.each(function (i, o) {
391        if ($(o).attr('data-src')) $(o).attr('src', $(o).attr('data-src'))
392        $(o).wrap('<div></div>')
393      })
394    }
395    $('head').append('<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css">')
396    loadScript('https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js', function () {
397      initJustifiedGallery($justifiedGallery)
398    })
399
400    var initJustifiedGallery = function (selector) {
401      selector.each(function (i, o) {
402        if ($(this).is(':visible')) {
403          $(this).justifiedGallery({
404            rowHeight: 220,
405            margins: 4
406          })
407        }
408      })
409    }
410  }
411
412  /**
413   * fancybox和 mediumZoom
414   */
415
416  var isMediumZoom = GLOBAL_CONFIG.medium_zoom
417  var isFancybox = GLOBAL_CONFIG.fancybox
418  if (isFancybox) {
419    var images = $('#article-container img:not(.gallery-group-img)').not($('a>img'))
420    images.each(function (i, o) {
421      var lazyloadSrc = $(o).attr('data-src') ? $(o).attr('data-src') : $(o).attr('src')
422      $(o).wrap(
423        '<a href="' +
424        lazyloadSrc +
425        '" data-fancybox="group" data-caption="' +
426        $(o).attr('alt') +
427        '" class="fancybox"></a>'
428      )
429    })
430
431    $().fancybox({
432      selector: '[data-fancybox]',
433      loop: true,
434      transitionEffect: 'slide',
435      protect: true,
436      buttons: ['slideShow', 'fullScreen', 'thumbs', 'close']
437    })
438  } else if (isMediumZoom) {
439    const zoom = mediumZoom(document.querySelectorAll('#article-container :not(a)>img'))
440    zoom.on('open', function (event) {
441      var photoBg = $(document.documentElement).attr('data-theme') === 'dark' ? '#121212' : '#fff'
442      zoom.update({
443        background: photoBg
444      })
445    })
446  }
447
448  /**
449   * lazyload
450   */
451  if (GLOBAL_CONFIG.islazyload) {
452    window.lozad('img').observe()
453  }
454
455  /**
456   * 滾動處理
457   */
458  var initTop = 0
459  $(window).scroll(function (event) {
460    var currentTop = $(this).scrollTop()
461    var isUp = scrollDirection(currentTop)
462    if (currentTop > 56) {
463      if (isUp) {
464        if ($pageHead.hasClass('visible')) $pageHead.removeClass('visible')
465      } else {
466        if (!$pageHead.hasClass('visible')) $pageHead.addClass('visible')
467      }
468      $pageHead.addClass('fixed')
469      if ($rightside.css('opacity') === '0') {
470        $rightside.css({ opacity: '1', transform: 'translateX(-38px)' })
471      }
472    } else {
473      if (currentTop === 0) {
474        $pageHead.removeClass('fixed').removeClass('visible')
475      }
476      $rightside.css({ opacity: '', transform: '' })
477    }
478  })
479
480  // find the scroll direction
481  function scrollDirection (currentTop) {
482    var result = currentTop > initTop // true is down & false is up
483    initTop = currentTop
484    return result
485  }
486
487  /**
488   * 點擊滾回頂部
489   */
490  $('#go-up').on('click', function () {
491    scrollTo('body')
492  })
493
494  /**
495   *  toc
496   */
497
498  if (GLOBAL_CONFIG_SITE.isPost && GLOBAL_CONFIG_SITE.isSidebar) {
499    $('.toc-child').hide()
500
501    // main of scroll
502    $(window).scroll(throttle(function (event) {
503      var currentTop = $(this).scrollTop()
504      scrollPercent(currentTop)
505      findHeadPosition(currentTop)
506      autoScrollToc(currentTop)
507    }, 100))
508
509    // scroll
510    $('.toc-link').on('click', function (e) {
511      if (window.innerWidth <= 1024) {
512        closeMobileSidebar('toc')
513      } else {
514        e.preventDefault()
515        scrollTo($(this).attr('href'))
516      }
517    })
518
519    // expand toc-item
520    var expandToc = function ($item) {
521      if ($item.is(':visible')) {
522        return
523      }
524      $item.fadeIn(400)
525    }
526
527    var scrollPercent = function (currentTop) {
528      var docHeight = $('#article-container').height()
529      var winHeight = $(window).height()
530      var contentMath = (docHeight > winHeight) ? (docHeight - winHeight) : ($(document).height() - winHeight)
531      var scrollPercent = (currentTop) / (contentMath)
532      var scrollPercentRounded = Math.round(scrollPercent * 100)
533      var percentage = (scrollPercentRounded > 100) ? 100
534        : (scrollPercentRounded <= 0) ? 0
535          : scrollPercentRounded
536      $('.progress-num').text(percentage)
537      $('.sidebar-toc__progress-bar').animate({
538        width: percentage + '%'
539      }, 100)
540    }
541
542    // anchor
543    var isanchor = GLOBAL_CONFIG.isanchor
544    var updateAnchor = function (anchor) {
545      if (window.history.replaceState && anchor !== window.location.hash) {
546        window.history.replaceState(undefined, undefined, anchor)
547      }
548    }
549
550    // find head position & add active class
551    // DOM Hierarchy:
552    // ol.toc > (li.toc-item, ...)
553    // li.toc-item > (a.toc-link, ol.toc-child > (li.toc-item, ...))
554    var findHeadPosition = function (top) {
555    // assume that we are not in the post page if no TOC link be found,
556    // thus no need to update the status
557      if ($('.toc-link').length === 0) {
558        return false
559      }
560
561      var list = $('#article-container').find('h1,h2,h3,h4,h5,h6')
562      var currentId = ''
563      list.each(function () {
564        var head = $(this)
565        if (top > head.offset().top - 25) {
566          currentId = '#' + $(this).attr('id')
567        }
568      })
569
570      if (currentId === '') {
571        $('.toc-link').removeClass('active')
572        $('.toc-child').hide()
573      }
574
575      var currentActive = $('.toc-link.active')
576      if (currentId && currentActive.attr('href') !== currentId) {
577        if (isanchor) updateAnchor(currentId)
578
579        $('.toc-link').removeClass('active')
580
581        var _this = $('.toc-link[href="' + currentId + '"]')
582        _this.addClass('active')
583
584        var parents = _this.parents('.toc-child')
585        // Returned list is in reverse order of the DOM elements
586        // Thus `parents.last()` is the outermost .toc-child container
587        // i.e. list of subsections
588        var topLink = (parents.length > 0) ? parents.last() : _this
589        expandToc(topLink.closest('.toc-item').find('.toc-child'))
590        topLink
591          // Find all top-level .toc-item containers, i.e. sections
592          // excluding the currently active one
593          .closest('.toc-item').siblings('.toc-item')
594          // Hide their respective list of subsections
595          .find('.toc-child').hide()
596      }
597    }
598
599    var autoScrollToc = function (currentTop) {
600      if ($('.toc-link').hasClass('active')) {
601        var activePosition = $('.active').offset().top
602        var sidebarScrolltop = $('#sidebar .sidebar-toc__content').scrollTop()
603        if (activePosition > (currentTop + $(window).height() - 100)) {
604          $('#sidebar .sidebar-toc__content').scrollTop(sidebarScrolltop + 100)
605        }
606        if (activePosition < currentTop + 100) {
607          $('#sidebar .sidebar-toc__content').scrollTop(sidebarScrolltop - 100)
608        }
609      }
610    }
611  }
612
613  /**
614   * 閲讀模式
615   */
616  $('#readmode').click(function () {
617    $('body').toggleClass('read-mode')
618  })
619
620  /**
621   * 字體調整
622   */
623  $('#font_plus').click(function () {
624    $body.css('font-size', parseFloat($body.css('font-size')) + 1)
625  })
626  $('#font_minus').click(function () {
627    $body.css('font-size', parseFloat($body.css('font-size')) - 1)
628  })
629
630  /**
631   * menu
632   * 側邊欄sub-menu 展開/收縮
633   * 解決menus在觸摸屏下,滑動屏幕menus_item_child不消失的問題(手機hover的bug)
634   */
635  $('#mobile-sidebar-menus .menus-expand').on('click', function () {
636    if ($(this).hasClass('menus-closed')) {
637      $(this).parents('.menus_item').find('.menus_item_child').slideDown()
638      $(this).removeClass('menus-closed')
639    } else {
640      $(this).parents('.menus_item').find('.menus_item_child').slideUp()
641      $(this).addClass('menus-closed')
642    }
643  })
644
645  $(window).on('touchmove', function (e) {
646    var $menusChild = $('#page-header .menus_item_child')
647    if ($menusChild.is(':visible')) {
648      $menusChild.css('display', 'none')
649    }
650  })
651
652  /**
653   * rightside 點擊設置 按鈕 展開
654   */
655  $('#rightside_config').on('click', function () {
656    if ($('#rightside-config-hide').hasClass('rightside-in')) {
657      $('#rightside-config-hide').removeClass('rightside-in').addClass('rightside-out')
658    } else {
659      $('#rightside-config-hide').removeClass('rightside-out').addClass('rightside-in')
660    }
661  })
662
663  /**
664   * 複製時加上版權信息
665   */
666  var copyright = GLOBAL_CONFIG.copyright
667  if (copyright !== undefined) {
668    document.body.oncopy = function (event) {
669      event.preventDefault()
670      let textFont; const copyFont = window.getSelection(0).toString()
671      if (copyFont.length > 45) {
672        textFont = copyFont + '\n' + '\n' + '\n' +
673          copyright.languages.author + '\n' +
674          copyright.languages.link + window.location.href + '\n' +
675          copyright.languages.source + '\n' +
676          copyright.languages.info
677      } else {
678        textFont = copyFont
679      }
680      if (event.clipboardData) {
681        return event.clipboardData.setData('text', textFont)
682      } else {
683        // 兼容IE
684        return window.clipboardData.setData('text', textFont)
685      }
686    }
687  }
688
689  /**
690   * Darkmode
691   */
692  var isFontAwesomeV5 = GLOBAL_CONFIG.isFontAwesomeV5
693  var $darkModeButtom = $('#darkmode')
694  if (typeof autoChangeMode !== 'undefined') {
695    document.documentElement.getAttribute('data-theme') === 'dark' ? changeLightIcon() : changeDarkIcon()
696  }
697
698  function changeLightIcon () {
699    isFontAwesomeV5 ? $darkModeButtom.removeClass('fa-moon').addClass('fa-sun') : $darkModeButtom.removeClass('fa-moon-o').addClass('fa-sun-o')
700  }
701
702  function changeDarkIcon () {
703    isFontAwesomeV5 ? $darkModeButtom.removeClass('fa-sun').addClass('fa-moon') : $darkModeButtom.removeClass('fa-sun-o').addClass('fa-moon-o')
704  }
705
706  function switchReadMode () {
707    var nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
708    if (nowMode === 'light') {
709      changeLightIcon()
710      activateDarkMode()
711      Cookies.set('theme', 'dark', { expires: 2 })
712      if (isSnackbar) snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night)
713    } else {
714      changeDarkIcon()
715      activateLightMode()
716      Cookies.set('theme', 'light', { expires: 2 })
717      if (isSnackbar) snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day)
718    }
719  }
720
721  $darkModeButtom.click(function () {
722    switchReadMode()
723    if (typeof utterancesTheme === 'function') utterancesTheme()
724  })
725
726  /**
727   * 網頁運行時間
728   */
729  if (GLOBAL_CONFIG.runtime) {
730    // get user config
731    var $runtimeCount = $('#webinfo-runtime-count')
732    var startDate = $runtimeCount.attr('start_date')
733    var showDateTime = function () {
734      var BirthDay = new Date(startDate)
735      var today = new Date()
736      var timeold = (today.getTime() - BirthDay.getTime())
737      var daysold = Math.floor(timeold / (24 * 60 * 60 * 1000))
738      $runtimeCount.text(daysold + ' ' + GLOBAL_CONFIG.runtime_unit)
739    }
740    var interval
741    showDateTime()
742    clearInterval(interval)
743    interval = setInterval(showDateTime, 10000)
744  }
745
746  /**
747   * 百度推送
748   */
749  if (GLOBAL_CONFIG.baiduPush) {
750    (function () {
751      var bp = document.createElement('script')
752      var curProtocol = window.location.protocol.split(':')[0]
753      if (curProtocol === 'https') {
754        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'
755      } else {
756        bp.src = 'http://push.zhanzhang.baidu.com/push.js'
757      }
758      var s = document.getElementsByTagName('script')[0]
759      s.parentNode.insertBefore(bp, s)
760    })()
761  }
762
763  /**
764   * tag-hide
765   */
766  var $hideInline = $('.hide-button')
767  if ($hideInline.length) {
768    $hideInline.on('click', function (e) {
769      e.preventDefault()
770      var $this = $(this)
771      var $hideContent = $(this).next('.hide-content')
772      $this.toggleClass('open')
773      $hideContent.toggle()
774      if ($this.hasClass('open')) {
775        if (isJustifiedGallery && $hideContent.find('.justified-gallery').length > 0) {
776          initJustifiedGallery($hideContent.find('.justified-gallery'))
777        }
778      }
779    })
780  }
781})

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.