aboutsummaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2023-11-22 15:06:15 -0500
committertdro <tdro@noreply.example.com>2023-11-22 15:06:15 -0500
commit73462cdf6aedebbc08c62b652c9b81e91a970760 (patch)
treef86ff8f139a8da5f61ef6094a19968285341ca04 /assets/js
parent35f491efb88c9e35e87b719a9e8b1be90c3c5918 (diff)
downloadcanory-73462cdf6aedebbc08c62b652c9b81e91a970760.tar.gz
canory-73462cdf6aedebbc08c62b652c9b81e91a970760.tar.bz2
canory-73462cdf6aedebbc08c62b652c9b81e91a970760.zip
static/js: Disable infinite scroll experiment
Can play around with this later
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/index.js46
1 files changed, 0 insertions, 46 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index 543b5a1..c5f8ba9 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -600,52 +600,6 @@
});
})();
(function() {
- function fetch(url, method, callback) {
- const http = new XMLHttpRequest();
- http.onreadystatechange = function() {
- if (callback && http.readyState === 4 && http.status === 200) {
- callback(http);
- }
- };
- http.open(method, url);
- http.send();
- return http;
- }
- [
- "scroll",
- "DOMContentLoaded"
- ].forEach(function(event) {
- self.addEventListener(event, function() {
- const remaining = Math.abs(document.documentElement.scrollHeight - document.documentElement.clientHeight - document.documentElement.scrollTop);
- const traversed = self.pageYOffset;
- const journey = remaining + traversed;
- const ratio = traversed / journey * 100;
- const threshold = ratio >= 50;
- const pagination = document.querySelector('[data-type="pagination"]');
- if (!pagination) return;
- const main = document.querySelector("main");
- const next = pagination.querySelector('[rel="next"]');
- const end = pagination.querySelector('[rel="last"]').title === "hidden";
- const asynchronous = document.querySelectorAll("[data-type='pagination']").length !== 1;
- if (end || asynchronous) return pagination.remove();
- if (threshold) {
- pagination.remove();
- fetch(next.href, "GET", function(http) {
- const page = new DOMParser().parseFromString(http.responseText, "text/html");
- const items = page.querySelector("main").childNodes;
- const paginate = page.querySelector('[data-type="pagination"]');
- for(let i1 = 0; i1 < items.length; i1++){
- main.appendChild(items[i1]);
- }
- main.after(paginate);
- console.log("Fetch:", next.href, items);
- });
- }
- console.log("r:", remaining, "t:", traversed, "j:", journey, "%:", ratio);
- });
- });
-})();
-(function() {
const relative = new Intl.RelativeTimeFormat("en", {
localeMatcher: "best fit",
numeric: "always",