PageSourceSearch

https://jainkart.in/js/public.catalogproducts.js

js jainkart.in collected 2026-10-02 01:57:13 UTC 2,406 bytes, 103 lines download raw bytes

1var CatalogProducts = {
2  settings: {
3    ajax: false,
4    fetchUrl: false,
5    browserPath: false,
6  },
7
8  params: {
9    jqXHR: false,
10  },
11
12  init: function (settings) {
13    this.settings = $.extend({}, this.settings, settings);
14  },
15
16  getProducts: function (pageNumber) {
17    if (this.params.jqXHR && this.params.jqXHR.readyState !== 4) {
18      this.params.jqXHR.abort();
19    }
20
21    var urlBuilder = createProductsURLBuilder(this.settings.browserPath);
22
23    if (pageNumber) {
24      urlBuilder.addParameter('pagenumber', pageNumber);
25    }
26
27    var beforePayload = {
28      urlBuilder
29    };
30    $(this).trigger({ type: "before", payload: beforePayload });
31
32    this.setBrowserHistory(urlBuilder.build());
33
34    if (!this.settings.ajax) {
35      setLocation(urlBuilder.build());
36    } else {
37      this.setLoadWaiting(1);
38
39      var postData = { ...beforePayload.urlBuilder.params.query };
40      addAntiForgeryToken(postData)
41
42      var self = this;
43      this.params.jqXHR = $.ajax({
44        cache: false,
45        url: this.settings.fetchUrl,
46        type: 'POST',
47        data: postData,
48        success: function (response) {
49          $('.products-wrapper').html(response);
50          $('html, body').animate({ scrollTop: $('.center-2 .page').offset().top }, 'slow');
51          $(self).trigger({ type: "loaded" });
52        },
53        error: function () {
54          $(self).trigger({ type: "error" });
55        },
56        complete: function () {
57          self.setLoadWaiting();
58        }
59      });
60    }
61  },
62
63  setLoadWaiting(enable) {
64    var $busyEl = $('.ajax-products-busy');
65    if (enable) {
66      $busyEl.show();
67    } else {
68      $busyEl.hide();
69    }
70  },
71
72  setBrowserHistory(url) {
73    window.history.replaceState({ path: url }, '', url);
74  }
75}
76
77function createProductsURLBuilder(basePath) {
78  return {
79    params: {
80      basePath: basePath,
81      query: {}
82    },
83
84    addBasePath: function (url) {
85      this.params.basePath = url;
86      return this;
87    },
88
89    addParameter: function (name, value) {
90      this.params.query[name] = value;
91      return this;
92    },
93
94    build: function () {
95      var query = $.param(this.params.query);
96      var url = this.params.basePath;
97
98      return url.indexOf('?') !== -1
99        ? url + '&' + query
100        : url + '?' + query;
101    }
102  }
103}

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.