JO
2024-08-13 bf781fe79d3f2babeeaa9dd55e5f4a5da04e9977
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* global CONFIG, quicklink */
 
(function() {
  if (typeof CONFIG.quicklink.ignores === 'string') {
    const ignoresStr = `[${CONFIG.quicklink.ignores}]`;
    CONFIG.quicklink.ignores = JSON.parse(ignoresStr);
  }
 
  let resetFn = null;
 
  const onRefresh = () => {
    if (resetFn) resetFn();
    if (!CONFIG.quicklink.enable) return;
 
    let ignoresArr = CONFIG.quicklink.ignores || [];
    if (!Array.isArray(ignoresArr)) {
      ignoresArr = [ignoresArr];
    }
 
    resetFn = quicklink.listen({
      timeout : CONFIG.quicklink.timeout,
      priority: CONFIG.quicklink.priority,
      ignores : [
        uri => uri.includes('#'),
        uri => uri === CONFIG.quicklink.url,
        ...ignoresArr
      ]
    });
  };
 
  if (CONFIG.quicklink.delay) {
    window.addEventListener('load', onRefresh);
    document.addEventListener('pjax:success', onRefresh);
  } else {
    document.addEventListener('page:loaded', onRefresh);
  }
})();