PageSourceSearch

https://mainzer-carneval-verein.de/wp-content/plugins/woocommerce-…/unit-price-observer-queue.js?ver=3.20.7

js mainzer-carneval-verein.de collected 2026-09-25 00:43:06 UTC 9,141 bytes, 209 lines download raw bytes

1/******/ (function() { // webpackBootstrap
2var __webpack_exports__ = {};
3/*global woocommerce_admin_meta_boxes, woocommerce_admin, accounting, woocommerce_admin_meta_boxes_order */
4window.germanized = window.germanized || {};
5(function ($, germanized) {
6  germanized.unit_price_observer_queue = {
7    queue: {},
8    timeout: null,
9    params: {},
10    request: null,
11    init: function () {
12      this.params = wc_gzd_unit_price_observer_queue_params;
13      this.queue = {};
14      this.queuesInExecution = {};
15      this.latestQueueInExection = '';
16      this.aborted = {};
17      this.timeout = null;
18      this.request = null;
19    },
20    execute: function () {
21      var self = germanized.unit_price_observer_queue,
22        data = [],
23        currentQueueId = Date.now() + '';
24      self.queuesInExecution[currentQueueId] = {
25        ...self.queue
26      };
27      self.latestQueueInExection = currentQueueId;
28      self.queue = {};
29
30      /**
31       * Reverse queue
32       */
33      Object.keys(self.queuesInExecution[currentQueueId]).forEach(function (queueKey) {
34        data = data.concat([{
35          'product_id': self.queuesInExecution[currentQueueId][queueKey].productId,
36          'price': self.queuesInExecution[currentQueueId][queueKey].priceData.price,
37          'price_sale': self.queuesInExecution[currentQueueId][queueKey].priceData.sale_price,
38          'quantity': self.queuesInExecution[currentQueueId][queueKey].priceData.quantity,
39          'is_range': self.queuesInExecution[currentQueueId][queueKey].priceData.hasOwnProperty('is_range') ? self.queuesInExecution[currentQueueId][queueKey].priceData.is_range : false,
40          'key': queueKey
41        }]);
42      });
43      self.request = $.ajax({
44        type: "POST",
45        url: self.params.wc_ajax_url.toString().replace('%%endpoint%%', 'gzd_refresh_unit_price'),
46        data: {
47          'security': self.params.refresh_unit_price_nonce,
48          'products': data,
49          'queue_id': currentQueueId
50        },
51        queueId: currentQueueId,
52        success: function (data) {
53          var xhrQueueId = this.queueId,
54            currentQueue = self.queuesInExecution.hasOwnProperty(xhrQueueId) ? self.queuesInExecution[xhrQueueId] : {},
55            aborted = self.aborted.hasOwnProperty(xhrQueueId) ? self.aborted[xhrQueueId] : {};
56          Object.keys(currentQueue).forEach(function (queueId) {
57            if (!aborted.hasOwnProperty(queueId)) {
58              var current = currentQueue[queueId],
59                observer = current.observer,
60                priceData = current.priceData,
61                priceSelector = current.priceSelector,
62                isPrimary = current.isPrimary,
63                unitPrices = self.getUnitPricesFromMap(priceData.unit_price);
64              if (observer) {
65                if (data.products.hasOwnProperty(queueId)) {
66                  var response = data.products[queueId];
67                  observer.stopObserver(observer, priceSelector);
68
69                  /**
70                   * Do only adjust unit price in case current product id has not changed
71                   * in the meantime (e.g. variation change).
72                   */
73                  if (parseInt(response.product_id) === observer.getCurrentProductId(observer)) {
74                    if (response.hasOwnProperty('unit_price_html')) {
75                      observer.unsetUnitPriceLoading(observer, unitPrices, response.unit_price_html);
76                    } else {
77                      observer.unsetUnitPriceLoading(observer, unitPrices);
78                    }
79                  } else {
80                    observer.unsetUnitPriceLoading(observer, unitPrices);
81                  }
82                  observer.startObserver(observer, priceSelector, isPrimary);
83                } else {
84                  observer.stopObserver(observer, priceSelector);
85                  observer.unsetUnitPriceLoading(observer, unitPrices);
86                  observer.startObserver(observer, priceSelector, isPrimary);
87                }
88              }
89            } else {
90              delete self.aborted[xhrQueueId][queueId];
91            }
92          });
93          delete self.queuesInExecution[xhrQueueId];
94        },
95        error: function () {
96          var xhrQueueId = this.queueId,
97            currentQueue = self.queuesInExecution.hasOwnProperty(xhrQueueId) ? self.queuesInExecution[xhrQueueId] : {},
98            aborted = self.aborted.hasOwnProperty(xhrQueueId) ? self.aborted[xhrQueueId] : {};
99          Object.keys(currentQueue).forEach(function (queueId) {
100            if (!aborted.hasOwnProperty(queueId)) {
101              var current = currentQueue[queueId],
102                observer = current.observer,
103                priceData = current.priceData,
104                priceSelector = current.priceSelector,
105                isPrimary = current.isPrimary,
106                unitPrices = self.getUnitPricesFromMap(priceData.unit_price);
107              if (observer) {
108                observer.stopObserver(observer, priceSelector);
109                observer.unsetUnitPriceLoading(observer, unitPrices);
110                observer.startObserver(observer, priceSelector, isPrimary);
111              }
112            } else {
113              delete self.aborted[xhrQueueId][queueId];
114            }
115          });
116          delete self.queuesInExecution[xhrQueueId];
117        },
118        dataType: 'json'
119      });
120    },
121    getUnitPricesFromMap: function (unitPriceMap) {
122      let unitPrices = [];
123      unitPriceMap.forEach(function (unitPrice) {
124        unitPrices = $.merge(unitPrices, $(unitPrice));
125      });
126      return $(unitPrices);
127    },
128    getQueueKey: function (productId) {
129      return (productId + '').replace(/[^a-zA-Z0-9]/g, '');
130    },
131    getLatestQueueInExecution() {
132      var self = germanized.unit_price_observer_queue;
133      return self.queuesInExecution.hasOwnProperty(self.latestQueueInExection) ? self.queuesInExecution[self.latestQueueInExection] : {};
134    },
135    exists: function (productId) {
136      var self = germanized.unit_price_observer_queue,
137        queueKey = self.getQueueKey(productId);
138      return self.queue.hasOwnProperty(queueKey) || self.getLatestQueueInExecution().hasOwnProperty(queueKey);
139    },
140    get: function (productId) {
141      var self = germanized.unit_price_observer_queue,
142        queueKey = self.getQueueKey(productId),
143        queueInExecution = self.getLatestQueueInExecution().hasOwnProperty(queueKey);
144      if (queueInExecution.hasOwnProperty(queueKey)) {
145        return queueInExecution[queueKey];
146      } else if (self.queue.hasOwnProperty(queueKey)) {
147        return self.queue[queueKey];
148      }
149      return false;
150    },
151    abort: function (productId) {
152      var self = germanized.unit_price_observer_queue,
153        queueKey = self.getQueueKey(productId),
154        latestQueueInExecutionKey = self.latestQueueInExection,
155        latestQueueInExecution = self.queuesInExecution.hasOwnProperty(latestQueueInExecutionKey) ? self.queuesInExecution[latestQueueInExecutionKey] : {};
156      if (latestQueueInExecution.hasOwnProperty(queueKey)) {
157        var current = latestQueueInExecution[queueKey],
158          observer = current.observer,
159          priceData = current.priceData,
160          priceSelector = current.priceSelector,
161          isPrimary = current.isPrimary,
162          unitPrices = self.getUnitPricesFromMap(priceData.unit_price);
163        if (observer) {
164          observer.stopObserver(observer, priceSelector);
165          observer.unsetUnitPriceLoading(observer, unitPrices);
166          observer.startObserver(observer, priceSelector, isPrimary);
167        }
168        if (!self.aborted.hasOwnProperty(latestQueueInExecutionKey)) {
169          self.aborted[latestQueueInExecutionKey] = {};
170        }
171        self.aborted[latestQueueInExecutionKey][queueKey] = current;
172        return true;
173      }
174      return false;
175    },
176    add: function (observer, productId, priceData, priceSelector, isPrimary) {
177      var self = germanized.unit_price_observer_queue,
178        queueKey = self.getQueueKey(productId);
179      if (self.queue.hasOwnProperty(queueKey)) {
180        priceData['unit_price'].each(function (i, obj) {
181          if (!self.queue[queueKey]['priceData']['unit_price'].has(obj)) {
182            self.queue[queueKey]['priceData']['unit_price'].set(obj, obj);
183          }
184        });
185      } else {
186        var unitPrices = new Map();
187        priceData['unit_price'].each(function (i, obj) {
188          unitPrices.set(obj, obj);
189        });
190        priceData['unit_price'] = unitPrices;
191        self.queue[queueKey] = {
192          'productId': productId,
193          'observer': observer,
194          'priceData': priceData,
195          'priceSelector': priceSelector,
196          'isPrimary': isPrimary
197        };
198      }
199      clearTimeout(self.timeout);
200      self.timeout = setTimeout(self.execute, 500);
201    }
202  };
203  $(document).ready(function () {
204    germanized.unit_price_observer_queue.init();
205  });
206})(jQuery, window.germanized);
207((window.germanized = window.germanized || {})["static"] = window.germanized["static"] || {})["unit-price-observer-queue"] = __webpack_exports__;
208/******/ })()
209;

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.