PageSourceSearch

https://www.cumpa.de/wp-content/plugins/cumpa//assets/js/min/cumpa-scripts-min.js?ver=2.5

js cumpa.de collected 2026-10-06 01:47:03 UTC 14,959 bytes, 574 lines download raw bytes

1// Own Functions
2jQuery(document).ready(function ($) {
3	$(document).ready(function () {
4
5		// Download Images
6		$(document).on('click', '#downloadimages', function () {
7			var postId = $(this).data('post_id');
8			// Trigger the download process for the images
9			var labelphotos = $(this).html();
10			$(this).html('<i class="bx bx-loader bx-spin"></i> Bitte warten...');
11			$(this).prop('disabled', true);
12
13
14			$.ajax({
15				url: ajaxcall.url,
16				type: 'POST',
17				data: {
18					action: 'downloadzip',
19					pid: postId,
20					security: ajaxcall.nonce
21				},
22				success: function (response) {
23					/* console.log(response); */
24					if (response) {
25						window.location.href = response
26					} else {
27						alert('Fehler beim Herunterladen der Bilder.');
28					}
29					$('#downloadimages').html(labelphotos);
30					$('#downloadimages').prop('disabled', false);
31				},
32				error: function () {
33					alert('Fehler beim Herunterladen der Bilder.');
34				}
35			});
36		});
37
38		// Generate PDF AJAX
39		$(document).on('click', '#generatepdf', function () {
40			var link = $(this).data('url');
41			printPage(link);
42		});
43
44		function closePrint() {
45			document.body.removeChild(this.__container__);
46		}
47
48		function setPrint() {
49			this.contentWindow.__container__ = this;
50			this.contentWindow.onbeforeunload = closePrint;
51			this.contentWindow.onafterprint = closePrint;
52			this.contentWindow.focus(); // Required for IE
53			this.contentWindow.print();
54		}
55
56		function printPage(sURL) {
57			var oHiddFrame = document.createElement("iframe");
58			oHiddFrame.onload = setPrint;
59			oHiddFrame.style.position = "fixed";
60			oHiddFrame.style.right = "0";
61			oHiddFrame.style.bottom = "0";
62			oHiddFrame.style.width = "0";
63			oHiddFrame.style.height = "0";
64			oHiddFrame.style.border = "0";
65			oHiddFrame.src = sURL;
66			document.body.appendChild(oHiddFrame);
67		}
68
69		/* window.onscroll = function (ev) {
70			if ((window.innerHeight + window.scrollY) >= document.body.scrollHeight) {
71				// you're at the bottom of the page
72				$('#contacter').removeClass('active');
73			} else {
74				$('#contacter').addClass('active');
75			}
76		}; */
77
78		$(document).on('click', '.emailalert', function (e) {
79			e.preventDefault();
80
81			var nonce = ajaxcall.nonce;
82			var pid = $(this).data('id');
83
84			$('body').append('<div id="eaholder"></div><div id="eaform"><div class="sload"><i class="bx bx-loader bx-spin"></i></div></div>');
85			$('body').addClass('stop');
86
87			$.ajax({
88				type: 'post',
89				url: ajaxcall.url,
90				data: {
91					security: nonce,
92					action: 'eaopen',
93					pid: pid,
94				},
95				success: function (result) {
96					$('#eaform').html(result);
97					$('#eaform #emailler').focus();
98				},
99				error: function (result) {
100
101				},
102			});
103		});
104
105		$(document).on('click', '.cancelea, #closeea', function (e) {
106			e.preventDefault();
107			$('#eaform,#eaholder').remove();
108			$('body').removeClass('stop');
109		});
110
111		$(document).on('submit', '#eaform form', function (e) {
112			e.preventDefault();
113			var formel = $(this);
114			var nonce = ajaxcall.nonce;
115
116			var email_for_cookie = $('#emailler', formel).val();
117			var pid = $('#pid', formel).val();
118
119			if (!email_for_cookie || !pid) {
120				return;
121			}
122
123			var submitbtn = formel.find('button[type="submit"]');
124			var submitbtn_html = submitbtn.html();
125
126
127			submitbtn.prop('disabled', true);
128			submitbtn.html('<i class="bx bx-loader bx-spin"></i>');
129
130			cumpa_saveCookie('prefill_email', email_for_cookie, 365);
131
132			/* if ($('input#savename').is(':checked')) {
133				cumpa_saveCookie('prefill_cumpa', email_for_cookie, 365);
134			} else {
135				cumpa_saveCookie('prefill_cumpa', 0, 365);
136			} */
137
138			$.ajax({
139				type: 'post',
140				url: ajaxcall.url,
141				data: {
142					security: nonce,
143					action: 'saveeaalert',
144					email: email_for_cookie,
145					pid: pid,
146				},
147				success: function (result) {
148					$('#eaform #slinner').html(result);
149					$(".emailalert[data-id='" + pid + "']").remove();
150				},
151				error: function (result) {
152
153				},
154			});
155
156		});
157
158
159
160
161		$(document).on('click', '.askforsample, #opencart', function (e) {
162			e.preventDefault();
163
164			var pid = $(this).data('id');
165
166			$('body').append('<div id="sampleholder"></div><div id="sampleform"><div class="sload"><i class="bx bx-loader bx-spin"></i></div></div>');
167			$('body').addClass('stop');
168
169			$.ajax({
170				type: 'post',
171				url: ajaxcall.url,
172				data: {
173					security: ajaxcall.nonce,
174					action: 'addsample',
175					pid: pid,
176				},
177				success: function (result) {
178					$('#sampleform').html(result);
179					outputCart();
180				},
181				error: function (result) {
182
183				},
184			});
185		});
186
187		$(document).on('click', '#closehinter', function (e) {
188			e.preventDefault();
189			$('#pricehinnter, #pricehinnterholder').hide();
190		});
191		/* function roundToTwo(num) {
192			return +(Math.round(num + "e+2") + "e-2");
193		}
194
195		function roundHalfUp(num, precision) {
196			return Math.round((num + Number.EPSILON) * Math.pow(10, precision)) / Math.pow(10, precision);
197		} */
198
199		function roundHalfUp(num) {
200			return Math.ceil(num * 100) / 100;
201		}
202
203		// Liefert für bestimmte Sackgrößen abweichende "Buying Size [bags]"-Bereiche
204		// (Spalte 1). Rabatt und Preis bleiben unverändert. null = Standardbereiche.
205		function cumpaBagRanges(bagsize) {
206			switch (parseInt(bagsize, 10)) {
207				case 30:
208					return ['1-19', '20-39', '40-99', '100-149', '150-199', '200 - 560'];
209				default:
210					return null;
211			}
212		}
213
214		$(document).on('click', '.pricehinnter', function (e) {
215			e.preventDefault();
216			$('#pricehinnter, #pricehinnterholder').show();
217
218
219			var price = parseFloat($(this).parent('div').data('price').replace(',', '.'));
220			var bagRanges = cumpaBagRanges($(this).parent('div').data('bagsize'));
221			var rowIndex = 0;
222
223			// Aktueller Bestand in Saecken - Staffeln mit Untergrenze darueber ausgrauen
224			var realstock = parseInt($(this).parent('div').data('realstock'), 10);
225			if (isNaN(realstock)) {
226				realstock = 0;
227			}
228
229			/* $.each($('#discounttable tr'), function (key, value) {
230				var percent = parseFloat($(this).find('td:nth-child(2)').text().replace(',', '.'));
231				if ($.isNumeric(percent)) {
232					var calculatedprice = price - (price * percent / 100);
233					calculatedprice = roundHalfUp(calculatedprice);
234
235					$(this).find('td:nth-child(3)').text(calculatedprice.toFixed(2).replace('.', ',') + ' € / kg');
236				}
237			}); */
238
239			$.each($('#discounttable tr'), function (key, value) {
240				var percent = parseFloat($(this).find('td:nth-child(2)').text().replace(',', '.'));
241				if ($.isNumeric(percent)) {
242					// Das Modal wird von allen Produkten geteilt: die Original-Bereiche
243					// beim ersten Oeffnen merken und fuer Produkte ohne Sonder-Mapping
244					// wiederherstellen (sonst bleiben z.B. die 30-kg-Bereiche stehen)
245					var td1 = $(this).find('td:nth-child(1)');
246					if (!td1.attr('data-orig-range')) {
247						td1.attr('data-orig-range', td1.text());
248					}
249					if (bagRanges && bagRanges[rowIndex]) {
250						td1.text(bagRanges[rowIndex]);
251					} else {
252						td1.text(td1.attr('data-orig-range'));
253					}
254					rowIndex++;
255
256					// Ausgrau-Status pro Produkt zuruecksetzen und neu setzen
257					$(this).removeClass('discount-unavailable');
258					if (realstock >= 1 && realstock < 999999) {
259						var lower = parseInt($(this).find('td:nth-child(1)').text().trim(), 10);
260						if (!isNaN(lower) && lower > realstock) {
261							$(this).addClass('discount-unavailable');
262						}
263					}
264
265					//var calculatedprice = roundToTwo(price - (price / 100 * percent));
266					if (percent == 0) {
267						var calculatedprice = price;
268						calculatedprice = parseFloat(calculatedprice.toFixed(3));
269					} else {
270						var calculatedprice = price - (price * percent / 100);
271						calculatedprice = parseFloat(calculatedprice.toFixed(3));
272						calculatedprice = Math.ceil(calculatedprice * 100) / 100;
273					}
274
275					$(this).find('td:nth-child(3)').text(calculatedprice.toFixed(2).replace('.', ',') + ' € / kg');
276				}
277			});
278
279
280		});
281		$(document).on('click', '#closehinter_2', function (e) {
282			e.preventDefault();
283			$('#pricehinnter_2, #pricehinnterholder_2').hide();
284		});
285		$(document).on('click', '.pricehinnter_2', function (e) {
286			e.preventDefault();
287			$('#pricehinnter_2, #pricehinnterholder_2').show();
288		});
289
290
291		$(document).on('click', '#closesl, .closesl', function (e) {
292			e.preventDefault();
293			saveArtundGram();
294			$('#sampleform,#sampleholder').remove();
295			$('body').removeClass('stop');
296			outputCart();
297			$('#opencart').removeClass('shaker');
298			$('#opencart').addClass('shaker');
299		});
300		$(document).on('click', '.closeslaq', function (e) {
301			e.preventDefault();
302			location.reload();
303		});
304
305
306		$(document).on('click', '.removesample', function (e) {
307			e.preventDefault();
308			var el = $(this).parents('.slsample');
309
310			el.append('<div class="slload"><i class="bx bx-spin bx-loader"></i></div>');
311
312			var pid = $(this).parents('.slsample').data('sid');
313			var nonce = ajaxcall.nonce;
314
315			$('#opencart').removeClass('shaker');
316			$('#opencart').addClass('shaker');
317
318			/* if (!pid) {
319				return;
320			} */
321
322			$.ajax({
323				type: 'post',
324				url: ajaxcall.url,
325				data: {
326					security: nonce,
327					action: 'removesample',
328					pid: pid,
329				},
330				success: function (result) {
331					el.slideUp();
332					outputCart();
333					el.remove();
334				},
335				error: function (result) {
336
337				},
338			});
339		});
340
341		function selectRoasted(el) {
342			if (el.val() == 2) {
343				el.parents('.artselect').find('.roastedhint').show();
344				el.parents('.artselect').find('.gramm').hide();
345			} else if (el.val() == 1) {
346				el.parents('.artselect').find('.roastedhint').hide();
347				el.parents('.artselect').find('.gramm').show();
348			} else {
349				el.parents('.artselect').find('.roastedhint').hide();
350				el.parents('.artselect').find('.gramm').hide();
351			}
352		}
353
354		$(document).on('change', 'select.gor', function (e) {
355			selectRoasted($(this));
356		});
357
358
359		$(document).on('change', 'select.gor, select.gramm', function (e) {
360			$(this).removeClass('requ');
361			saveArtundGram();
362		});
363
364		function saveArtundGram() {
365			var nonce = ajaxcall.nonce;
366			var formdatas = {};
367
368			$.each($('.slsample'), function (key, value) {
369				var el = $(this);
370				var sid = el.attr('data-sid');
371				if (sid) {
372					if (el.find('select.gor').val() == 1) {
373						formdatas[sid] = [el.find('select.gor').val(), el.find('select.gramm').val()];
374					} else {
375						formdatas[sid] = [el.find('select.gor').val(), 0];
376					}
377				};
378			});
379
380			$.ajax({
381				type: 'post',
382				url: ajaxcall.url,
383				data: {
384					security: nonce,
385					action: 'savesamples',
386					formdata: formdatas,
387				},
388				success: function (result) {
389					console.log(result);
390				},
391				error: function (result) {
392
393				},
394			});
395
396		}
397
398
399		$(document).on('click', '.slnextsteo', function (e) {
400			e.preventDefault();
401
402			var notvalid = false;
403			// Check art
404			$("select.gor").each(function (index, element) {
405				if ($(this).val() == 0) {
406					$(this).addClass('requ');
407					notvalid = true;
408				}
409			});
410			console.log(notvalid);
411
412			saveArtundGram();
413
414			if (notvalid) {
415				return;
416			}
417
418			$('#slinner').slideUp();
419			$('#slinnerform').slideDown();
420		});
421		$(document).on('click', '.backslbtn', function (e) {
422			e.preventDefault();
423			saveArtundGram();
424			$('#slinner').slideDown();
425			$('#slinnerform').slideUp();
426		});
427
428
429		$(document).on('submit', '#slinnerform form', function (e) {
430			e.preventDefault();
431			var formel = $(this);
432			var nonce = ajaxcall.nonce;
433
434			var submitbtn = formel.find('button[type="submit"]');
435			var submitbtn_html = submitbtn.html();
436			var formdata = {};
437
438
439			submitbtn.prop('disabled', true);
440			submitbtn.html('<i class="bx bx-loader bx-spin"></i>');
441
442			var addressdata_for_cookie = '';
443
444			$.each($('input[type="text"], input[type="email"], select, textarea', formel), function (key, value) {
445				var elid = this.id;
446				if (elid) {
447					formdata[elid] = $(this).val();
448					addressdata_for_cookie += elid + '#+' + $(this).val() + '::';
449				};
450			});
451
452			if ($('input#savename').is(':checked')) {
453				cumpa_saveCookie('prefill_cumpa', addressdata_for_cookie, 365);
454			} else {
455				cumpa_saveCookie('prefill_cumpa', 0, 365);
456			}
457
458			var newslettersub = 0;
459			if ($('input#newslettersub').is(':checked')) {
460				newslettersub = 1;
461			}
462
463			$.ajax({
464				type: 'post',
465				url: ajaxcall.url,
466				data: {
467					security: nonce,
468					action: 'sendsamples',
469					formdata: formdata,
470					newslettersub: newslettersub,
471				},
472				success: function (result) {
473					console.log(result);
474					$('#slinnerform').html(result);
475					cumpa_saveCookie('samplescart_cumpa_new', 0, 1);
476					cumpa_eraseCookie('samplescart_cumpa_new');
477				},
478				error: function (result) {
479
480				},
481			});
482
483		});
484
485		function cumpa_saveCookie(name, value, days) {
486			var expires = "";
487			if (days) {
488				var date = new Date();
489				date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
490				expires = "; expires=" + date.toUTCString();
491			}
492			document.cookie = name + "=" + (value || "") + expires + "; path=/";
493		}
494
495		function cumpa_eraseCookie(name) {
496			document.cookie = name + '=; Max-Age=-99999999;';
497		}
498
499		function cumpa_getCookie(cname) {
500			let name = cname + "=";
501			let ca = document.cookie.split(';');
502			for (let i = 0; i < ca.length; i++) {
503				let c = ca[i];
504				while (c.charAt(0) == ' ') {
505					c = c.substring(1);
506				}
507				if (c.indexOf(name) == 0) {
508					return c.substring(name.length, c.length);
509				}
510			}
511			return "";
512		}
513
514		function outputCart() {
515			$('#opencart').remove();
516			var items = cumpa_getCookie('samplescart_cumpa_new')
517			if (items) {
518				itemscount = items.split('_');
519				itemscount = itemscount.filter(Boolean);
520				$('body').append('<button id="opencart"><i class="bx bx-cart"></i><span class="te">Samples<br>Cart</span><span class="coun">' + itemscount.length + '</span></button>');
521			}
522		}
523		outputCart();
524
525		setInterval(function () {
526			$('#opencart').removeClass('shaker');
527			$('#opencart').addClass('shaker');
528		}, 60000);
529
530
531
532		//FACET
533		$(document).on('click', '.cfilterbox h4', function (e) {
534			e.preventDefault();
535
536			$(this).parents('.cfilterbox').toggleClass('closed');
537		});
538
539		(function ($) {
540			$(document).on('facetwp-refresh', function () {
541				$('.facetwp-template').animate({ opacity: 0 }, 500);
542				/* $('html, body').animate({
543					scrollTop: $(".facetwp-template").offset().top - 200
544				}, 300); */
545			});
546			$(document).on('facetwp-loaded', function () {
547				$('.facetwp-template').animate({ opacity: 1 }, 500);
548				var qs = FWP.buildQueryString();
549				if ('' === qs) { // no facets are selected
550					$('#resetallfilter2').hide();
551					$('#filterallcu').hide();
552				}
553				else {
554					$('#resetallfilter2').show();
555					$('#filterallcu').show();
556				}
557			});
558		})(jQuery);
559
560		$(document).ready(function () {
561			if (typeof FWP != "undefined") {
562				var qs = FWP.buildQueryString();
563				if ('' === qs) { // no facets are selected
564					$('#resetallfilter2').hide();
565					$('#filterallcu').hide();
566				}
567				else {
568					$('#resetallfilter2').show();
569					$('#filterallcu').show();
570				}
571			}
572		})
573	});
574});

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.