PageSourceSearch

https://www.notebookcheck.pl/typo3conf/ext/nbc2bestprice/res/bestprice.js?2026090908

js notebookcheck.pl collected 2026-10-02 09:53:30 UTC 14,223 bytes, 406 lines download raw bytes

1
2/*	function showHideLegend(objDiv)
3	{
4		$child = $(objDiv).children()[0];
5		if($child.style.display=='none')
6		{
7			$(objDiv).children().show('slow');
8			$child.style.display='block';		
9		}
10		else if($child.style.display=='block')
11		{
12			$(objDiv).children().hide('slow');		
13		}
14	}*/
15	var giCountryID = '';
16	
17	//search for bestprice cookie and set var iCountryID 
18	//return iCountryID or ''
19	function getCookie(cname)
20	{
21		var name = cname + "=";
22		var decodedCookie = decodeURIComponent(document.cookie);
23		var ca = decodedCookie.split(';');
24		for(var i = 0; i <ca.length; i++) {
25			var c = ca[i];
26			while (c.charAt(0) == ' ') {
27				c = c.substring(1);
28			}
29			if (c.indexOf(name) == 0) {
30					giCountryID = c.substring(name.length, c.length);
31				return giCountryID;
32			}
33		}
34		return "";		
35	} 
36	
37	//write cookie 'nbc_' and store:
38	//iCountryID, sContinent, isEU, sCountryShortcode
39	function setCookie(cname,cvalue)
40	{
41		a = new Date((new Date()).getTime() +1000*60*60*24*365); // 1 Jahr 
42		document.cookie = 'nbc_'+cname+'='+cvalue+'; expires='+a.toGMTString()+'; path=/';
43	}
44
45	function load_pricecompare($spec_id,$bp_id,$llkey,$sWhichside,$iCountryID,$bCheapestOffer,$iMaxPrice,$iMinPrice)
46	{
47		
48		if(!$iCountryID) 
49		{
50			if(getCookie('nbc_countryid')!='')
51			{
52				$iCountryID = giCountryID;
53			}
54		}
55		if($typo3Path.search("typo3nbc")==1)
56		{
57			$typo3Path = "http://localhost/typo3nbc/";
58		}
59		else
60		{
61			$typo3Path = "https://dev1.notebook-check.com/";
62		}
63
64		/*
65		jQuery.ajax({
66			url: $typo3Path+'?eID=bestprice',
67				type: "POST",
68				dataType: "JSON",
69				data: {
70					extPath: $extPath,
71					spec_id: $spec_id,
72					bp_id: $bp_id,
73					llkey: $llkey,
74					side: $sWhichside,
75					iCountryID: $iCountryID,
76					bCheapestOffer: $bCheapestOffer,
77					iMinPrice: $iMinPrice,
78					iMaxPrice: $iMaxPrice
79				},
80			success: function(result) {
81				console.log(result);
82	    },
83			error: function(XMLHttpRequest, textStatus, errorThrown) {
84 					//alert('Error: '+textStatus);
85	    }
86 		});
87		 */
88
89		url = $typo3Path+'?eID=bestprice';
90		params = "extPath="+encodeURIComponent($extPath);
91		params += "&spec_id="+$spec_id;
92		params += "&bp_id="+$bp_id;
93		params += "&llkey="+$llkey;
94		params += "&side="+encodeURIComponent($sWhichside);
95		params += "&iCountryID="+encodeURIComponent($iCountryID);
96		if ($bCheapestOffer) params += "&bCheapestOffer="+encodeURIComponent($bCheapestOffer);
97		if ($iMinPrice) params += "&iMinPrice="+encodeURIComponent($iMinPrice);
98		if ($iMaxPrice) params += "&iMaxPrice="+encodeURIComponent($iMaxPrice);
99
100		var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
101		xhr.open("POST", url, true);
102		xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
103		xhr.onreadystatechange = function() {
104			if (xhr.readyState>3) {
105				if (xhr.status==200) {
106					try {
107						var result = JSON.parse(xhr.responseText);
108				
109						if(giCountryID==''&&result.session.CountryID)
110						{
111							for(var cname in result.session) 
112							{
113								//alert(cname.toLowerCase()+':'+result.session[cname]);
114								setCookie(cname.toLowerCase(),result.session[cname]);
115							}
116						}
117						if (result.wert==false)
118						{
119							if (document.getElementById('pricecompare_table_review_left')) document.getElementById('pricecompare_table_review_left').innerHTML = 'No results, try with an other EAN/UPC or Modelname in the specs configuration!';
120							if(result.output=='Nothing found')
121							{
122								if (document.getElementById('start_bp_search_'+$spec_id+'_'+$bp_id)) document.getElementById('start_bp_search_'+$spec_id+'_'+$bp_id).innerHTML = 'No offer found.';
123								else console.log('No offer found for '+$spec_id+'_'+$bp_id);
124							}
125							else if ((typeof result.output != 'undefined' && result.output.indexOf('to_slow')!=-1)||result.db=='offline')
126							{
127								if (document.getElementById('start_bp_search_'+$spec_id+'_'+$bp_id)) document.getElementById('start_bp_search_'+$spec_id+'_'+$bp_id).innerHTML = 'This service is currently not available. Please try again later.';
128								else console.log('Price service currently not available for '+$spec_id+'_'+$bp_id);
129							}
130						}
131						else
132						{
133							var $sWhere = '';
134							if ($bCheapestOffer)
135							{
136								$sWhere = 'co';
137							}
138							else
139							{
140								$sWhere = $sWhichside;
141							}
142							if(document.getElementById('h_pricecompare_'+$spec_id+'_'+$bp_id) && document.getElementById('h_pricecompare_'+$spec_id+'_'+$bp_id).innerHTML!='')
143							{
144								document.getElementById('h_pricecompare_'+$spec_id+'_'+$bp_id).style.display = "block";
145							}
146
147							//Shop <H> 'Preisvergleich' on Top only
148							if (document.getElementById('pricecompare_header_'+$sWhere+'_'+$spec_id+'_'+$bp_id) && document.getElementById('pricecompare_header_'+$sWhere+'_'+$spec_id+'_'+$bp_id).innerHTML != '')
149							{
150
151								var $objHeader = document.getElementById('pricecompare_header_'+$sWhere+'_'+$spec_id+'_'+$bp_id);
152								var $objPrev = $objHeader.parentElement.previousElementSibling;
153								if ($objPrev && $objPrev.querySelector("h3.pc_h3") && $objPrev.querySelector("h3.pc_h3").innerHTML!='') document.getElementById('pricecompare_header_'+$sWhere+'_'+$spec_id+'_'+$bp_id).style.display="block";
154								/*
155								var $objHeader = jQuery('#pricecompare_header_'+$sWhere+'_'+$spec_id+'_'+$bp_id);
156								$objPrev = $objHeader.parent("DIV").prev("DIV");
157								if (!$objPrev.children("h3.pc_h3").text()!='')
158								{
159									document.getElementById('pricecompare_header_'+$sWhere+'_'+$spec_id+'_'+$bp_id).style.display="block";
160								}
161								*/
162							}
163
164							if(result.modelname!='')
165							{
166								var $objHeader = document.getElementById('modelname_pricecompare_left_'+$spec_id+'_'+$bp_id);
167								if ($objHeader) {
168									$objHeader.innerHTML = result.modelname;
169									$objHeader.style.display = "block";
170								}
171							}
172							if (document.getElementById('start_bp_search'+'_'+$spec_id+'_'+$bp_id) && document.getElementById('start_bp_search'+'_'+$spec_id+'_'+$bp_id).innerHTML !='')
173							{
174								document.getElementById('start_bp_search'+'_'+$spec_id+'_'+$bp_id).style.display="none";
175							}
176							if($sWhere=='co'&&(result.price==null||result.price=='')){}
177							else
178							{
179								if (document.getElementById('pricecompare_table_review_'+$sWhere)) {
180									document.getElementById('pricecompare_table_review_'+$sWhere).style.display = "block";
181									document.getElementById('pricecompare_table_review_'+$sWhere).innerHTML = result.wert;
182								}
183								if (document.getElementById('pricecompare_table_review_'+$sWhere+'_'+$spec_id+'_'+$bp_id)) {
184									document.getElementById('pricecompare_table_review_'+$sWhere+'_'+$spec_id+'_'+$bp_id).style.display = "block";
185									document.getElementById('pricecompare_table_review_'+$sWhere+'_'+$spec_id+'_'+$bp_id).innerHTML = result.wert;
186								}
187							}
188							if(typeof(result.price)!='undefined')
189							{
190								if (document.getElementById('scr_bestprice_'+$spec_id+'_'+$bp_id)) //if(jQuery('#scr_bestprice_'+$spec_id+'_'+$bp_id)!=null)
191								{
192									if(result.price!=null)
193									{
194										sPrice = result.price.toString();
195										while(sPrice.length<30)
196										{
197											sPrice = '0'+sPrice;
198										}
199									}
200									else 
201									{
202										sPrice='';
203									}
204									document.getElementById('scr_bestprice_'+$spec_id+'_'+$bp_id).innerHTML = sPrice;
205									document.getElementById('scr_bestprice_'+$spec_id+'_'+$bp_id).removeAttribute("id");
206								}
207								if (document.querySelectorAll('[id*="scr_bestprice"]').length>0) //if(jQuery('[id*="scr_bestprice"]').length==0)
208								{
209									init_dataTable();//defined in class.tx_nbc2fe_benchcompare.php line 2409
210								}
211							}
212						}
213					} catch(e) {
214						console.log("could not parse JSON response due to error: "+e);
215					}
216			} else console.log("loading of pricecompare failed in bestprice.js :(");
217		}
218	}
219	//xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
220	xhr.send(params);
221
222
223	} // function
224	
225	function count_pricecompare($itemID, $shopID, $specID, $deviceID)
226	{
227		url = $sModPath+"countclick.php";
228		params = "item_id="+encodeURIComponent($itemID);
229		if ($specID) params += "&shop_id="+$specID;
230		if ($shopID) params += "&spec_id="+$shopID;
231		if ($deviceID) params += "&device_id="+encodeURIComponent($deviceID);
232		
233		var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
234		xhr.open("POST", url, true);
235		xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
236		xhr.onreadystatechange = function() {
237			if (xhr.readyState>3) {
238				if (xhr.status==200) {
239					console.log("counted pricecompare click");
240				} else console.log("counting click failed :(");
241			} 
242		}
243		xhr.send(params);
244
245		/*
246		jQuery.ajax({
247			url: $sModPath+"countclick.php",
248			type: "POST",
249			dataType: "JSON",
250			data: {
251				item_id: $itemID,
252				shop_id: $shopID,
253				spec_id: $specID,
254				device_id: $deviceID
255			}
256		});
257		*/
258	} // function
259
260
261	function showNextTableRow($ID,$side,$spec_id)
262	{
263		// show all .row items (only 3 visible in css)
264		document.querySelectorAll('#'+$ID+'_'+$side+' .row').forEach(element => {
265			element.style.display='block';
266		});
267		document.querySelectorAll('#'+$ID+'_'+$side+'_'+$spec_id+' .row').forEach(element => {
268			element.style.display='block';
269		});
270
271		// hide #pcdiv_more_'+$side+'_'+$spec_id button
272		if (document.getElementById('pcdiv_more_'+$side)) document.getElementById('pcdiv_more_'+$side).style.display="none";
273		if (document.getElementById('pcdiv_more_'+$side+'_'+$spec_id)) document.getElementById('pcdiv_more_'+$side+'_'+$spec_id).style.display="none";
274
275		/*
276		jQuery('#'+$ID+'_'+$side+' > .row:hidden').eq(0).show('slow')
277		.next().show('slow')
278		.next().show('slow');
279		var aTR = jQuery('#'+$ID+'_'+$side+' > .row:hidden');
280		if (aTR.length == 0)
281		{
282			jQuery('#pcdiv_more_'+$side).hide('slow');
283		}
284		jQuery('#'+$ID+'_'+$side+'_'+$spec_id+' > .row:hidden').eq(0).show('slow')
285		.next().show('slow')
286		.next().show('slow');
287		var aTR = jQuery('#'+$ID+'_'+$side+'_'+$spec_id+' > .row:hidden');
288		if (aTR.length == 0)
289		{
290			jQuery('#pcdiv_more_'+$side+'_'+$spec_id).hide('slow');
291		}
292		*/
293	}
294	
295	function savedata($specID,$what,$value,$sys_lang_id, $affiliate_id)
296	{
297		if(validation($what, $value))
298		{
299			url = $sModPath+"setvalue.php";
300			params = "sys_lang_id="+encodeURIComponent($sys_lang_id);
301			if ($value) params += "&value="+encodeURIComponent($value);
302			if ($what) params += "&kind="+encodeURIComponent($what);
303			if ($specID) params += "&spec_id="+encodeURIComponent($specID);
304			if ($affiliate_id) params += "&affiliate_id="+encodeURIComponent($affiliate_id);
305			
306			var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
307			xhr.open("POST", url, true);
308			xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
309			xhr.onreadystatechange = function() {
310				if (xhr.readyState>3) {
311					if (xhr.status==200) {
312						try {
313							var result = JSON.parse(xhr.responseText);
314
315							if(result.response) {
316								document.querySelector('#response p').innerHTML = 'saved '+$what;
317								document.getElementById('response').style.display = 'block';
318								setTimeout(function () {
319									document.getElementById('response').style.display = 'none';	
320								}, 3000);
321							}
322							else {
323								document.querySelector('#response p').innerHTML = 'Error: couldn\'t save '+$what;
324								document.getElementById('response').style.display = 'block';
325								setTimeout(function () {
326									document.getElementById('response').style.display = 'none';	
327								}, 3000);
328							}
329						} catch(e) {
330							console.log("could not parse JSON response for setvalue due to error: "+e);
331						}
332					} else console.log("loading of savedata failed in bestprice.js :(");
333				} // if readystate
334			} // onreadystate
335			//xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
336			xhr.send(params);
337
338			/*
339			jQuery.ajax({
340				url: $sModPath+"setvalue.php",
341				type: "POST",
342				dataType: "JSON",
343				data: {
344					sys_lang_id: $sys_lang_id,
345					value: $value,
346					kind: $what,
347					spec_id: $specID,
348					affiliate_id: $affiliate_id
349				},
350		    success: function(result) {
351		    	if(result.response) {
352			    	document.querySelector('#response p').innerHTML = 'saved '+$what;
353					document.getElementById('response').style.display = 'block';
354					setTimeout(function () {
355						document.getElementById('response').style.display = 'none';	
356					}, 3000);
357			    	//jQuery('#response').show('slow').delay(3000).hide('slow');
358			    }
359			    else {
360			    	document.querySelector('#response p').innerHTML = 'Error: couldn\'t save '+$what;
361					document.getElementById('response').style.display = 'block';
362					setTimeout(function () {
363						document.getElementById('response').style.display = 'none';	
364					}, 3000);
365			    	//jQuery('#response').show('slow').delay(3000).hide('slow');
366			    }
367		    },
368				error: function(XMLHttpRequest, textStatus, errorThrown) {
369	 					console.error('Error in bestprice.js savedata: '+textStatus);
370		    }
371			});
372			*/
373		} // if validation
374	} // function
375
376	function validation($what, $value)
377	{
378		if ($value.trim()=='')return false;
379		
380		switch($what)
381		{
382			case 'mpn':
383			{
384				$ret = true;
385				if($value.trim().length<4)
386				{
387					console.error('bestprice.js: article number requires at least 4 characters');
388					$ret = false;
389				}
390				if($ret&&$value.toLowerCase().indexOf($objDevice.modelname.toLowerCase())!=-1)
391				{
392					$ret = confirm('The modelname: "'+$objDevice.modelname+'" is part of the MPN. Usual it should not. Do you want to proceed anyway?');
393				}
394				if ($ret&&$value.toLowerCase().indexOf($objDevice.serie.toLowerCase())!=-1)
395				{
396					$ret = confirm('The serie: "'+$objDevice.serie+'" is part of the MPN. Usual it should not. Do you want to proceed anyway?');
397				}
398				if($ret&&$value.toLowerCase().indexOf($objDevice.brand.toLowerCase())!=-1)
399				{
400					$ret = confirm('The brand: "'+$objDevice.brand+'" is part of the MPN. Usual it should not. Do you want to proceed anyway?');
401				}
402				break;
403			}
404		}
405		return $ret;
406	}

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.