nodebb-plugin-ezoic-infinite 1.5.91 → 1.5.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/client.js +5 -71
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -1,54 +1,15 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
var __ezoicAnchorMap = Object.create(null);
|
|
6
|
-
|
|
7
|
-
function ezoicGetAnchorKey(el, afterPos, kindClass) {
|
|
4
|
+
function ezoicTrySetAnchor(wrap, el, kindClass, afterPos) {
|
|
8
5
|
try {
|
|
9
|
-
if (!el) return
|
|
6
|
+
if (!wrap || !el) return;
|
|
10
7
|
var pid = el.getAttribute && (el.getAttribute('data-pid') || el.getAttribute('data-id'));
|
|
11
|
-
if (pid) return kindClass + ':pid:' + String(pid);
|
|
12
8
|
var tid = el.getAttribute && (el.getAttribute('data-tid') || el.getAttribute('data-topic-id'));
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (a) {
|
|
16
|
-
var p = a.getAttribute('data-pid') || a.getAttribute('data-id');
|
|
17
|
-
if (p) return kindClass + ':pid:' + String(p);
|
|
18
|
-
var t = a.getAttribute('data-tid') || a.getAttribute('data-topic-id');
|
|
19
|
-
if (t) return kindClass + ':tid:' + String(t);
|
|
20
|
-
}
|
|
21
|
-
} catch (e) {}
|
|
22
|
-
return kindClass + ':pos:' + String(afterPos || 0);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function ezoicRegisterWrapAnchor(wrap, anchorKey) {
|
|
26
|
-
try {
|
|
27
|
-
if (!wrap || !anchorKey) return;
|
|
28
|
-
wrap.setAttribute('data-ezoic-anchor', anchorKey);
|
|
29
|
-
__ezoicAnchorMap[anchorKey] = wrap;
|
|
30
|
-
} catch (e) {}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function ezoicFindWrapByAnchor(anchorKey) {
|
|
34
|
-
try {
|
|
35
|
-
var w = __ezoicAnchorMap[anchorKey];
|
|
36
|
-
if (w && w.isConnected) return w;
|
|
37
|
-
} catch (e) {}
|
|
38
|
-
try {
|
|
39
|
-
return document.querySelector('.nodebb-ezoic-wrap[data-ezoic-anchor="' + String(anchorKey).replace(/"/g, '') + '"]');
|
|
40
|
-
} catch (e) { return null; }
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function ezoicCleanupAnchorMap() {
|
|
44
|
-
try {
|
|
45
|
-
Object.keys(__ezoicAnchorMap).forEach(function(k){
|
|
46
|
-
var w = __ezoicAnchorMap[k];
|
|
47
|
-
if (!w || !w.isConnected) delete __ezoicAnchorMap[k];
|
|
48
|
-
});
|
|
9
|
+
var key = kindClass + ':' + (pid ? ('pid:' + pid) : (tid ? ('tid:' + tid) : ('pos:' + String(afterPos || 0))));
|
|
10
|
+
wrap.setAttribute('data-ezoic-anchor', key);
|
|
49
11
|
} catch (e) {}
|
|
50
12
|
}
|
|
51
|
-
// ===== /V6 =====
|
|
52
13
|
|
|
53
14
|
|
|
54
15
|
// Track scroll direction to avoid aggressive recycling when the user scrolls upward.
|
|
@@ -690,8 +651,7 @@ function globalGapFixInit() {
|
|
|
690
651
|
const wrap = document.createElement('div');
|
|
691
652
|
wrap.className = `${WRAP_CLASS} ${kindClass}`;
|
|
692
653
|
wrap.setAttribute('data-ezoic-after', String(afterPos));
|
|
693
|
-
|
|
694
|
-
ezoicRegisterWrapAnchor(wrap, __anchorKey);
|
|
654
|
+
ezoicTrySetAnchor(wrap, el, kindClass, afterPos);
|
|
695
655
|
wrap.setAttribute('data-ezoic-wrapid', String(id));
|
|
696
656
|
wrap.setAttribute('data-created', String(now()));
|
|
697
657
|
// "Pinned" placements (after the first item) should remain stable.
|
|
@@ -1131,7 +1091,6 @@ function buildOrdinalMap(items) {
|
|
|
1131
1091
|
}
|
|
1132
1092
|
|
|
1133
1093
|
function injectBetween(kindClass, items, interval, showFirst, allIds, cursorKey) {
|
|
1134
|
-
ezoicCleanupAnchorMap();
|
|
1135
1094
|
if (!items.length) return 0;
|
|
1136
1095
|
|
|
1137
1096
|
const { map: ordinalMap, max: maxOrdinal } = buildOrdinalMap(items);
|
|
@@ -1525,28 +1484,3 @@ function buildOrdinalMap(items) {
|
|
|
1525
1484
|
insertHeroAdEarly().catch(() => {});
|
|
1526
1485
|
requestBurst();
|
|
1527
1486
|
})();
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
// V6 guard: prevent unexpected regrouping under first topic
|
|
1531
|
-
try {
|
|
1532
|
-
if (typeof MutationObserver !== 'undefined' && !window.__ezoicWrapGuardInstalled) {
|
|
1533
|
-
window.__ezoicWrapGuardInstalled = true;
|
|
1534
|
-
var guardObserver = new MutationObserver(function() {
|
|
1535
|
-
try {
|
|
1536
|
-
Object.keys(__ezoicAnchorMap).forEach(function(k){
|
|
1537
|
-
var w = __ezoicAnchorMap[k];
|
|
1538
|
-
if (!w || !w.isConnected) return;
|
|
1539
|
-
var anchor = w.getAttribute('data-ezoic-anchor') || '';
|
|
1540
|
-
var m = anchor.match(/:(pid|tid):(.+)$/);
|
|
1541
|
-
if (!m) return;
|
|
1542
|
-
var val = m[2];
|
|
1543
|
-
var anchorEl = document.querySelector('[data-pid="' + val + '"], [data-id="' + val + '"], [data-tid="' + val + '"], [data-topic-id="' + val + '"]');
|
|
1544
|
-
if (anchorEl && w.previousElementSibling !== anchorEl) {
|
|
1545
|
-
if (anchorEl.parentNode) anchorEl.parentNode.insertBefore(w, anchorEl.nextSibling);
|
|
1546
|
-
}
|
|
1547
|
-
});
|
|
1548
|
-
} catch (e) {}
|
|
1549
|
-
});
|
|
1550
|
-
guardObserver.observe(document.body || document.documentElement, { childList: true, subtree: true });
|
|
1551
|
-
}
|
|
1552
|
-
} catch (e) {}
|