PageSourceSearch

https://www.airitibooks.com/js/loading.js?v=3JdsVCvPgrWepbn3KySToJjX-6jxSu2hxDzwUyrncg0

js airitibooks.com collected 2026-10-01 11:55:21 UTC 2,660 bytes, 113 lines download raw bytes

1let ajaxRequestCount = 0;
2let loadingTimer = null;
3let loadingShownAt = 0;
4const SHOW_DELAY = 300;
5const MIN_DISPLAY_TIME = 500;
6
7// 初始載入遮罩控制
8let initialPageLoaded = false;
9let initialAjaxDone = false;
10
11// 一般 AJAX 遮罩管理
12function showLoadingMask() {
13  if (!$('.loadingPage').is(':visible')) {
14    $('.loadingPage').show();
15    loadingShownAt = Date.now();
16  }
17}
18
19function hideLoadingMask() {
20  const timeSinceShown = Date.now() - loadingShownAt;
21  if (timeSinceShown < MIN_DISPLAY_TIME) {
22    setTimeout(() => {
23      $('.loadingPage').hide();
24    }, MIN_DISPLAY_TIME - timeSinceShown);
25  } else {
26    $('.loadingPage').hide();
27  }
28}
29
30// AJAX 全域管理
31$(document).ajaxStart(function () {
32  ajaxRequestCount++;
33  if (ajaxRequestCount === 1) {
34    loadingTimer = setTimeout(showLoadingMask, SHOW_DELAY);
35  }
36});
37
38$(document).ajaxStop(function () {
39  ajaxRequestCount--;
40  if (ajaxRequestCount <= 0) {
41    clearTimeout(loadingTimer);
42    hideLoadingMask();
43    ajaxRequestCount = 0;
44
45    // 檢查是否是初始遮罩
46    if (!initialAjaxDone) {
47      initialAjaxDone = true;
48      tryHideInitialMask();
49    }
50  }
51});
52
53$(document).ready(function () {
54  initialPageLoaded = true;
55  tryHideInitialMask();
56
57  setTimeout(() => {
58    if (!initialAjaxDone) {
59      initialAjaxDone = true;
60      tryHideInitialMask();
61    }
62  }, 500);
63});
64
65function tryHideInitialMask() {
66  if (initialPageLoaded && initialAjaxDone) {
67    $('.loadingPage').hide();
68  }
69}
70
71function redirectWithMask(url) {
72  setTimeout(() => {
73    $('.loadingPage').show();
74  }, 350);
75  window.location = url;
76}
77
78$(document).on('click', 'a', function (e) {
79  const $a = $(this);
80  const href = $a.attr('href');
81  const target = $a.attr('target');
82  // 不處理無 href、錨點、JavaScript 連結、_blank、mailto、Publication/DownLoadAttachment 等情況
83  if (!href ||
84    href.startsWith('#') ||
85    href.startsWith('javascript:') ||
86    href.startsWith('mailto:') ||
87    href.includes('Publication/DownLoadAttachment') ||
88    (target && target === '_blank')) {
89    return;
90  }
91  e.preventDefault();
92  e.stopImmediatePropagation();
93  redirectWithMask(href);
94});
95
96// 檢查是否為 "ctrl + 左鍵" 的組合。
97let fullNewPageCheck = false;
98document.addEventListener("click", function (e) {
99
100  // Windows/Linux Ctrl + 左鍵
101  if (e.ctrlKey && e.button === 0) {
102    fullNewPageCheck = true;
103    return;
104  }
105
106  // macOS Cmd + 左鍵
107  if (e.metaKey && e.button === 0) {
108    fullNewPageCheck = true;
109    return;
110  }
111
112  fullNewPageCheck = false;
113}, true);

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.