ajaxify 8.1.3 → 8.1.7
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/ajaxify.js +144 -219
- package/ajaxify.min.js +1 -1
- package/package.json +1 -1
package/ajaxify.js
CHANGED
|
@@ -15,6 +15,15 @@ Ajaxifies the whole site, dynamically replacing the elements specified in "eleme
|
|
|
15
15
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
let $;
|
|
19
|
+
|
|
20
|
+
//Module global helpers
|
|
21
|
+
let rootUrl = location.origin, inlineclass = "ajy-inline",
|
|
22
|
+
bdy,
|
|
23
|
+
qa=(s,o=document)=>o.querySelectorAll(s),
|
|
24
|
+
qs=(s,o=document)=>o.querySelector(s);
|
|
25
|
+
|
|
26
|
+
|
|
18
27
|
// The main plugin - Ajaxify
|
|
19
28
|
// Is passed the global options
|
|
20
29
|
// Checks for necessary pre-conditions - otherwise gracefully degrades
|
|
@@ -22,7 +31,7 @@ Ajaxifies the whole site, dynamically replacing the elements specified in "eleme
|
|
|
22
31
|
// Calls Pronto
|
|
23
32
|
class Ajaxify { constructor(options) {
|
|
24
33
|
String.prototype.iO = function(s) { return this.toString().indexOf(s) + 1; }; //Intuitively better understandable shorthand for String.indexOf() - String.iO()
|
|
25
|
-
|
|
34
|
+
$ = this;
|
|
26
35
|
|
|
27
36
|
//Options default values
|
|
28
37
|
$.s = {
|
|
@@ -43,11 +52,10 @@ $.s = {
|
|
|
43
52
|
asyncdef : true, // default async value for dynamically inserted external scripts, false = synchronous / true = asynchronous
|
|
44
53
|
alwayshints : false, // strings, - separated by ", " - if matched in any external script URL - these are always loaded on every page load
|
|
45
54
|
inline : true, // true = all inline scripts loaded, false = only specific inline scripts are loaded
|
|
46
|
-
inlinesync : true, // synchronise inline scripts loading by adding a central tiny delay to all of them
|
|
47
55
|
inlinehints : false, // strings - separated by ", " - if matched in any inline scripts - only these are executed - set "inline" to false beforehand
|
|
48
56
|
inlineskip : "adsbygoogle", // strings - separated by ", " - if matched in any inline scripts - these are NOT are executed - set "inline" to true beforehand
|
|
49
57
|
inlineappend : true, // append scripts to the main content element, instead of "eval"-ing them
|
|
50
|
-
intevents: true, // intercept events that are fired only on classic page load and simulate their trigger on ajax page load ("DOMContentLoaded"
|
|
58
|
+
intevents: true, // intercept events that are fired only on classic page load and simulate their trigger on ajax page load ("DOMContentLoaded")
|
|
51
59
|
style : true, // true = all style tags in the head loaded, false = style tags on target page ignored
|
|
52
60
|
prefetchoff : false, // Plugin pre-fetches pages on hoverIntent - true = set off completely // strings - separated by ", " - hints to select out
|
|
53
61
|
|
|
@@ -60,38 +68,15 @@ $.s = {
|
|
|
60
68
|
};
|
|
61
69
|
|
|
62
70
|
|
|
63
|
-
$.pass = 0; $.currentURL = "";
|
|
71
|
+
$.pass = 0; $.currentURL = ""; $.h = {};
|
|
64
72
|
$.parse = (s, pl) => (pl = document.createElement('div'), pl.insertAdjacentHTML('afterbegin', s), pl.firstElementChild); // HTML parser
|
|
65
|
-
$.trigger = (t, e) => { let ev = document.createEvent('HTMLEvents'); ev.initEvent("pronto." + t, true, false); ev.data = e ? e : $.Rq("e"); window.dispatchEvent(ev); document.dispatchEvent(ev); }
|
|
66
|
-
$.internal = (url) => { if (!url) return false; if (typeof(url) === "object") url = url.href; if (url==="") return true; return url.substring(0,rootUrl.length) === rootUrl || !url.iO(":"); }
|
|
73
|
+
$.trigger = (t, e) => { let ev = document.createEvent('HTMLEvents'); ev.initEvent("pronto." + t, true, false); ev.data = e ? e : $.Rq("e"); window.dispatchEvent(ev); document.dispatchEvent(ev); };
|
|
74
|
+
$.internal = (url) => { if (!url) return false; if (typeof(url) === "object") url = url.href; if (url==="") return true; return url.substring(0,rootUrl.length) === rootUrl || !url.iO(":"); };
|
|
67
75
|
$.intevents = () => {
|
|
68
|
-
let iFn = function (a, b, c = false) { if ((this === document || this === window) && a=="DOMContentLoaded") setTimeout(b); else this.ael(a,b,c);} // if "DOMContentLoaded" - execute function, else - add event listener
|
|
76
|
+
let iFn = function (a, b, c = false) { if ((this === document || this === window) && a=="DOMContentLoaded") setTimeout(b); else this.ael(a,b,c);}; // if "DOMContentLoaded" - execute function, else - add event listener
|
|
69
77
|
EventTarget.prototype.ael = EventTarget.prototype.addEventListener; // store original method
|
|
70
78
|
EventTarget.prototype.addEventListener = iFn; // start intercepting event listener addition
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
//Module global variables
|
|
74
|
-
let rootUrl = location.origin, api = window.history && window.history.pushState && window.history.replaceState,
|
|
75
|
-
|
|
76
|
-
//Regexes for escaping fetched HTML of a whole page - best of Baluptons Ajaxify
|
|
77
|
-
//Makes it possible to pre-fetch an entire page
|
|
78
|
-
docType = /<\!DOCTYPE[^>]*>/i,
|
|
79
|
-
tagso = /<(html|head|link)([\s\>])/gi,
|
|
80
|
-
tagsod = /<(body)([\s\>])/gi,
|
|
81
|
-
tagsc = /<\/(html|head|body|link)\>/gi,
|
|
82
|
-
|
|
83
|
-
//Helper strings
|
|
84
|
-
div12 = '<div class="ajy-$1"$2',
|
|
85
|
-
divid12 = '<div id="ajy-$1"$2',
|
|
86
|
-
linki = '<link rel="stylesheet" type="text/css" href="*" />',
|
|
87
|
-
linkr = 'link[href*="!"]',
|
|
88
|
-
scrr = 'script[src*="!"]',
|
|
89
|
-
inlineclass = "ajy-inline";
|
|
90
|
-
|
|
91
|
-
//Global helpers
|
|
92
|
-
let doc=document, bdy,
|
|
93
|
-
qa=(s,o=doc)=>o.querySelectorAll(s),
|
|
94
|
-
qs=(s,o=doc)=>o.querySelector(s);
|
|
79
|
+
};
|
|
95
80
|
|
|
96
81
|
function _copyAttributes(el, $S, flush) { //copy all attributes of element generically
|
|
97
82
|
if (flush) [...el.attributes].forEach(e => el.removeAttribute(e.name)); //delete all old attributes
|
|
@@ -110,77 +95,12 @@ function _on(eventName, elementSelector, handler, el = document) { //e.currentTa
|
|
|
110
95
|
}, !!eventName.iO('mo'));
|
|
111
96
|
}
|
|
112
97
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
Hints.prototype.find = function (t) {return (!t || !this.myHints) ? false : this.myHints.some(h => t.iO(h))}; //iterate through hints within passed text (t)
|
|
118
|
-
|
|
119
|
-
function lg(m){ $.s.verbosity && console && console.log(m); }
|
|
120
|
-
|
|
121
|
-
// The stateful Cache class
|
|
122
|
-
// Usage - parameter "o" values:
|
|
123
|
-
// none - returns currently cached page
|
|
124
|
-
// <URL> - returns page with specified URL
|
|
125
|
-
// <object> - saves the page in cache
|
|
126
|
-
// f - flushes the cache
|
|
127
|
-
class Cache { constructor() {
|
|
128
|
-
let d = false;
|
|
129
|
-
|
|
130
|
-
this.a = function (o) {
|
|
131
|
-
if (!o) return d;
|
|
132
|
-
|
|
133
|
-
if (typeof o === "string") { //URL or "f" passed
|
|
134
|
-
if(o === "f") { //"f" passed -> flush
|
|
135
|
-
$.pages("f"); //delegate flush to $.pages
|
|
136
|
-
lg("Cache flushed");
|
|
137
|
-
} else d = $.pages($.memory(o)); //URL passed -> look up page in memory
|
|
138
|
-
|
|
139
|
-
return d; //return cached page
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (typeof o === "object") {
|
|
143
|
-
d = o;
|
|
144
|
-
return d;
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}}
|
|
148
|
-
|
|
149
|
-
// The stateful Memory class
|
|
150
|
-
// Usage: $.memory(<URL>) - returns the same URL if not turned off internally
|
|
151
|
-
class Memory { constructor(options) {
|
|
152
|
-
|
|
153
|
-
this.a = function (h) {
|
|
154
|
-
if (!h || $.s.memoryoff === true) return false;
|
|
155
|
-
if ($.s.memoryoff === false) return h;
|
|
156
|
-
return Hints($.s.memoryoff).find(h) ? false : h;
|
|
157
|
-
};
|
|
98
|
+
class Hints { constructor(h) { let _ = this;
|
|
99
|
+
_.list = (typeof h === 'string' && h.length > 0) ? h.split(", ") : false; //hints are passed as a comma separated string
|
|
100
|
+
_.find = (t) => (!t || !_.list) ? false : _.list.some(h => t.iO(h)); //iterate through hints within passed text (t)
|
|
158
101
|
}}
|
|
159
102
|
|
|
160
|
-
|
|
161
|
-
// Usage - parameter "h" values:
|
|
162
|
-
// <URL> - returns page with specified URL from internal array
|
|
163
|
-
// <object> - saves the passed page in internal array
|
|
164
|
-
// false - returns false
|
|
165
|
-
class Pages { constructor() {
|
|
166
|
-
let d = [], i = -1;
|
|
167
|
-
|
|
168
|
-
this.a = function (h) {
|
|
169
|
-
if (typeof h === "string") {
|
|
170
|
-
if(h === "f") d = [];
|
|
171
|
-
else if((i=_iPage(h)) !== -1) return d[i][1];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (typeof h === "object") {
|
|
175
|
-
if((i=_iPage(h)) === -1) d.push(h);
|
|
176
|
-
else d[i] = h;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (typeof h === "boolean") return false;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
let _iPage = h => d.findIndex(e => e[0] == h)
|
|
183
|
-
}}
|
|
103
|
+
function lg(m){ $.s.verbosity && console && console.log(m); }
|
|
184
104
|
|
|
185
105
|
// The GetPage class
|
|
186
106
|
// First parameter (o) is a switch:
|
|
@@ -192,10 +112,21 @@ class Pages { constructor() {
|
|
|
192
112
|
// otherwise - returns selection of current page to client
|
|
193
113
|
|
|
194
114
|
class GetPage { constructor() {
|
|
195
|
-
let rsp = 0, cb = 0, plus = 0, rt = "", ct = 0, rc = 0, ac = 0
|
|
196
|
-
|
|
115
|
+
let rsp = 0, cb = 0, plus = 0, rt = "", ct = 0, rc = 0, ac = 0,
|
|
116
|
+
|
|
117
|
+
//Regexes for escaping fetched HTML of a whole page - best of Baluptons Ajaxify
|
|
118
|
+
//Makes it possible to pre-fetch an entire page
|
|
119
|
+
docType = /<\!DOCTYPE[^>]*>/i,
|
|
120
|
+
tagso = /<(html|head|link)([\s\>])/gi,
|
|
121
|
+
tagsod = /<(body)([\s\>])/gi,
|
|
122
|
+
tagsc = /<\/(html|head|body|link)\>/gi,
|
|
123
|
+
|
|
124
|
+
//Helper strings
|
|
125
|
+
div12 = '<div class="ajy-$1"$2',
|
|
126
|
+
divid12 = '<div id="ajy-$1"$2';
|
|
127
|
+
|
|
197
128
|
this.a = function (o, p, p2) {
|
|
198
|
-
if (!o) return $.cache();
|
|
129
|
+
if (!o) return $.cache.g();
|
|
199
130
|
|
|
200
131
|
if (o.iO("/")) {
|
|
201
132
|
cb = p;
|
|
@@ -214,11 +145,11 @@ class GetPage { constructor() {
|
|
|
214
145
|
if (o === "-") return _lSel(p);
|
|
215
146
|
if (o === "x") return rsp;
|
|
216
147
|
|
|
217
|
-
if (!$.cache()) return;
|
|
218
|
-
if (o === "body") return qs("#ajy-" + o, $.cache());
|
|
219
|
-
if (o === "script") return qa(o, $.cache());
|
|
148
|
+
if (!$.cache.g()) return;
|
|
149
|
+
if (o === "body") return qs("#ajy-" + o, $.cache.g());
|
|
150
|
+
if (o === "script") return qa(o, $.cache.g());
|
|
220
151
|
|
|
221
|
-
return qs((o === "title") ? o : ".ajy-" + o, $.cache());
|
|
152
|
+
return qs((o === "title") ? o : ".ajy-" + o, $.cache.g());
|
|
222
153
|
};
|
|
223
154
|
let _lSel = $t => (
|
|
224
155
|
$.pass++,
|
|
@@ -230,18 +161,13 @@ let _lSel = $t => (
|
|
|
230
161
|
),
|
|
231
162
|
_lPage = (h, pre) => {
|
|
232
163
|
if (h.iO("#")) h = h.split("#")[0];
|
|
233
|
-
if ($.Rq("is") || !$.cache(h)) return _lAjax(h, pre);
|
|
164
|
+
if ($.Rq("is") || !$.cache.l(h)) return _lAjax(h, pre);
|
|
234
165
|
|
|
235
166
|
plus = 0;
|
|
236
167
|
if (cb) return cb();
|
|
237
168
|
},
|
|
238
169
|
_ld = ($t, $h) => {
|
|
239
|
-
if(!$h)
|
|
240
|
-
lg("Inserting placeholder for ID: " + $t.getAttribute("id"));
|
|
241
|
-
var tagN = $t.tagName.toLowerCase();
|
|
242
|
-
$t.parentNode.replaceChild($.parse("<" + tagN + " id='" + $t.getAttribute("id") + "'></" + tagN + ">"), $t);
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
170
|
+
if(!$h) return; //no input
|
|
245
171
|
|
|
246
172
|
var $c = $h.cloneNode(true); // clone element node (true = deep clone)
|
|
247
173
|
qa("script", $c).forEach(e => e.parentNode.removeChild(e));
|
|
@@ -249,10 +175,10 @@ let _lSel = $t => (
|
|
|
249
175
|
$t.innerHTML = $c.innerHTML;
|
|
250
176
|
},
|
|
251
177
|
_lEls = $t =>
|
|
252
|
-
$.cache() && !_isBody($t) && $t.forEach(function($el) {
|
|
253
|
-
_ld($el, qs("#" + $el.getAttribute("id"), $.cache()));
|
|
178
|
+
$.cache.g() && !_isBody($t) && $t.forEach(function($el) {
|
|
179
|
+
_ld($el, qs("#" + $el.getAttribute("id"), $.cache.g()));
|
|
254
180
|
}),
|
|
255
|
-
_isBody = $t => $t[0].tagName.toLowerCase() == "body" && (_ld(bdy, qs("#ajy-body", $.cache())), 1),
|
|
181
|
+
_isBody = $t => $t[0].tagName.toLowerCase() == "body" && (_ld(bdy, qs("#ajy-body", $.cache.g())), 1),
|
|
256
182
|
_lAjax = (hin, pre) => {
|
|
257
183
|
var ispost = $.Rq("is");
|
|
258
184
|
if (pre) rt="p"; else rt="c";
|
|
@@ -289,7 +215,7 @@ let _lSel = $t => (
|
|
|
289
215
|
}).finally(() => rc--); // reset active request counter
|
|
290
216
|
},
|
|
291
217
|
_cl = c => (plus = 0, (!c) ? cb = 0 : 0), // clear plus AND/OR callback
|
|
292
|
-
_cache = (href, h, err) => $.cache($.parse(_parseHTML(h))) && ($.pages([href, $.cache()]), 1) && cb && cb(err),
|
|
218
|
+
_cache = (href, h, err) => $.cache.s($.parse(_parseHTML(h))) && ($.pages.p([href, $.cache.g()]), 1) && cb && cb(err),
|
|
293
219
|
_isHtml = x => (ct = x.headers.get("content-type")) && (ct.iO("html") || ct.iO("form-")),
|
|
294
220
|
_parseHTML = h => document.createElement("html").innerHTML = _replD(h).trim(),
|
|
295
221
|
_replD = h => String(h).replace(docType, "").replace(tagso, div12).replace(tagsod, divid12).replace(tagsc, "</div>")
|
|
@@ -303,8 +229,10 @@ let _lSel = $t => (
|
|
|
303
229
|
// otherwise - delta loading
|
|
304
230
|
class Scripts { constructor() {
|
|
305
231
|
let $s = false, txt = 0;
|
|
232
|
+
$.h.inlinehints = new Hints($.s.inlinehints);
|
|
233
|
+
$.h.inlineskip = new Hints($.s.inlineskip);
|
|
306
234
|
|
|
307
|
-
|
|
235
|
+
this.a = function (o) {
|
|
308
236
|
if (o === "i") {
|
|
309
237
|
if(!$s) $s = {};
|
|
310
238
|
return true;
|
|
@@ -331,8 +259,8 @@ let _allstyle = $s =>
|
|
|
331
259
|
),
|
|
332
260
|
_onetxt = $s =>
|
|
333
261
|
(!(txt = $s.textContent).iO(").ajaxify(") && (!txt.iO("new Ajaxify(")) &&
|
|
334
|
-
(($.s.inline &&
|
|
335
|
-
|
|
262
|
+
(($.s.inline && !$.h.inlineskip.find(txt)) || $s.classList.contains("ajaxy") ||
|
|
263
|
+
$.h.inlinehints.find(txt))
|
|
336
264
|
) && _addtxt($s),
|
|
337
265
|
_addtxt = $s => {
|
|
338
266
|
if(!txt || !txt.length) return;
|
|
@@ -347,7 +275,7 @@ let _allstyle = $s =>
|
|
|
347
275
|
return qs("body").appendChild(sc);
|
|
348
276
|
},
|
|
349
277
|
_addstyle = t => qs("head").appendChild($.parse('<style>' + t + '</style>')),
|
|
350
|
-
_addScripts = $s => (
|
|
278
|
+
_addScripts = $s => ($.addAll($s.c, "href"), $.addAll($s.j, "src"))
|
|
351
279
|
}}
|
|
352
280
|
|
|
353
281
|
// The DetScripts plugin - stands for "detach scripts"
|
|
@@ -378,7 +306,12 @@ let _rel = (lk, v) => Array.prototype.filter.call(lk, e => e.getAttribute("rel")
|
|
|
378
306
|
// href - operate on stylesheets in the new selection
|
|
379
307
|
// src - operate on JS scripts
|
|
380
308
|
class AddAll { constructor() {
|
|
381
|
-
let $scriptsO = [], $sCssO = [], $sO = [], PK = 0, url = 0
|
|
309
|
+
let $scriptsO = [], $sCssO = [], $sO = [], PK = 0, url = 0,
|
|
310
|
+
linki = '<link rel="stylesheet" type="text/css" href="*" />',
|
|
311
|
+
linkr = 'link[href*="!"]',
|
|
312
|
+
scrr = 'script[src*="!"]';
|
|
313
|
+
|
|
314
|
+
$.h.alwayshints = new Hints($.s.alwayshints);
|
|
382
315
|
|
|
383
316
|
this.a = function ($this, pk) {
|
|
384
317
|
if(!$this.length) return; //ensure input
|
|
@@ -414,7 +347,7 @@ class AddAll { constructor() {
|
|
|
414
347
|
};
|
|
415
348
|
let _allScripts = $t => $t.forEach(e => _iScript(e)),
|
|
416
349
|
_newArray = $t => $t.forEach(e => (url = e.getAttribute(PK)) ? $scriptsO.push(url) : 0),
|
|
417
|
-
_classAlways = $t => $t.getAttribute("data-class") == "always" ||
|
|
350
|
+
_classAlways = $t => $t.getAttribute("data-class") == "always" || $.h.alwayshints.find(url),
|
|
418
351
|
_iScript = $S => {
|
|
419
352
|
url = $S.getAttribute(PK);
|
|
420
353
|
|
|
@@ -563,7 +496,7 @@ class Frms { constructor() {
|
|
|
563
496
|
|
|
564
497
|
q.preventDefault(); //prevent default form action
|
|
565
498
|
return(false); //success -> disable default behaviour
|
|
566
|
-
})
|
|
499
|
+
});
|
|
567
500
|
});
|
|
568
501
|
});
|
|
569
502
|
};
|
|
@@ -582,82 +515,6 @@ let _k = () => {
|
|
|
582
515
|
}
|
|
583
516
|
}}
|
|
584
517
|
|
|
585
|
-
// The stateful Offsets plugin
|
|
586
|
-
// Usage:
|
|
587
|
-
// 1) $.offsets(<URL>) - returns offset of specified URL from internal array
|
|
588
|
-
// 2) $.offsets() - saves the current URL + offset in internal array
|
|
589
|
-
class Offsets { constructor() {
|
|
590
|
-
let d = [], i = -1;
|
|
591
|
-
|
|
592
|
-
this.a = function (h) {
|
|
593
|
-
if (typeof h === "string") { //Lookup page offset
|
|
594
|
-
h = h.iO("?") ? h.split("?")[0] : h; //Handle root URL only from dynamic pages
|
|
595
|
-
i = _iOffset(h); //Fetch offset
|
|
596
|
-
if(i === -1) return 0; // scrollTop if not found
|
|
597
|
-
return d[i][1]; //Return offset that was found
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
//Add page offset
|
|
601
|
-
var u = $.currentURL, us1 = u.iO("?") ? u.split("?")[0] : u, us = us1.iO("#") ? us1.split("#")[0] : us1, os = [us, (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop];
|
|
602
|
-
i = _iOffset(us); //get page index
|
|
603
|
-
if(i === -1) d.push(os); //doesn't exist -> push to array
|
|
604
|
-
else d[i] = os; //exists -> overwrite
|
|
605
|
-
};
|
|
606
|
-
let _iOffset = h => d.findIndex(e => e[0] == h)
|
|
607
|
-
}}
|
|
608
|
-
|
|
609
|
-
// The Scrolly plugin - manages scroll effects centrally
|
|
610
|
-
// scrolltop values: "s" - "smart" (default), true - always scroll to top, false - no scroll
|
|
611
|
-
// Switch (o) values:
|
|
612
|
-
// + - add current page to offsets
|
|
613
|
-
// ! - scroll to current page offset
|
|
614
|
-
class Scrolly { constructor() {
|
|
615
|
-
|
|
616
|
-
this.a = function (o) {
|
|
617
|
-
if(!o) return; //ensure operator
|
|
618
|
-
|
|
619
|
-
var op = o; //cache operator
|
|
620
|
-
|
|
621
|
-
if(o === "+" || o === "!") o = $.currentURL; //fetch currentURL for "+" and "-" operators
|
|
622
|
-
|
|
623
|
-
if(op !== "+" && o.iO("#") && (o.iO("#") < o.length - 1)) { //if hash in URL and not standalone hash
|
|
624
|
-
let $el = qs("#" + o.split("#")[1]); //fetch the element
|
|
625
|
-
if (!$el) return; //nothing found -> return quickly
|
|
626
|
-
let box = $el.getBoundingClientRect();
|
|
627
|
-
_scrll(box.top + window.pageYOffset - document.documentElement.clientTop); // ...animate to ID
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
if($.s.scrolltop === "s") { //smart scroll enabled
|
|
632
|
-
if(op === "+") $.offsets(); //add page offset
|
|
633
|
-
if(op === "!") _scrll($.offsets(o)); //scroll to stored position of page
|
|
634
|
-
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
if(op !== "+" && $.s.scrolltop) _scrll(0); //otherwise scroll to top of page
|
|
639
|
-
|
|
640
|
-
//default -> do nothing
|
|
641
|
-
};
|
|
642
|
-
let _scrll = o => window.scrollTo(0, o)
|
|
643
|
-
}}
|
|
644
|
-
|
|
645
|
-
// The hApi plugin - manages operatios on the History API centrally
|
|
646
|
-
// Second parameter (p) - set global currentURL
|
|
647
|
-
// Switch (o) values:
|
|
648
|
-
// = - perform a replaceState, using currentURL
|
|
649
|
-
// otherwise - perform a pushState, using currentURL
|
|
650
|
-
class HApi { constructor() {
|
|
651
|
-
|
|
652
|
-
this.a = function (o, p) {
|
|
653
|
-
if(!o) return; //ensure operator
|
|
654
|
-
if(p) $.currentURL = p; //if p given -> update current URL
|
|
655
|
-
|
|
656
|
-
if(o === "=") history.replaceState({ url: $.currentURL }, "state-" + $.currentURL, $.currentURL); //perform replaceState
|
|
657
|
-
else if ($.currentURL !== window.location.href) history.pushState({ url: $.currentURL }, "state-" + $.currentURL, $.currentURL); //perform pushState
|
|
658
|
-
};
|
|
659
|
-
}}
|
|
660
|
-
|
|
661
518
|
// The Pronto plugin - Pronto variant of Ben Plum's Pronto plugin - low level event handling in general
|
|
662
519
|
// Works on a selection, passed to Pronto by the selection, which specifies, which elements to Ajaxify
|
|
663
520
|
// Switch (h) values:
|
|
@@ -666,6 +523,7 @@ class HApi { constructor() {
|
|
|
666
523
|
// <URL> - set "h" variable of Rq hard and continue with _request()
|
|
667
524
|
class Pronto { constructor() {
|
|
668
525
|
let $gthis = 0, requestTimer = 0, pd = 150, ptim = 0;
|
|
526
|
+
$.h.prefetchoff = new Hints($.s.prefetchoff);
|
|
669
527
|
|
|
670
528
|
this.a = function ($this, h) {
|
|
671
529
|
if(!h) return; //ensure data
|
|
@@ -676,9 +534,9 @@ class Pronto { constructor() {
|
|
|
676
534
|
$gthis = qa($this); //copy selection to global selector
|
|
677
535
|
$.frms = new Frms().a; //initialise forms sub-plugin
|
|
678
536
|
if($.s.idleTime) $.slides = new classSlides($).a; //initialise optional slideshow sub-plugin
|
|
679
|
-
$.scrolly = new Scrolly()
|
|
680
|
-
$.offsets = new Offsets().
|
|
681
|
-
$.hApi = new HApi()
|
|
537
|
+
$.scrolly = new Scrolly(); //initialise scroll effects sub-plugin
|
|
538
|
+
($.offsets = new Offsets()).f();
|
|
539
|
+
$.hApi = new HApi();
|
|
682
540
|
_init_p(); //initialise Pronto sub-plugin
|
|
683
541
|
return $this; //return query selector for chaining
|
|
684
542
|
}
|
|
@@ -695,7 +553,7 @@ class Pronto { constructor() {
|
|
|
695
553
|
}
|
|
696
554
|
};
|
|
697
555
|
let _init_p = () => {
|
|
698
|
-
$.hApi(
|
|
556
|
+
$.hApi.r(window.location.href);
|
|
699
557
|
window.addEventListener("popstate", _onPop);
|
|
700
558
|
if ($.s.prefetchoff !== true) {
|
|
701
559
|
_on("mouseenter", $.s.selector, _preftime); // start prefetch timeout
|
|
@@ -708,13 +566,13 @@ let _init_p = () => {
|
|
|
708
566
|
$.frms("d", $gthis);
|
|
709
567
|
if($.s.idleTime) $.slides("i");
|
|
710
568
|
},
|
|
711
|
-
_preftime = (t, e) => ptim = setTimeout(()=> _prefetch(t, e), pd), // call prefetch if timeout expires without being cleared by _prefstop
|
|
569
|
+
_preftime = (t, e) => (_prefstop(), ptim = setTimeout(()=> _prefetch(t, e), pd)), // call prefetch if timeout expires without being cleared by _prefstop
|
|
712
570
|
_prefstop = () => clearTimeout(ptim),
|
|
713
571
|
_prefetch = (t, e) => {
|
|
714
572
|
if($.s.prefetchoff === true) return;
|
|
715
573
|
if (!$.Rq("?", true)) return;
|
|
716
574
|
var href = $.Rq("v", e, t);
|
|
717
|
-
if ($.Rq("=", true) || !href ||
|
|
575
|
+
if ($.Rq("=", true) || !href || $.h.prefetchoff.find(href)) return;
|
|
718
576
|
$.fn("+", href, () => false);
|
|
719
577
|
},
|
|
720
578
|
_stopBubbling = e => (
|
|
@@ -728,13 +586,13 @@ let _init_p = () => {
|
|
|
728
586
|
if(!href || _exoticKey(t)) return;
|
|
729
587
|
if(href.substr(-1) ==="#") return true;
|
|
730
588
|
if(_hashChange()) {
|
|
731
|
-
$.hApi(
|
|
589
|
+
$.hApi.r(href);
|
|
732
590
|
return true;
|
|
733
591
|
}
|
|
734
592
|
|
|
735
|
-
$.scrolly(
|
|
593
|
+
$.scrolly.p();
|
|
736
594
|
_stopBubbling(e);
|
|
737
|
-
if($.Rq("=")) $.hApi(
|
|
595
|
+
if($.Rq("=")) $.hApi.r();
|
|
738
596
|
if($.s.refresh || !$.Rq("=")) _request(notPush);
|
|
739
597
|
},
|
|
740
598
|
_request = notPush => {
|
|
@@ -763,7 +621,7 @@ let _init_p = () => {
|
|
|
763
621
|
$.Rq("i");
|
|
764
622
|
$.Rq("h", url);
|
|
765
623
|
$.Rq("p", false);
|
|
766
|
-
$.scrolly(
|
|
624
|
+
$.scrolly.p();
|
|
767
625
|
|
|
768
626
|
if (!url || url === $.currentURL) return;
|
|
769
627
|
$.trigger("request");
|
|
@@ -776,12 +634,12 @@ let _init_p = () => {
|
|
|
776
634
|
var href = $.Rq("h"), title;
|
|
777
635
|
href = $.Rq("c", href);
|
|
778
636
|
|
|
779
|
-
|
|
637
|
+
if($.Rq("p")) $.hApi.p(href); else $.hApi.r(href);
|
|
780
638
|
if(title = $.fn("title")) qs("title").innerHTML = title.innerHTML;
|
|
781
639
|
$.Rq("C", $.fn("-", $gthis));
|
|
782
640
|
$.frms("a");
|
|
783
641
|
|
|
784
|
-
$.scrolly(
|
|
642
|
+
$.scrolly.l();
|
|
785
643
|
_gaCaptureView(href);
|
|
786
644
|
$.trigger("render");
|
|
787
645
|
if($.s.passCount) qs("#" + $.s.passCount).innerHTML = "Pass: " + $.pass;
|
|
@@ -817,7 +675,7 @@ $.init = () => {
|
|
|
817
675
|
|
|
818
676
|
let run = () => {
|
|
819
677
|
$.s = Object.assign($.s, options);
|
|
820
|
-
$.pages = new Pages().
|
|
678
|
+
($.pages = new Pages()).f();
|
|
821
679
|
$.pronto = new Pronto().a;
|
|
822
680
|
if (load()) {
|
|
823
681
|
$.pronto($.s.elements, "i");
|
|
@@ -825,7 +683,7 @@ let run = () => {
|
|
|
825
683
|
}
|
|
826
684
|
},
|
|
827
685
|
load = () => {
|
|
828
|
-
if (!
|
|
686
|
+
if (!(window.history && window.history.pushState && window.history.replaceState) || !$.s.pluginon) {
|
|
829
687
|
lg("Gracefully exiting...");
|
|
830
688
|
return false;
|
|
831
689
|
}
|
|
@@ -835,13 +693,80 @@ let run = () => {
|
|
|
835
693
|
if ($.s.intevents) $.intevents(); // intercept events
|
|
836
694
|
$.scripts = new Scripts().a;
|
|
837
695
|
$.scripts("i");
|
|
838
|
-
$.cache = new Cache()
|
|
839
|
-
$.memory = new Memory().
|
|
696
|
+
$.cache = new Cache();
|
|
697
|
+
$.memory = new Memory(); $.h.memoryoff = new Hints($.s.memoryoff);
|
|
840
698
|
$.fn = $.getPage = new GetPage().a;
|
|
841
699
|
$.detScripts = new DetScripts().a;
|
|
842
700
|
$.addAll = new AddAll().a;
|
|
843
701
|
$.Rq = new RQ().a;
|
|
844
702
|
return true;
|
|
845
|
-
}
|
|
703
|
+
};
|
|
846
704
|
$.init(); // initialize Ajaxify on definition
|
|
847
|
-
}}
|
|
705
|
+
}}
|
|
706
|
+
|
|
707
|
+
// The stateful Cache class
|
|
708
|
+
// this.d = entire current page (as an object)
|
|
709
|
+
class Cache {
|
|
710
|
+
g(){ return this.d } //getter
|
|
711
|
+
s(v){ return this.d = v } //setter
|
|
712
|
+
l(u){ let v = $.memory.l(u); return this.s(v === false ? v : $.pages.l(v)) } //lookup URL and load
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
// The stateful Memory class
|
|
716
|
+
// Usage: $.memory.l(<URL>) - returns the same URL if not turned off internally
|
|
717
|
+
class Memory {
|
|
718
|
+
l(h){
|
|
719
|
+
if (!h || $.s.memoryoff === true) return false;
|
|
720
|
+
if ($.s.memoryoff === false) return h;
|
|
721
|
+
return $.h.memoryoff.find(h) ? false : h;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// The stateful Pages class
|
|
726
|
+
// this.d = Array of pages - [0] = URL // [1] = reference to whole page
|
|
727
|
+
class Pages {
|
|
728
|
+
f(){ this.d = [] } //flush
|
|
729
|
+
l(u){ if (this.P(u)) return this.d[this.i][1] } //lookup URL and return page
|
|
730
|
+
p(o){ if(this.P(o[0])) this.d[this.i]=o; else this.d.push(o) } //update or push page passed as an object
|
|
731
|
+
P(u){ return (this.i = this.d.findIndex(e => e[0] == u)) + 1 } //lookup page index and store in "i"
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// The Offsets class
|
|
735
|
+
// this.d = Array of pages - [0] = URL // [1] = offset
|
|
736
|
+
class Offsets {
|
|
737
|
+
f(){ this.d = [] } //flush internal offsets array - must be performed by parent
|
|
738
|
+
l(h){ if(h.iO("?")) h = h.split("?")[0]; //lookup page offset
|
|
739
|
+
return this.O(h) ? this.d[this.i][1] : 0; //return if found otherwise 0
|
|
740
|
+
}
|
|
741
|
+
p(h){ let us1 = h.iO("?") ? h.split("?")[0] : h, //initialise all helper variables in one go
|
|
742
|
+
us = us1.iO("#") ? us1.split("#")[0] : us1,
|
|
743
|
+
os = [us, (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop];
|
|
744
|
+
if(this.O(us)) this.d[this.i]=os; else this.d.push(os); // update if found, otherwise push
|
|
745
|
+
}
|
|
746
|
+
O(h){ return (this.i = this.d.findIndex(e => e[0] == h)) + 1 } //find URL in internal array - add 1 for convenience
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// The Scrolly class
|
|
750
|
+
// operates on $.currentURL
|
|
751
|
+
class Scrolly { constructor() { if ('scrollRestoration' in history) history.scrollRestoration = 'manual' }
|
|
752
|
+
p(){ $.s.scrolltop == "s" && $.offsets.p($.currentURL) }
|
|
753
|
+
l(){ let o = $.currentURL;
|
|
754
|
+
if(o.iO("#") && (o.iO("#") < o.length - 1)) { //if hash in URL and not standalone hash
|
|
755
|
+
let $el = qs("#" + o.split("#")[1]); //fetch the element
|
|
756
|
+
if (!$el) return; //nothing found -> return quickly
|
|
757
|
+
let box = $el.getBoundingClientRect();
|
|
758
|
+
return this.s(box.top + window.pageYOffset - document.documentElement.clientTop); // ...animate to ID
|
|
759
|
+
}
|
|
760
|
+
if($.s.scrolltop == "s") this.s($.offsets.l(o)); //smart scroll -> lookup and restore offset
|
|
761
|
+
else $.s.scrolltop && this.s(0); //scrolltop true -> scroll to top of page
|
|
762
|
+
}
|
|
763
|
+
s(o){ setTimeout(() => window.scrollTo(0, o), 10) } //scroll to offset with small timeout
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// The HAPi class
|
|
767
|
+
// operates on $.currentURL - manages operations on the History API centrally(replaceState / pushState)
|
|
768
|
+
class HApi {
|
|
769
|
+
r(h){ let c = this.u(h); history.replaceState({ url: c }, "state-" + c, c); } //perform replaceState
|
|
770
|
+
p(h){ let c = this.u(h); if (c !== window.location.href) history.pushState({ url: c }, "state-" + c, c); } //perform pushState
|
|
771
|
+
u(h){ if(h) $.currentURL = h; return $.currentURL; } //update currentURL if given and return always
|
|
772
|
+
}
|
package/ajaxify.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class Ajaxify{constructor(options){String.prototype.iO=function(t){return this.toString().indexOf(t)+1};let $=this;$.s={elements:"body",selector:"a:not(.no-ajaxy)",forms:"form:not(.no-ajaxy)",canonical:!1,refresh:!1,requestDelay:0,scrolltop:"s",bodyClasses:!1,deltas:!0,asyncdef:!0,alwayshints:!1,inline:!0,inlinesync:!0,inlinehints:!1,inlineskip:"adsbygoogle",inlineappend:!0,intevents:!0,style:!0,prefetchoff:!1,verbosity:0,memoryoff:!1,cb:0,pluginon:!0,passCount:!1},$.pass=0,$.currentURL="",$.parse=((t,e)=>(e=document.createElement("div"),e.insertAdjacentHTML("afterbegin",t),e.firstElementChild)),$.trigger=((t,e)=>{let r=document.createEvent("HTMLEvents");r.initEvent("pronto."+t,!0,!1),r.data=e||$.Rq("e"),window.dispatchEvent(r),document.dispatchEvent(r)}),$.internal=(t=>!!t&&("object"==typeof t&&(t=t.href),""===t||(t.substring(0,rootUrl.length)===rootUrl||!t.iO(":")))),$.intevents=(()=>{EventTarget.prototype.ael=EventTarget.prototype.addEventListener,EventTarget.prototype.addEventListener=function(t,e,r=!1){this!==document&&this!==window||"DOMContentLoaded"!=t?this.ael(t,e,r):setTimeout(e)}});let rootUrl=location.origin,api=window.history&&window.history.pushState&&window.history.replaceState,docType=/<\!DOCTYPE[^>]*>/i,tagso=/<(html|head|link)([\s\>])/gi,tagsod=/<(body)([\s\>])/gi,tagsc=/<\/(html|head|body|link)\>/gi,div12='<div class="ajy-$1"$2',divid12='<div id="ajy-$1"$2',linki='<link rel="stylesheet" type="text/css" href="*" />',linkr='link[href*="!"]',scrr='script[src*="!"]',inlineclass="ajy-inline",doc=document,bdy,qa=(t,e=doc)=>e.querySelectorAll(t),qs=(t,e=doc)=>e.querySelector(t);function _copyAttributes(t,e,r){r&&[...t.attributes].forEach(e=>t.removeAttribute(e.name)),[...e.attributes].forEach(e=>t.setAttribute(e.nodeName,e.nodeValue))}function _on(t,e,r,n=document){n.addEventListener(t,function(t){for(var n=t.target;n&&n!=this;n=n.parentNode)if(n.matches(e)){r(n,t);break}},!!t.iO("mo"))}function Hints(t){if(!(this instanceof Hints))return new Hints(t);this.myHints="string"==typeof t&&t.length>0&&t.split(", ")}function lg(t){$.s.verbosity&&console&&console.log(t)}Hints.prototype.find=function(t){return!(!t||!this.myHints)&&this.myHints.some(e=>t.iO(e))};class Cache{constructor(){let t=!1;this.a=function(e){return e?"string"==typeof e?("f"===e?($.pages("f"),lg("Cache flushed")):t=$.pages($.memory(e)),t):"object"==typeof e?t=e:void 0:t}}}class Memory{constructor(t){this.a=function(t){return!(!t||!0===$.s.memoryoff)&&(!1===$.s.memoryoff?t:!Hints($.s.memoryoff).find(t)&&t)}}}class Pages{constructor(){let t=[],e=-1;this.a=function(n){if("string"==typeof n)if("f"===n)t=[];else if(-1!==(e=r(n)))return t[e][1];if("object"==typeof n&&(-1===(e=r(n))?t.push(n):t[e]=n),"boolean"==typeof n)return!1};let r=e=>t.findIndex(t=>t[0]==e)}}class GetPage{constructor(){let t=0,e=0,r=0,n="",s=0,i=0,o=0;this.a=function(s,l,d){if(!s)return $.cache();if(s.iO("/")){if(e=l,r==s)return;return c(s)}if("+"===s)return r=l,e=d,c(l,!0);if("a"!==s){if("s"===s)return(i?1:0)+n;if("-"===s)return a(l);if("x"===s)return t;if($.cache())return"body"===s?qs("#ajy-"+s,$.cache()):"script"===s?qa(s,$.cache()):qs("title"===s?s:".ajy-"+s,$.cache())}else i>0&&(p(),o.abort())};let a=t=>($.pass++,d(t),qa("body > script").forEach(t=>!!t.classList.contains(inlineclass)&&t.parentNode.removeChild(t)),$.scripts(!0),$.scripts("s"),$.scripts("c")),c=(t,n)=>(t.iO("#")&&(t=t.split("#")[0]),$.Rq("is")||!$.cache(t)?u(t,n):(r=0,e?e():void 0)),l=(t,e)=>{if(e){var r=e.cloneNode(!0);qa("script",r).forEach(t=>t.parentNode.removeChild(t)),_copyAttributes(t,r,!0),t.innerHTML=r.innerHTML}else{lg("Inserting placeholder for ID: "+t.getAttribute("id"));var n=t.tagName.toLowerCase();t.parentNode.replaceChild($.parse("<"+n+" id='"+t.getAttribute("id")+"'></"+n+">"),t)}},d=t=>$.cache()&&!f(t)&&t.forEach(function(t){l(t,qs("#"+t.getAttribute("id"),$.cache()))}),f=t=>"body"==t[0].tagName.toLowerCase()&&(l(bdy,qs("#ajy-body",$.cache())),1),u=(e,r)=>{var s=$.Rq("is");n=r?"p":"c",o=new AbortController,i++,fetch(e,{method:s?"POST":"GET",cache:"default",mode:"same-origin",headers:{"X-Requested-With":"XMLHttpRequest"},body:s?$.Rq("d"):null,signal:o.signal}).then(n=>{if(n.ok&&y(n))return t=n,n.text();r||(location.href=e,p(),$.pronto(0,$.currentURL))}).then(r=>{if(p(1),r)return t.responseText=r,h(e,r)}).catch(t=>{if("AbortError"!==t.name)try{return $.trigger("error",t),lg("Response text : "+t.message),h(e,t.message,t)}catch(t){}}).finally(()=>i--)},p=t=>(r=0,t?0:e=0),h=(t,r,n)=>$.cache($.parse(g(r)))&&($.pages([t,$.cache()]),1)&&e&&e(n),y=t=>(s=t.headers.get("content-type"))&&(s.iO("html")||s.iO("form-")),g=t=>document.createElement("html").innerHTML=m(t).trim(),m=t=>String(t).replace(docType,"").replace(tagso,div12).replace(tagsod,divid12).replace(tagsc,"</div>")}}class Scripts{constructor(){let $s=!1,txt=0;this.a=function(t){return"i"===t?($s||($s={}),!0):"s"===t?_allstyle($s.y):"1"===t?($.detScripts($s),_addScripts($s)):"c"===t?!(!$.s.canonical||!$s.can)&&$s.can.getAttribute("href"):"d"===t?$.detScripts($s):t&&"object"==typeof t?_onetxt(t):void($.scripts("d")||_addScripts($s))};let _allstyle=t=>!$.s.style||!t||(qa("style",qs("head")).forEach(t=>t.parentNode.removeChild(t)),t.forEach(t=>_addstyle(t.textContent))),_onetxt=t=>!(txt=t.textContent).iO(").ajaxify(")&&!txt.iO("new Ajaxify(")&&($.s.inline&&!Hints($.s.inlineskip).find(txt)||t.classList.contains("ajaxy")||Hints($.s.inlinehints).find(txt))&&_addtxt(t),_addtxt=$s=>{if(txt&&txt.length){if($.s.inlineappend||$s.getAttribute("type")&&!$s.getAttribute("type").iO("text/javascript"))try{return _apptxt($s)}catch(t){}try{eval(txt)}catch(t){lg("Error in inline script : "+txt+"\nError code : "+t)}}},_apptxt=t=>{let e=document.createElement("script");_copyAttributes(e,t),e.classList.add(inlineclass);try{e.appendChild(document.createTextNode(t.textContent))}catch(r){e.text=t.textContent}return qs("body").appendChild(e)},_addstyle=t=>qs("head").appendChild($.parse("<style>"+t+"</style>")),_addScripts=t=>($.addAll(t.c,"href"),$.s.inlinesync?setTimeout(()=>$.addAll(t.j,"src")):$.addAll(t.j,"src"))}}class DetScripts{constructor(){let t=0,e=0,r=0;this.a=function(s){if(!(t=$.pass?$.fn("head"):qs("head")))return!0;e=qa($.pass?".ajy-link":"link",t),r=$.pass?$.fn("script"):qa("script"),s.c=n(e,"stylesheet"),s.y=qa("style",t),s.can=n(e,"canonical"),s.j=r};let n=(t,e)=>Array.prototype.filter.call(t,t=>t.getAttribute("rel").iO(e))}}class AddAll{constructor(){let t=[],e=[],r=[],n=0,s=0;this.a=function(d,f){if(d.length){if("n"===$.s.deltas)return!0;if(n=f,!$.s.deltas)return i(d);t="href"==n?e:r,$.pass?d.forEach(function(e){var r=e;if(s=r.getAttribute(n),a(r))return l(),void c(r);s?t.some(t=>t==s)||(t.push(s),c(r)):"href"==n||r.classList.contains("no-ajaxy")||$.scripts(r)}):o(d)}};let i=t=>t.forEach(t=>c(t)),o=e=>e.forEach(e=>(s=e.getAttribute(n))?t.push(s):0),a=t=>"always"==t.getAttribute("data-class")||Hints($.s.alwayshints).find(s),c=t=>{if(s=t.getAttribute(n),"href"==n)return qs("head").appendChild($.parse(linki.replace("*",s)));if(!s)return $.scripts(t);var e=document.createElement("script");e.async=$.s.asyncdef,_copyAttributes(e,t),qs("head").appendChild(e)},l=()=>qa(("href"==n?linkr:scrr).replace("!",s)).forEach(t=>t.parentNode.removeChild(t))}}class RQ{constructor(){let t=0,e=0,r=0,n=0,s=0,i=0,o=!1;this.a=function(c,l,d){if("="===c)return l?i===$.currentURL||i===o:i===$.currentURL;if("!"===c)return o=i;if("?"===c){let t=$.fn("s");return t.iO("0")||l||$.fn("a"),"1c"===t&&l?!1:("1p"===t&&l&&(!$.s.memoryoff||$.fn("a")),!0)}if("v"===c){if(!l)return!1;if(a(l,d),!$.internal(i))return!1;c="i"}return"i"===c?(t=!1,e=null,r=!0,n=!1,i):"h"===c?(l&&("string"==typeof l&&(s=0),i=l.href?l.href:l),i):"e"===c?(l&&a(l,d),s||i):"p"===c?(void 0!==l&&(r=l),r):"is"===c?(void 0!==l&&(t=l),t):"d"===c?(l&&(e=l),e):"C"===c?(void 0!==l&&(n=l),n):"c"===c?!n||n===l||l.iO("#")||l.iO("?")?l:n:void 0};let a=(t,e)=>i="string"!=typeof(s=t)?s.currentTarget&&s.currentTarget.href||e&&e.href||s.currentTarget.action||s.originalEvent.state.url:s}}class Frms{constructor(){let t=0,e=0;this.a=function(s,i){$.s.forms&&s&&("d"===s&&(e=i),"a"===s&&e.forEach(e=>{Array.prototype.filter.call(qa($.s.forms,e),function(t){let e=t.getAttribute("action");return $.internal(e&&e.length>0?e:$.currentURL)}).forEach(e=>{e.addEventListener("submit",e=>{t=e.target,i=r();var s="get",o=t.getAttribute("method");o.length>0&&"post"==o.toLowerCase()&&(s="post");var a,c=t.getAttribute("action");return a=c&&c.length>0?c:$.currentURL,$.Rq("v",e),"get"==s?a=n(a,i):($.Rq("is",!0),$.Rq("d",i)),$.trigger("submit",a),$.pronto(0,{href:a}),e.preventDefault(),!1})})}))};let r=()=>{let e=new FormData(t),r=qs("input[name][type=submit]",t);return r&&e.append(r.getAttribute("name"),r.value),e},n=(t,e)=>{let r="";for(var[n,s]of(t.iO("?")&&(t=t.substring(0,t.iO("?"))),e.entries()))r+=`${n}=${encodeURIComponent(s)}&`;return`${t}?${r.slice(0,-1)}`}}}class Offsets{constructor(){let t=[],e=-1;this.a=function(n){if("string"==typeof n)return n=n.iO("?")?n.split("?")[0]:n,-1===(e=r(n))?0:t[e][1];var s=$.currentURL,i=s.iO("?")?s.split("?")[0]:s,o=i.iO("#")?i.split("#")[0]:i,a=[o,document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop];-1===(e=r(o))?t.push(a):t[e]=a};let r=e=>t.findIndex(t=>t[0]==e)}}class Scrolly{constructor(){this.a=function(e){if(e){var r=e;if("+"!==e&&"!"!==e||(e=$.currentURL),"+"!==r&&e.iO("#")&&e.iO("#")<e.length-1){let r=qs("#"+e.split("#")[1]);if(!r)return;let n=r.getBoundingClientRect();t(n.top+window.pageYOffset-document.documentElement.clientTop)}else{if("s"===$.s.scrolltop)return"+"===r&&$.offsets(),void("!"===r&&t($.offsets(e)));"+"!==r&&$.s.scrolltop&&t(0)}}};let t=t=>window.scrollTo(0,t)}}class HApi{constructor(){this.a=function(t,e){t&&(e&&($.currentURL=e),"="===t?history.replaceState({url:$.currentURL},"state-"+$.currentURL,$.currentURL):$.currentURL!==window.location.href&&history.pushState({url:$.currentURL},"state-"+$.currentURL,$.currentURL))}}}class Pronto{constructor(){let t=0,e=0,r=0;this.a=function(e,r){if(r)return"i"===r?(bdy=document.body,e.length||(e="body"),t=qa(e),$.frms=(new Frms).a,$.s.idleTime&&($.slides=new classSlides($).a),$.scrolly=(new Scrolly).a,$.offsets=(new Offsets).a,$.hApi=(new HApi).a,n(),e):"object"==typeof r?($.Rq("h",r),void c()):void(r.iO("/")&&($.Rq("h",r),c(!0)))};let n=()=>{$.hApi("=",window.location.href),window.addEventListener("popstate",d),!0!==$.s.prefetchoff&&(_on("mouseenter",$.s.selector,s),_on("mouseleave",$.s.selector,i),_on("touchstart",$.s.selector,o)),_on("click",$.s.selector,a,bdy),$.frms("d",qa("body")),$.frms("a"),$.frms("d",t),$.s.idleTime&&$.slides("i")},s=(t,e)=>r=setTimeout(()=>o(t,e),150),i=()=>clearTimeout(r),o=(t,e)=>{if(!0!==$.s.prefetchoff&&$.Rq("?",!0)){var r=$.Rq("v",e,t);$.Rq("=",!0)||!r||Hints($.s.prefetchoff).find(r)||$.fn("+",r,()=>!1)}},a=(t,e,r)=>{if($.Rq("?")){var n=$.Rq("v",e,t);if(n&&!p(t)){if("#"===n.substr(-1))return!0;if(h())return $.hApi("=",n),!0;$.scrolly("+"),(t=>(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))(e),$.Rq("=")&&$.hApi("="),!$.s.refresh&&$.Rq("=")||c(r)}}},c=t=>{$.Rq("!"),t&&$.Rq("p",!1),$.trigger("request"),$.fn($.Rq("h"),t=>{t&&(lg("Error in _request : "+t),$.trigger("error",t)),l()})},l=()=>{$.trigger("beforeload"),$.s.requestDelay?(e&&clearTimeout(e),e=setTimeout(f,$.s.requestDelay)):f()},d=t=>{var e=window.location.href;$.Rq("i"),$.Rq("h",e),$.Rq("p",!1),$.scrolly("+"),e&&e!==$.currentURL&&($.trigger("request"),$.fn(e,l))},f=()=>{if($.trigger("load"),$.s.bodyClasses){var e=$.fn("body").getAttribute("class");bdy.setAttribute("class",e||"")}var r,n=$.Rq("h");n=$.Rq("c",n),$.hApi($.Rq("p")?"+":"=",n),(r=$.fn("title"))&&(qs("title").innerHTML=r.innerHTML),$.Rq("C",$.fn("-",t)),$.frms("a"),$.scrolly("!"),u(n),$.trigger("render"),$.s.passCount&&(qs("#"+$.s.passCount).innerHTML="Pass: "+$.pass),$.s.cb&&$.s.cb()},u=t=>{t="/"+t.replace(rootUrl,""),void 0!==window.ga?window.ga("send","pageview",t):void 0!==window._gaq&&window._gaq.push(["_trackPageview",t])},p=t=>{var e=$.Rq("h"),r=$.Rq("e"),n=r.currentTarget.target||t.target;return r.which>1||r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||"_blank"===n||e.iO("wp-login")||e.iO("wp-admin")},h=()=>{var t=$.Rq("e");return t.hash&&t.href.replace(t.hash,"")===window.location.href.replace(location.hash,"")||t.href===window.location.href+"#"}}}$.init=(()=>{let t=options;return t&&"string"==typeof t?$.pronto(0,t):("complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?run():document.addEventListener("DOMContentLoaded",run),$)});let run=()=>{$.s=Object.assign($.s,options),$.pages=(new Pages).a,$.pronto=(new Pronto).a,load()&&($.pronto($.s.elements,"i"),$.s.deltas&&$.scripts("1"))},load=()=>api&&$.s.pluginon?(lg("Ajaxify loaded..."),$.s.intevents&&$.intevents(),$.scripts=(new Scripts).a,$.scripts("i"),$.cache=(new Cache).a,$.memory=(new Memory).a,$.fn=$.getPage=(new GetPage).a,$.detScripts=(new DetScripts).a,$.addAll=(new AddAll).a,$.Rq=(new RQ).a,!0):(lg("Gracefully exiting..."),!1);$.init()}}
|
|
1
|
+
let $,rootUrl=location.origin,inlineclass="ajy-inline",bdy,qa=(t,e=document)=>e.querySelectorAll(t),qs=(t,e=document)=>e.querySelector(t);class Ajaxify{constructor(options){function _copyAttributes(t,e,r){r&&[...t.attributes].forEach(e=>t.removeAttribute(e.name)),[...e.attributes].forEach(e=>t.setAttribute(e.nodeName,e.nodeValue))}function _on(t,e,r,s=document){s.addEventListener(t,function(t){for(var s=t.target;s&&s!=this;s=s.parentNode)if(s.matches(e)){r(s,t);break}},!!t.iO("mo"))}String.prototype.iO=function(t){return this.toString().indexOf(t)+1},$=this,$.s={elements:"body",selector:"a:not(.no-ajaxy)",forms:"form:not(.no-ajaxy)",canonical:!1,refresh:!1,requestDelay:0,scrolltop:"s",bodyClasses:!1,deltas:!0,asyncdef:!0,alwayshints:!1,inline:!0,inlinehints:!1,inlineskip:"adsbygoogle",inlineappend:!0,intevents:!0,style:!0,prefetchoff:!1,verbosity:0,memoryoff:!1,cb:0,pluginon:!0,passCount:!1},$.pass=0,$.currentURL="",$.h={},$.parse=((t,e)=>(e=document.createElement("div"),e.insertAdjacentHTML("afterbegin",t),e.firstElementChild)),$.trigger=((t,e)=>{let r=document.createEvent("HTMLEvents");r.initEvent("pronto."+t,!0,!1),r.data=e||$.Rq("e"),window.dispatchEvent(r),document.dispatchEvent(r)}),$.internal=(t=>!!t&&("object"==typeof t&&(t=t.href),""===t||(t.substring(0,rootUrl.length)===rootUrl||!t.iO(":")))),$.intevents=(()=>{EventTarget.prototype.ael=EventTarget.prototype.addEventListener,EventTarget.prototype.addEventListener=function(t,e,r=!1){this!==document&&this!==window||"DOMContentLoaded"!=t?this.ael(t,e,r):setTimeout(e)}});class Hints{constructor(t){let e=this;e.list="string"==typeof t&&t.length>0&&t.split(", "),e.find=(t=>!(!t||!e.list)&&e.list.some(e=>t.iO(e)))}}function lg(t){$.s.verbosity&&console&&console.log(t)}class GetPage{constructor(){let t=0,e=0,r=0,s="",i=0,n=0,o=0,a=/<\!DOCTYPE[^>]*>/i,l=/<(html|head|link)([\s\>])/gi,c=/<(body)([\s\>])/gi,d=/<\/(html|head|body|link)\>/gi;this.a=function(i,a,l){if(!i)return $.cache.g();if(i.iO("/")){if(e=a,r==i)return;return f(i)}if("+"===i)return r=a,e=l,f(a,!0);if("a"!==i){if("s"===i)return(n?1:0)+s;if("-"===i)return h(a);if("x"===i)return t;if($.cache.g())return"body"===i?qs("#ajy-"+i,$.cache.g()):"script"===i?qa(i,$.cache.g()):qs("title"===i?i:".ajy-"+i,$.cache.g())}else n>0&&(m(),o.abort())};let h=t=>($.pass++,u(t),qa("body > script").forEach(t=>!!t.classList.contains(inlineclass)&&t.parentNode.removeChild(t)),$.scripts(!0),$.scripts("s"),$.scripts("c")),f=(t,s)=>(t.iO("#")&&(t=t.split("#")[0]),$.Rq("is")||!$.cache.l(t)?g(t,s):(r=0,e?e():void 0)),p=(t,e)=>{if(e){var r=e.cloneNode(!0);qa("script",r).forEach(t=>t.parentNode.removeChild(t)),_copyAttributes(t,r,!0),t.innerHTML=r.innerHTML}},u=t=>$.cache.g()&&!y(t)&&t.forEach(function(t){p(t,qs("#"+t.getAttribute("id"),$.cache.g()))}),y=t=>"body"==t[0].tagName.toLowerCase()&&(p(bdy,qs("#ajy-body",$.cache.g())),1),g=(e,r)=>{var i=$.Rq("is");s=r?"p":"c",o=new AbortController,n++,fetch(e,{method:i?"POST":"GET",cache:"default",mode:"same-origin",headers:{"X-Requested-With":"XMLHttpRequest"},body:i?$.Rq("d"):null,signal:o.signal}).then(s=>{if(s.ok&&v(s))return t=s,s.text();r||(location.href=e,m(),$.pronto(0,$.currentURL))}).then(r=>{if(m(1),r)return t.responseText=r,q(e,r)}).catch(t=>{if("AbortError"!==t.name)try{return $.trigger("error",t),lg("Response text : "+t.message),q(e,t.message,t)}catch(t){}}).finally(()=>n--)},m=t=>(r=0,t?0:e=0),q=(t,r,s)=>$.cache.s($.parse(w(r)))&&($.pages.p([t,$.cache.g()]),1)&&e&&e(s),v=t=>(i=t.headers.get("content-type"))&&(i.iO("html")||i.iO("form-")),w=t=>document.createElement("html").innerHTML=b(t).trim(),b=t=>String(t).replace(a,"").replace(l,'<div class="ajy-$1"$2').replace(c,'<div id="ajy-$1"$2').replace(d,"</div>")}}class Scripts{constructor(){let $s=!1,txt=0;$.h.inlinehints=new Hints($.s.inlinehints),$.h.inlineskip=new Hints($.s.inlineskip),this.a=function(t){return"i"===t?($s||($s={}),!0):"s"===t?_allstyle($s.y):"1"===t?($.detScripts($s),_addScripts($s)):"c"===t?!(!$.s.canonical||!$s.can)&&$s.can.getAttribute("href"):"d"===t?$.detScripts($s):t&&"object"==typeof t?_onetxt(t):void($.scripts("d")||_addScripts($s))};let _allstyle=t=>!$.s.style||!t||(qa("style",qs("head")).forEach(t=>t.parentNode.removeChild(t)),t.forEach(t=>_addstyle(t.textContent))),_onetxt=t=>!(txt=t.textContent).iO(").ajaxify(")&&!txt.iO("new Ajaxify(")&&($.s.inline&&!$.h.inlineskip.find(txt)||t.classList.contains("ajaxy")||$.h.inlinehints.find(txt))&&_addtxt(t),_addtxt=$s=>{if(txt&&txt.length){if($.s.inlineappend||$s.getAttribute("type")&&!$s.getAttribute("type").iO("text/javascript"))try{return _apptxt($s)}catch(t){}try{eval(txt)}catch(t){lg("Error in inline script : "+txt+"\nError code : "+t)}}},_apptxt=t=>{let e=document.createElement("script");_copyAttributes(e,t),e.classList.add(inlineclass);try{e.appendChild(document.createTextNode(t.textContent))}catch(r){e.text=t.textContent}return qs("body").appendChild(e)},_addstyle=t=>qs("head").appendChild($.parse("<style>"+t+"</style>")),_addScripts=t=>($.addAll(t.c,"href"),$.addAll(t.j,"src"))}}class DetScripts{constructor(){let t=0,e=0,r=0;this.a=function(i){if(!(t=$.pass?$.fn("head"):qs("head")))return!0;e=qa($.pass?".ajy-link":"link",t),r=$.pass?$.fn("script"):qa("script"),i.c=s(e,"stylesheet"),i.y=qa("style",t),i.can=s(e,"canonical"),i.j=r};let s=(t,e)=>Array.prototype.filter.call(t,t=>t.getAttribute("rel").iO(e))}}class AddAll{constructor(){let t=[],e=[],r=[],s=0,i=0;$.h.alwayshints=new Hints($.s.alwayshints),this.a=function(d,h){if(d.length){if("n"===$.s.deltas)return!0;if(s=h,!$.s.deltas)return n(d);t="href"==s?e:r,$.pass?d.forEach(function(e){var r=e;if(i=r.getAttribute(s),a(r))return c(),void l(r);i?t.some(t=>t==i)||(t.push(i),l(r)):"href"==s||r.classList.contains("no-ajaxy")||$.scripts(r)}):o(d)}};let n=t=>t.forEach(t=>l(t)),o=e=>e.forEach(e=>(i=e.getAttribute(s))?t.push(i):0),a=t=>"always"==t.getAttribute("data-class")||$.h.alwayshints.find(i),l=t=>{if(i=t.getAttribute(s),"href"==s)return qs("head").appendChild($.parse('<link rel="stylesheet" type="text/css" href="*" />'.replace("*",i)));if(!i)return $.scripts(t);var e=document.createElement("script");e.async=$.s.asyncdef,_copyAttributes(e,t),qs("head").appendChild(e)},c=()=>qa(("href"==s?'link[href*="!"]':'script[src*="!"]').replace("!",i)).forEach(t=>t.parentNode.removeChild(t))}}class RQ{constructor(){let t=0,e=0,r=0,s=0,i=0,n=0,o=!1;this.a=function(l,c,d){if("="===l)return c?n===$.currentURL||n===o:n===$.currentURL;if("!"===l)return o=n;if("?"===l){let t=$.fn("s");return t.iO("0")||c||$.fn("a"),"1c"===t&&c?!1:("1p"===t&&c&&(!$.s.memoryoff||$.fn("a")),!0)}if("v"===l){if(!c)return!1;if(a(c,d),!$.internal(n))return!1;l="i"}return"i"===l?(t=!1,e=null,r=!0,s=!1,n):"h"===l?(c&&("string"==typeof c&&(i=0),n=c.href?c.href:c),n):"e"===l?(c&&a(c,d),i||n):"p"===l?(void 0!==c&&(r=c),r):"is"===l?(void 0!==c&&(t=c),t):"d"===l?(c&&(e=c),e):"C"===l?(void 0!==c&&(s=c),s):"c"===l?!s||s===c||c.iO("#")||c.iO("?")?c:s:void 0};let a=(t,e)=>n="string"!=typeof(i=t)?i.currentTarget&&i.currentTarget.href||e&&e.href||i.currentTarget.action||i.originalEvent.state.url:i}}class Frms{constructor(){let t=0,e=0;this.a=function(i,n){$.s.forms&&i&&("d"===i&&(e=n),"a"===i&&e.forEach(e=>{Array.prototype.filter.call(qa($.s.forms,e),function(t){let e=t.getAttribute("action");return $.internal(e&&e.length>0?e:$.currentURL)}).forEach(e=>{e.addEventListener("submit",e=>{t=e.target,n=r();var i="get",o=t.getAttribute("method");o.length>0&&"post"==o.toLowerCase()&&(i="post");var a,l=t.getAttribute("action");return a=l&&l.length>0?l:$.currentURL,$.Rq("v",e),"get"==i?a=s(a,n):($.Rq("is",!0),$.Rq("d",n)),$.trigger("submit",a),$.pronto(0,{href:a}),e.preventDefault(),!1})})}))};let r=()=>{let e=new FormData(t),r=qs("input[name][type=submit]",t);return r&&e.append(r.getAttribute("name"),r.value),e},s=(t,e)=>{let r="";for(var[s,i]of(t.iO("?")&&(t=t.substring(0,t.iO("?"))),e.entries()))r+=`${s}=${encodeURIComponent(i)}&`;return`${t}?${r.slice(0,-1)}`}}}class Pronto{constructor(){let t=0,e=0,r=0;$.h.prefetchoff=new Hints($.s.prefetchoff),this.a=function(e,r){if(r)return"i"===r?(bdy=document.body,e.length||(e="body"),t=qa(e),$.frms=(new Frms).a,$.s.idleTime&&($.slides=new classSlides($).a),$.scrolly=new Scrolly,($.offsets=new Offsets).f(),$.hApi=new HApi,s(),e):"object"==typeof r?($.Rq("h",r),void l()):void(r.iO("/")&&($.Rq("h",r),l(!0)))};let s=()=>{$.hApi.r(window.location.href),window.addEventListener("popstate",d),!0!==$.s.prefetchoff&&(_on("mouseenter",$.s.selector,i),_on("mouseleave",$.s.selector,n),_on("touchstart",$.s.selector,o)),_on("click",$.s.selector,a,bdy),$.frms("d",qa("body")),$.frms("a"),$.frms("d",t),$.s.idleTime&&$.slides("i")},i=(t,e)=>(n(),r=setTimeout(()=>o(t,e),150)),n=()=>clearTimeout(r),o=(t,e)=>{if(!0!==$.s.prefetchoff&&$.Rq("?",!0)){var r=$.Rq("v",e,t);$.Rq("=",!0)||!r||$.h.prefetchoff.find(r)||$.fn("+",r,()=>!1)}},a=(t,e,r)=>{if($.Rq("?")){var s=$.Rq("v",e,t);if(s&&!p(t)){if("#"===s.substr(-1))return!0;if(u())return $.hApi.r(s),!0;$.scrolly.p(),(t=>(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))(e),$.Rq("=")&&$.hApi.r(),!$.s.refresh&&$.Rq("=")||l(r)}}},l=t=>{$.Rq("!"),t&&$.Rq("p",!1),$.trigger("request"),$.fn($.Rq("h"),t=>{t&&(lg("Error in _request : "+t),$.trigger("error",t)),c()})},c=()=>{$.trigger("beforeload"),$.s.requestDelay?(e&&clearTimeout(e),e=setTimeout(h,$.s.requestDelay)):h()},d=t=>{var e=window.location.href;$.Rq("i"),$.Rq("h",e),$.Rq("p",!1),$.scrolly.p(),e&&e!==$.currentURL&&($.trigger("request"),$.fn(e,c))},h=()=>{if($.trigger("load"),$.s.bodyClasses){var e=$.fn("body").getAttribute("class");bdy.setAttribute("class",e||"")}var r,s=$.Rq("h");s=$.Rq("c",s),$.Rq("p")?$.hApi.p(s):$.hApi.r(s),(r=$.fn("title"))&&(qs("title").innerHTML=r.innerHTML),$.Rq("C",$.fn("-",t)),$.frms("a"),$.scrolly.l(),f(s),$.trigger("render"),$.s.passCount&&(qs("#"+$.s.passCount).innerHTML="Pass: "+$.pass),$.s.cb&&$.s.cb()},f=t=>{t="/"+t.replace(rootUrl,""),void 0!==window.ga?window.ga("send","pageview",t):void 0!==window._gaq&&window._gaq.push(["_trackPageview",t])},p=t=>{var e=$.Rq("h"),r=$.Rq("e"),s=r.currentTarget.target||t.target;return r.which>1||r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||"_blank"===s||e.iO("wp-login")||e.iO("wp-admin")},u=()=>{var t=$.Rq("e");return t.hash&&t.href.replace(t.hash,"")===window.location.href.replace(location.hash,"")||t.href===window.location.href+"#"}}}$.init=(()=>{let t=options;return t&&"string"==typeof t?$.pronto(0,t):("complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?run():document.addEventListener("DOMContentLoaded",run),$)});let run=()=>{$.s=Object.assign($.s,options),($.pages=new Pages).f(),$.pronto=(new Pronto).a,load()&&($.pronto($.s.elements,"i"),$.s.deltas&&$.scripts("1"))},load=()=>window.history&&window.history.pushState&&window.history.replaceState&&$.s.pluginon?(lg("Ajaxify loaded..."),$.s.intevents&&$.intevents(),$.scripts=(new Scripts).a,$.scripts("i"),$.cache=new Cache,$.memory=new Memory,$.h.memoryoff=new Hints($.s.memoryoff),$.fn=$.getPage=(new GetPage).a,$.detScripts=(new DetScripts).a,$.addAll=(new AddAll).a,$.Rq=(new RQ).a,!0):(lg("Gracefully exiting..."),!1);$.init()}}class Cache{g(){return this.d}s(t){return this.d=t}l(t){let e=$.memory.l(t);return this.s(!1===e?e:$.pages.l(e))}}class Memory{l(t){return!(!t||!0===$.s.memoryoff)&&(!1===$.s.memoryoff?t:!$.h.memoryoff.find(t)&&t)}}class Pages{f(){this.d=[]}l(t){if(this.P(t))return this.d[this.i][1]}p(t){this.P(t[0])?this.d[this.i]=t:this.d.push(t)}P(t){return(this.i=this.d.findIndex(e=>e[0]==t))+1}}class Offsets{f(){this.d=[]}l(t){return t.iO("?")&&(t=t.split("?")[0]),this.O(t)?this.d[this.i][1]:0}p(t){let e=t.iO("?")?t.split("?")[0]:t,r=e.iO("#")?e.split("#")[0]:e,s=[r,document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop];this.O(r)?this.d[this.i]=s:this.d.push(s)}O(t){return(this.i=this.d.findIndex(e=>e[0]==t))+1}}class Scrolly{constructor(){"scrollRestoration"in history&&(history.scrollRestoration="manual")}p(){"s"==$.s.scrolltop&&$.offsets.p($.currentURL)}l(){let t=$.currentURL;if(t.iO("#")&&t.iO("#")<t.length-1){let e=qs("#"+t.split("#")[1]);if(!e)return;let r=e.getBoundingClientRect();return this.s(r.top+window.pageYOffset-document.documentElement.clientTop)}"s"==$.s.scrolltop?this.s($.offsets.l(t)):$.s.scrolltop&&this.s(0)}s(t){setTimeout(()=>window.scrollTo(0,t),10)}}class HApi{r(t){let e=this.u(t);history.replaceState({url:e},"state-"+e,e)}p(t){let e=this.u(t);e!==window.location.href&&history.pushState({url:e},"state-"+e,e)}u(t){return t&&($.currentURL=t),$.currentURL}}
|