PageSourceSearch

https://eoczyszczalnie.com.pl/js/tools.js

js eoczyszczalnie.com.pl collected 2026-10-07 15:06:56 UTC 11,169 bytes, 345 lines download raw bytes

1/*
2* 2007-2013 PrestaShop
3*
4* NOTICE OF LICENSE
5*
6* This source file is subject to the Open Software License (OSL 3.0)
7* that is bundled with this package in the file LICENSE.txt.
8* It is also available through the world-wide-web at this URL:
9* http://opensource.org/licenses/osl-3.0.php
10* If you did not receive a copy of the license and are unable to
11* obtain it through the world-wide-web, please send an email
12* to [email protected] so we can send you a copy immediately.
13*
14* DISCLAIMER
15*
16* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
17* versions in the future. If you wish to customize PrestaShop for your
18* needs please refer to http://www.prestashop.com for more information.
19*
20*  @author PrestaShop SA <[email protected]>
21*  @copyright  2007-2013 PrestaShop SA
22*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
23*  International Registered Trademark & Property of PrestaShop SA
24*/
25
26function formatedNumberToFloat(price, currencyFormat, currencySign)
27{
28	price = price.replace(currencySign, '');
29	if (currencyFormat == 1)
30		return parseFloat(price.replace(',', '').replace(' ', ''));
31	else if (currencyFormat == 2)
32		return parseFloat(price.replace(' ', '').replace(',', '.'));
33	else if (currencyFormat == 3)
34		return parseFloat(price.replace('.', '').replace(' ', '').replace(',', '.'));
35	else if (currencyFormat == 4)
36		return parseFloat(price.replace(',', '').replace(' ', ''));
37	return price;
38}
39
40//return a formatted number
41function formatNumber(value, numberOfDecimal, thousenSeparator, virgule)
42{
43	value = value.toFixed(numberOfDecimal);
44	var val_string = value+'';
45	var tmp = val_string.split('.');
46	var abs_val_string = (tmp.length == 2) ? tmp[0] : val_string;
47	var deci_string = ('0.' + (tmp.length == 2 ? tmp[1] : 0)).substr(2);
48	var nb = abs_val_string.length;
49
50	for (var i = 1 ; i < 4; i++)
51		if (value >= Math.pow(10, (3 * i)))
52			abs_val_string = abs_val_string.substring(0, nb - (3 * i)) + thousenSeparator + abs_val_string.substring(nb - (3 * i));
53
54	if (parseInt(numberOfDecimal) == 0)
55		return abs_val_string;
56	return abs_val_string + virgule + (deci_string > 0 ? deci_string : '00');
57}
58
59function formatCurrency(price, currencyFormat, currencySign, currencyBlank)
60{
61	// if you modified this function, don't forget to modify the PHP function displayPrice (in the Tools.php class)
62	blank = '';
63	price = parseFloat(price.toFixed(6));
64	price = ps_round(price, priceDisplayPrecision);
65	if (currencyBlank > 0)
66		blank = ' ';
67	if (currencyFormat == 1)
68		return currencySign + blank + formatNumber(price, priceDisplayPrecision, ',', '.');
69	if (currencyFormat == 2)
70		return (formatNumber(price, priceDisplayPrecision, ' ', ',') + blank + currencySign);
71	if (currencyFormat == 3)
72		return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '.', ','));
73	if (currencyFormat == 4)
74		return (formatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign);
75	if (currencyFormat == 5)
76		return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '\'', '.'));
77	return price;
78}
79
80function ps_round(value, precision)
81{
82	if (typeof(roundMode) == 'undefined')
83		roundMode = 2;
84	if (typeof(precision) == 'undefined')
85		precision = 2;
86	
87	method = roundMode;
88	if (method == 0)
89		return ceilf(value, precision);
90	else if (method == 1)
91		return floorf(value, precision);
92	precisionFactor = precision == 0 ? 1 : Math.pow(10, precision);
93	return Math.round(value * precisionFactor) / precisionFactor;
94}
95
96function autoUrl(name, dest)
97{
98	var loc;
99	var id_list;
100
101	id_list = document.getElementById(name);
102	loc = id_list.options[id_list.selectedIndex].value;
103	if (loc != 0)
104		location.href = dest+loc;
105	return ;
106}
107
108function autoUrlNoList(name, dest)
109{
110	var loc;
111
112	loc = document.getElementById(name).checked;
113	location.href = dest + (loc == true ? 1 : 0);
114	return ;
115}
116
117/*
118** show or hide element e depending on condition show
119*/
120function toggle(e, show)
121{
122	e.style.display = show ? '' : 'none';
123}
124
125function toggleMultiple(tab)
126{
127    var len = tab.length;
128
129    for (var i = 0; i < len; i++)
130        if (tab[i].style)
131            toggle(tab[i], tab[i].style.display == 'none');
132}
133
134/**
135* Show dynamicaly an element by changing the sytle "display" property
136* depending on the option selected in a select.
137*
138* @param string $select_id id of the select who controls the display
139* @param string $elem_id prefix id of the elements controlled by the select
140*   the real id must be : 'elem_id'+nb with nb the corresponding number in the
141*   select (starting with 0).
142*/
143function showElemFromSelect(select_id, elem_id)
144{
145	var select = document.getElementById(select_id);
146	for (var i = 0; i < select.length; ++i)
147	{
148	    var elem = document.getElementById(elem_id + select.options[i].value);
149		if (elem != null)
150			toggle(elem, i == select.selectedIndex);
151	}
152}
153
154/**
155* Get all div with specified name and for each one (by id), toggle their visibility
156*/
157function openCloseAllDiv(name, option)
158{
159	var tab = $('*[name='+name+']');
160	for (var i = 0; i < tab.length; ++i)
161		toggle(tab[i], option);
162}
163
164/**
165* Toggle the value of the element id_button between text1 and text2
166*/
167function toggleElemValue(id_button, text1, text2)
168{
169	var obj = document.getElementById(id_button);
170	if (obj)
171		obj.value = ((!obj.value || obj.value == text2) ? text1 : text2);
172}
173
174function addBookmark(url, title)
175{
176	if (window.sidebar)
177		return window.sidebar.addPanel(title, url, "");
178	else if ( window.external && ('AddFavorite' in window.external))
179		return window.external.AddFavorite( url, title);
180	else if (window.opera && window.print)
181		return true;
182	return true;
183}
184
185function writeBookmarkLink(url, title, text, img)
186{
187	var insert = '';
188	if (img)
189		insert = writeBookmarkLinkObject(url, title, '<img src="' + img + '" alt="' + escape(text) + '" title="' + removeQuotes(text) + '" />') + '&nbsp';
190	insert += writeBookmarkLinkObject(url, title, text);
191	if (window.sidebar || window.opera && window.print || (window.external && ('AddFavorite' in window.external)))	
192		document.write(insert);
193}
194
195function writeBookmarkLinkObject(url, title, insert)
196{
197	if (window.sidebar || window.external)
198		return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + removeQuotes(title) + '\')">' + insert + '</a>');
199	else if (window.opera && window.print)
200		return ('<a rel="sidebar" href="' + escape(url) + '" title="' + removeQuotes(title) + '">' + insert + '</a>');
201	return ('');
202}
203
204function checkCustomizations()
205{
206	var pattern = new RegExp(' ?filled ?');
207
208	if (typeof customizationFields != 'undefined')
209		for (var i = 0; i < customizationFields.length; i++)
210		{								
211			/* If the field is required and empty then we abort */
212			if (parseInt(customizationFields[i][1]) == 1 && ($('#' + customizationFields[i][0]).html() == '' ||  $('#' + customizationFields[i][0]).text() != $('#' + customizationFields[i][0]).val()) && !pattern.test($('#' + customizationFields[i][0]).attr('class')))
213				return false;
214		}
215	return true;
216}
217
218function emptyCustomizations()
219{
220	if(typeof(customizationFields) == 'undefined') return;
221
222	$('.customization_block .success').fadeOut(function(){
223		$(this).remove();
224	});
225	$('.customization_block .error').fadeOut(function(){
226		$(this).remove();
227	});
228	for (var i = 0; i < customizationFields.length; i++)
229	{
230		$('#' + customizationFields[i][0]).html('');
231		$('#' + customizationFields[i][0]).val('');
232	}
233}
234
235function ceilf(value, precision)
236{
237	if (typeof(precision) == 'undefined')
238		precision = 0;
239	var precisionFactor = precision == 0 ? 1 : Math.pow(10, precision);
240	var tmp = value * precisionFactor;
241	var tmp2 = tmp.toString();
242	// If the current value has already the desired precision
243	if (tmp2.indexOf('.') === false)
244		return (value);
245	if (tmp2.charAt(tmp2.length - 1) == 0)
246		return value;
247	return Math.ceil(tmp) / precisionFactor;
248}
249
250function floorf(value, precision)
251{
252	if (typeof(precision) == 'undefined')
253		precision = 0;
254	var precisionFactor = precision == 0 ? 1 : Math.pow(10, precision);
255	var tmp = value * precisionFactor;
256	var tmp2 = tmp.toString();
257	// If the current value has already the desired precision
258	if (tmp2.indexOf('.') === false)
259		return (value);
260	if (tmp2.charAt(tmp2.length - 1) == 0)
261		return value;
262	return Math.floor(tmp) / precisionFactor;
263}
264
265function setCurrency(id_currency)
266{
267	$.ajax({
268		type: 'POST',
269		headers: { "cache-control": "no-cache" },
270		url: baseDir + 'index.php' + '?rand=' + new Date().getTime(),
271		data: 'controller=change-currency&id_currency='+ parseInt(id_currency),
272		success: function(msg)
273		{
274			location.reload(true);
275		}
276	});
277}
278
279function isArrowKey(k_ev)
280{
281	var unicode=k_ev.keyCode? k_ev.keyCode : k_ev.charCode;
282	if (unicode >= 37 && unicode <= 40)
283		return true;
284	return false;
285}
286
287function removeQuotes(value)
288{
289	value = value.replace(/\\"/g, '');
290	value = value.replace(/"/g, '');
291	value = value.replace(/\\'/g, '');
292	value = value.replace(/'/g, '');
293
294	return value;
295}
296
297/**
298 * Display a MessageBox
299 * @param {string} msg
300 * @param {string} title (optional)
301 */
302function fancyMsgBox(msg, title)
303{
304    if (title) msg = "<h2>" + title + "</h2><p>" + msg + "</p>";
305    msg += "<br/><p class=\"submit\" style=\"text-align:right; padding-bottom: 0\"><input class=\"button\" type=\"button\" value=\"OK\" onclick=\"$.fancybox.close();\" /></p>";
306    $.fancybox( msg, {'autoDimensions': false, 'width': 500, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none'} );
307}
308
309/**
310 * Display a messageDialog with different buttons including a callback for each one
311 * @param {string} question
312 * @param {mixed} title Optional title for the dialog box. Send false if you don't want any title
313 * @param {object} buttons Associative array containg a list of {buttonCaption: callbackFunctionName, ...}. Use an empty space instead of function name for no callback
314 * @param {mixed} otherParams Optional data sent to the callback function
315 */
316function fancyChooseBox(question, title, buttons, otherParams)
317{
318    var msg, funcName, action;
319    if (title) msg = "<h2>" + title + "</h2><p>" + question + "</p>";
320    msg += "<br/><p class=\"submit\" style=\"text-align:right; padding-bottom: 0\">";
321    var i = 0;
322    for (var caption in buttons) {
323        if (!buttons.hasOwnProperty(caption)) continue;
324        funcName = buttons[caption];
325        if (typeof otherParams == 'undefined') otherParams = 0;
326        otherParams = escape(JSON.stringify(otherParams));
327        action = funcName ? "$.fancybox.close();window['" + funcName + "'](JSON.parse(unescape('" + otherParams + "')), " + i + ")" : "$.fancybox.close()";
328        msg += '<input class="button" style="margin-right: 5px" type="button" value="' + caption + '" onclick="' + action + '" />';
329        i++;
330    }
331    msg += "</p>";
332    $.fancybox( msg, {'autoDimensions': false, 'width': 500, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none'} );
333}
334
335//On dom ready
336$().ready(function()
337{
338	// Hide all elements with .hideOnSubmit class when parent form is submit
339	$('form').submit(function()
340	{
341		$(this).find('.hideOnSubmit').hide();
342	});
343	// attribute target="_blank" is not W3C compliant
344	$('a._blank').attr('target', '_blank');
345});

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.