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