PageSourceSearch

https://www.poolshop123.de/plugins/km_artikelpreise/frontend/js/preise.js?v=3.2.2_3.6.0

js poolshop123.de collected 2026-10-08 06:58:11 UTC 10,904 bytes, 359 lines download raw bytes

1var km_preis_config,itsok;
2$(function() {
3	if($('#km_preis_data').length)
4	{
5		itsok=true;
6		try
7		{
8			km_preis_config = JSON.parse($('#km_preis_data').html());
9		} catch(e) {
10			console.log('JavaScript Fehler in der globalen Preiskonfiguration.');
11			itsok=false;
12		}
13		
14		if(itsok)
15		{
16			if(km_preis_config.showBrutto)
17				km_preis_config.basePrice = getNetto(km_preis_config.basePrice);
18			$(document).on('evo:changed.article.price',function(args){
19				setBasePrice();
20				checkPrice();
21			});
22			$(document).on('evo:contentLoaded',function(args){
23				registerInputs();
24				window.setTimeout(function(){
25					//Reset km_preis_config
26					if($('#km_preis_data_ajax').length)
27					{
28						try
29						{
30							km_preis_config = JSON.parse($('#km_preis_data_ajax').html());
31						} catch(e) {
32							console.log('JavaScript Fehler in der globalen Preiskonfiguration via Ajax nachladen.');
33						}
34					}
35					setBasePrice();
36					checkPrice();
37				},500);
38			});
39			
40			registerInputs();
41			setBasePrice();
42			checkPrice();
43		}
44	}
45});
46
47function registerInputs()
48{
49	$('.km_preise_input[type=range]').on('change',function(){
50		$(this).parent().find('span.rangevalue').html($(this).val());
51	});
52	$('.km_preise_input, #quantity').on('change',function(){
53		checkPrice();
54	});
55	
56	//Alte Felder - Shop3/Hypnos
57	$('[name*=eigenschaftwert_]').on('change',function(){
58		window.setTimeout(function(){
59			checkPrice();
60		},500);
61	});
62}
63
64
65function setBasePrice()
66{
67	var price = $(km_preis_config.price).text();
68	if(km_preis_config.waehrung.cVorBetrag != 'N')
69		price = price.substr(price.search(/[0-9]/));
70	price = parseFloat(price.replace(km_preis_config.waehrung.cNameHTML,'').trim().replace(km_preis_config.waehrung.cTrennzeichenTausend,'').replace(km_preis_config.waehrung.cTrennzeichenCent,'.'));
71	if(km_preis_config.showBrutto)
72		price = getNetto(price);
73	km_preis_config.basePrice = price;
74}
75function getBrutto(price)
76{
77	return price * ((100 + parseFloat(km_preis_config.mwst)) / 100);
78}
79
80function getNetto(price)
81{
82	return parseFloat(Number(price / ((100 + parseFloat(km_preis_config.mwst)) / 100)).toFixed(2));
83}
84function getEigenschaftValue(x)
85{
86	//First find the Element!
87	var elem = $('[name=eigenschaftwert\\['+x+'\\]]');
88	if(elem.length != 1)
89		elem = $('[name=eigenschaftwert_'+x+']');
90	if(elem.length != 1)
91		elem = $('[name=eigenschaftwert\\['+x+'\\]]:selected');
92	if(elem.length != 1)
93		elem = $('[name=eigenschaftwert_'+x+']:selected');
94	if(elem.length != 1)
95		elem = $('[name=eigenschaftwert\\['+x+'\\]]:checked');
96	if(elem.length != 1)
97		elem = $('[name=eigenschaftwert_'+x+']:checked');
98	
99	if(!elem.length == 1)
100		return 0;
101	
102	return $(elem).val();
103}
104
105function checkPrice()
106{
107	if(!km_preis_config.manipulations) return false;
108	
109	var price = km_preis_config.basePrice;
110	var basePrice = -1;
111	var priceFormatted;
112	var data;
113	var doIt;
114	var wert;
115	//if(!price) return false;
116	
117	//Jetzt alle Prüflogiken durchgehen
118	for(var x=0; x < km_preis_config.manipulations.length; x++)
119	{
120		data = false;
121		try
122		{
123			data = JSON.parse(km_preis_config.manipulations[x].formel);
124		} catch(e) {
125			console.log('JavaScript Fehler in der Formel, bitte mathematischen Ausdruck pruefen');
126		}
127		if(data)
128		{
129			doIt = (data.type==1) ? true : false;
130			if(!data.if) doIt = true;
131			else
132			{
133				//Bedingungen prüfen
134				for(i in data.if)
135				{
136					wert = 0;
137					if(data.if[i].eigenschaft > 0)
138						wert = getEigenschaftValue(data.if[i].eigenschaft);
139					else if(data.if[i].eigenschaft == -1)
140						wert = calculateFormel(data.if[i].eigenschaft_formel,price);
141					else
142						continue;
143					
144					if(!wert) wert = 0;
145					
146					value = (data.if[i].eigenschaft_wert) ? data.if[i].eigenschaft_wert : data.if[i].eigenschaft_value;
147					
148					wert = parseFloat(wert);
149					value = parseFloat(value);
150					
151					if(data.if[i].eigenschaft_if == '=')
152					{
153						if(parseFloat(wert) == parseFloat(value))
154						{
155							if(data.type==0)
156								doIt = true;
157						} else {
158							if(data.type==1)
159								doIt = false;
160						}
161					}
162					if(data.if[i].eigenschaft_if == '!=')
163					{
164						if(parseFloat(wert) != parseFloat(value))
165						{
166							if(data.type==0)
167								doIt = true;
168						} else {
169							if(data.type==1)
170								doIt = false;
171						}
172					}
173					if(data.if[i].eigenschaft_if == '<')
174					{
175						if(parseFloat(wert) < parseFloat(value))
176						{
177							if(data.type==0)
178								doIt = true;
179						} else {
180							if(data.type==1)
181								doIt = false;
182						}
183					}
184					if(data.if[i].eigenschaft_if == '>')
185					{
186						if(parseFloat(wert) > parseFloat(value))
187						{
188							if(data.type==0)
189								doIt = true;
190						} else {
191							if(data.type==1)
192								doIt = false;
193						}
194					}
195				}
196			}
197			
198			//Aktionen durchführen
199			if(doIt && data.aktion)
200			{
201				for(i in data.aktion)
202				{
203					if(data.aktion[i].type == 1)
204					{
205						//Preis anpassen
206						switch(data.aktion[i].preis_type)
207						{
208							case "0":
209								//Fester Aufpreis
210								price = price + parseFloat(data.aktion[i].preis_wert);
211								break;
212							case "1":
213								//Prozentualer Aufpreis
214								price = price + (price / 100 * data.aktion[i].preis_wert);
215								break;
216							case "2":
217								//Formelberechnung
218								price = calculateFormel(data.aktion[i].preis_formel,price);
219								break;
220							default:
221								//Unbekannte Berechnung
222								price = price;
223						}
224					} else if(data.aktion[i].type == 2)
225					{
226						//Feld befüllen
227						wert = "";
228						if(data.aktion[i].field_type == 1)
229						{
230							wert = calculateFormel(data.aktion[i].field_formel,price);
231							if(data.aktion[i].field_suffix != "")
232								wert = String(wert) + data.aktion[i].field_suffix;
233							if(data.aktion[i].field_praefix != "")
234								wert = data.aktion[i].field_praefix + String(wert);
235							
236						} else
237							wert = data.aktion[i].field_value;
238						$('[name=eigenschaftwert\\['+data.aktion[i].field_input+'\\]]').val(wert);
239						$('[name=eigenschaftwert_'+data.aktion[i].field_input+']').val(wert);
240					} else if(data.aktion[i].type == 3)
241					{
242						if(km_preis_config.hideSelektorParent != '')
243						{
244							$(km_preis_config.hideSelektor.replace('%s',data.aktion[i].verstecken)).parents(km_preis_config.hideSelektorParent ).hide();
245							if(km_preis_config.hideSelektorParentBefore == 'Y')
246								$(km_preis_config.hideSelektor.replace('%s',data.aktion[i].verstecken)).parents(km_preis_config.hideSelektorParent ).prev().hide();
247						}
248						else
249						$(km_preis_config.hideSelektor.replace('%s',data.aktion[i].verstecken)).hide();
250					} else if(data.aktion[i].type == 4)
251					{
252						if(km_preis_config.hideSelektorParent != '')
253						{
254							$(km_preis_config.hideSelektor.replace('%s',data.aktion[i].verstecken)).parents(km_preis_config.hideSelektorParent ).show();
255							if(km_preis_config.hideSelektorParentBefore == 'Y')
256								$(km_preis_config.hideSelektor.replace('%s',data.aktion[i].verstecken)).parents(km_preis_config.hideSelektorParent ).prev().show();
257						}
258						else
259						$(km_preis_config.hideSelektor.replace('%s',data.aktion[i].verstecken)).show();
260					} else if(data.aktion[i].type == 5)
261					{
262						//Gewicht anpassen - irrelevant für liveberechnung
263					} else if(data.aktion[i].type == 6)
264					{
265						console.log("setzebaseprice");
266						basePrice = calculateFormel(data.aktion[i].preis_formel,price);
267						console.log(basePrice);
268					} else if(data.aktion[i].type == 7)
269					{
270						//JavaScript ausführen
271						try
272						{
273							return eval(replaceFormel(data.aktion[i].preis_formel,price));
274						} catch(e) {
275							console.log('KM Preisprofi - JSAktionsyntaxerror');
276						}
277					}
278				}
279			}
280		}
281	}
282	
283	//Brutto ausgabe?
284	if(km_preis_config.showBrutto)
285		price = getBrutto(price);
286	
287	//Preis formatieren
288	priceFormatted = price.toFixed(2).toString().replace('.',km_preis_config.waehrung.cTrennzeichenCent);
289	if(price >= 1000)
290	{
291		priceFormatted = priceFormatted.substr(0,priceFormatted.length-6)+km_preis_config.waehrung.cTrennzeichenTausend+priceFormatted.substr(priceFormatted.length-6);
292	}
293	if(price >= 1000000)
294	{
295		priceFormatted = priceFormatted.substr(0,priceFormatted.length-10)+km_preis_config.waehrung.cTrennzeichenTausend+priceFormatted.substr(priceFormatted.length-10);
296	}
297	if(price >= 1000000000)
298	{
299		priceFormatted = priceFormatted.substr(0,priceFormatted.length-14)+km_preis_config.waehrung.cTrennzeichenTausend+priceFormatted.substr(priceFormatted.length-14);
300	}
301	if(km_preis_config.waehrung.cVorBetrag == 'N')
302		priceFormatted = priceFormatted + " " + km_preis_config.waehrung.cNameHTML;
303	else
304		priceFormatted = km_preis_config.waehrung.cNameHTML + " " + priceFormatted;
305	$(km_preis_config.price).html(priceFormatted);
306	if(basePrice >0)
307	{
308		//Baseprice anpassen
309		basePrice = price / basePrice;
310		priceFormatted = basePrice.toFixed(2).toString().replace('.',km_preis_config.waehrung.cTrennzeichenCent);
311		if(basePrice >= 1000)
312		{
313			priceFormatted = priceFormatted.substr(0,priceFormatted.length-6)+km_preis_config.waehrung.cTrennzeichenTausend+priceFormatted.substr(priceFormatted.length-6);
314		}
315		if(basePrice >= 1000000)
316		{
317			priceFormatted = priceFormatted.substr(0,priceFormatted.length-10)+km_preis_config.waehrung.cTrennzeichenTausend+priceFormatted.substr(priceFormatted.length-10);
318		}
319		if(basePrice >= 1000000000)
320		{
321			priceFormatted = priceFormatted.substr(0,priceFormatted.length-14)+km_preis_config.waehrung.cTrennzeichenTausend+priceFormatted.substr(priceFormatted.length-14);
322		}
323		if(km_preis_config.waehrung.cVorBetrag == 'N')
324			priceFormatted = priceFormatted + " " + km_preis_config.waehrung.cNameHTML;
325		else
326			priceFormatted = km_preis_config.waehrung.cNameHTML + " " + priceFormatted;
327		$(km_preis_config.basePriceSelektor).html(priceFormatted + " "+km_preis_config.basePriceString);
328	}
329}
330
331function replaceFormel(formel,price)
332{
333	var quantity;
334	quantity = parseFloat($('#quantity').val());
335	formel = formel.replace('##price##',price);
336	formel = formel.replace('##quantity##',quantity);
337	formel = formel.replace('ABRUNDEN(','Math.floor(');
338	formel = formel.replace('AUFRUNDEN(','Math.ceil(');
339	formel = formel.replace('RUNDEN(','Math.round(');
340	formel = formel.replace(/##e\:([0-9]*)##/i,function(x,y,z) {
341		return getEigenschaftValue(y);
342	});
343	if(formel.includes('##'))
344		formel = replaceFormel(formel,price);
345	
346	return formel;
347}
348
349function calculateFormel(formel,price)
350{
351	try
352	{
353		formel = replaceFormel(formel,price);
354		return eval(formel);
355	} catch(e) {
356		console.log('KM Preisprofi - Formelsyntaxerror: '+formel);
357		return 0;
358	}
359}

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.