File: /var/www/dinamo-shop/wp-content/themes/dinamo-shop/assets/js/utility.bundle.js
"use strict";
var AJAX = {
getProducts: function getProducts(searchTerm, hitsCount) {
var pageNumber = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var algolia = algoliasearch(util.algolia.applicationID, util.algolia.APIKey);
var index = algolia.initIndex(util.algolia.createIndexName("webshop_products"));
// console.log("inside ajax page number: ", pageNumber)
var requestData = {
query: searchTerm,
hitsPerPage: hitsCount,
page: pageNumber
};
return new Promise(function (resolve, reject) {
index.search(requestData, function (error, content) {
if (error) {
reject(error);
} else {
resolve(content);
}
});
});
}
};
"use strict";
var util = {
algolia: {
applicationID: "Y71AK704IQ",
APIKey: "06af1cafae2a61556a6e68847fb86e26",
createIndexName: function createIndexName(indexName) {
return window.location.hostname + "_" + indexName;
// return "dinamoshop2019.borealis.biz" + "_" + indexName;
}
},
debounce: function debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this,
args = arguments;
var later = function later() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
};