PageSourceSearch

https://www.citythreads.com/cdn/shop/t/66/assets/ajaxinate.min.js?v=69145893314062996711778488531

js citythreads.com collected 2026-10-03 21:31:08 UTC 5,371 bytes, 146 lines download raw bytes

1'use strict';
2/* ===================================================================================== @preserve =
3 ___  _   _    _
4/   || | | |  | |
5\__  | | | |  | |  __
6/    |/  |/_) |/  /  \_/\/
7\___/|__/| \_/|__/\__/  /\_/
8              |\
9              |/
10Ajaxinate
11version v2.0.4
12https://github.com/Elkfox/Ajaxinate
13Copyright (c) 2017 Elkfox Co Pty Ltd
14https://elkfox.com
15MIT License
16================================================================================================= */
17
18var Ajaxinate = function ajaxinateConstructor(config) {
19  var settings = config || {};
20  /*
21    pagination: Selector of pagination container
22    container: Selector of repeating content
23    offset: 0, offset the number of pixels before the bottom to start loading more on scroll
24    loadingText: 'Loading', The text changed during loading
25    callback: null, function to callback after a new page is loaded
26  */
27
28  var defaultSettings = {
29    method: 'scroll',
30    container: '#AjaxinateContainer',
31    pagination: '#AjaxinatePagination',
32    offset: 0,
33    loadingText: 'Loading',
34    callback: null
35  }; // Merge configs
36
37  this.settings = Object.assign(defaultSettings, settings);
38  this.addScrollListeners = this.addScrollListeners.bind(this);
39  this.addClickListener = this.addClickListener.bind(this);
40  this.checkIfPaginationInView = this.checkIfPaginationInView.bind(this);
41  this.stopMultipleClicks = this.stopMultipleClicks.bind(this);
42  this.removeClickListener = this.removeClickListener.bind(this);
43  this.removeScrollListener = this.removeScrollListener.bind(this);
44  this.destroy = this.destroy.bind(this);
45  this.containerElement = document.querySelector(this.settings.container);
46  this.paginationElement = document.querySelector(this.settings.pagination);
47  this.initialize();
48};
49
50Ajaxinate.prototype.initialize = function initializeTheCorrectFunctionsBasedOnTheMethod() {
51  if (this.containerElement) {
52    var initializers = {
53      click: this.addClickListener,
54      scroll: this.addScrollListeners
55    };
56    initializers[this.settings.method]();
57  }
58};
59
60Ajaxinate.prototype.addScrollListeners = function addEventListenersForScrolling() {
61  if (this.paginationElement) {
62    document.addEventListener('scroll', this.checkIfPaginationInView);
63    window.addEventListener('resize', this.checkIfPaginationInView);
64    window.addEventListener('orientationchange', this.checkIfPaginationInView);
65  }
66};
67
68Ajaxinate.prototype.addClickListener = function addEventListenerForClicking() {
69  if (this.paginationElement) {
70    this.nextPageLinkElement = this.paginationElement.querySelector('a');
71    this.clickActive = true;
72
73    if (typeof this.nextPageLinkElement !== 'undefined' && this.nextPageLinkElement !== null) {
74      this.nextPageLinkElement.addEventListener('click', this.stopMultipleClicks);
75    }
76  }
77};
78
79Ajaxinate.prototype.stopMultipleClicks = function handleClickEvent(event) {
80  event.preventDefault();
81
82  if (this.clickActive) {
83    this.nextPageLinkElement.innerText = this.settings.loadingText;
84    this.nextPageUrl = this.nextPageLinkElement.href;
85    this.clickActive = false;
86    this.loadMore();
87  }
88};
89
90Ajaxinate.prototype.checkIfPaginationInView = function handleScrollEvent() {
91  var top = this.paginationElement.getBoundingClientRect().top - this.settings.offset;
92  var bottom = this.paginationElement.getBoundingClientRect().bottom + this.settings.offset;
93
94  if (top <= window.innerHeight && bottom >= 0) {
95    this.nextPageLinkElement = this.paginationElement.querySelector('a');
96    this.removeScrollListener();
97
98    if (this.nextPageLinkElement) {
99      this.nextPageLinkElement.innerText = this.settings.loadingText;
100      this.nextPageUrl = this.nextPageLinkElement.href;
101      this.loadMore();
102    }
103  }
104};
105
106Ajaxinate.prototype.loadMore = function getTheHtmlOfTheNextPageWithAnAjaxRequest() {
107  this.request = new XMLHttpRequest();
108
109  this.request.onreadystatechange = function success() {
110    if (this.request.readyState === 4 && this.request.status === 200) {
111      var newContainer = this.request.responseXML.querySelectorAll(this.settings.container)[0];
112      var newPagination = this.request.responseXML.querySelectorAll(this.settings.pagination)[0];
113      this.containerElement.insertAdjacentHTML('beforeend', newContainer.innerHTML);
114      this.paginationElement.innerHTML = newPagination.innerHTML;
115
116      if (this.settings.callback && typeof this.settings.callback === 'function') {
117        this.settings.callback(this.request.responseXML);
118      }
119
120      this.initialize();
121    }
122  }.bind(this);
123
124  this.request.open('GET', this.nextPageUrl);
125  this.request.responseType = 'document';
126  this.request.send();
127};
128
129Ajaxinate.prototype.removeClickListener = function removeClickEventListener() {
130  this.nextPageLinkElement.removeEventListener('click', this.stopMultipleClicks);
131};
132
133Ajaxinate.prototype.removeScrollListener = function removeScrollEventListener() {
134  document.removeEventListener('scroll', this.checkIfPaginationInView);
135  window.removeEventListener('resize', this.checkIfPaginationInView);
136  window.removeEventListener('orientationchange', this.checkIfPaginationInView);
137};
138
139Ajaxinate.prototype.destroy = function removeEventListenersAndRemoveThis() {
140  var destroyers = {
141    click: this.removeClickListener,
142    scroll: this.removeScrollListener
143  };
144  destroyers[this.settings.method]();
145  return this;
146};

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.