PageSourceSearch

https://skibikemarathon.com/catalog/view/javascript/common.js?v=185b08f7

js skibikemarathon.com collected 2026-10-08 10:06:34 UTC 13,756 bytes, 499 lines download raw bytes

1function getURLVar(key) {
2	var value = [];
3
4	var query = String(document.location).split('?');
5
6	if (query[1]) {
7		var part = query[1].split('&');
8
9		for (i = 0; i < part.length; i++) {
10			var data = part[i].split('=');
11
12			if (data[0] && data[1]) {
13				value[data[0]] = data[1];
14			}
15		}
16
17		if (value[key]) {
18			return value[key];
19		} else {
20			return '';
21		}
22	} else { 			// Изменения для seo_url от Русской сборки OpenCart 3x
23		var query = String(document.location.pathname).split('/');
24		if (query[query.length - 1] == 'cart') value['route'] = 'checkout/cart';
25		if (query[query.length - 1] == 'checkout') value['route'] = 'checkout/checkout';
26		
27		if (value[key]) {
28			return value[key];
29		} else {
30			return '';
31		}
32	}
33}
34$(document).ready(function() {
35	// Highlight any found errors
36	$('.text-danger').each(function() {
37		var element = $(this).parent().parent();
38
39		if (element.hasClass('form-group')) {
40			element.addClass('has-error');
41		}
42	});
43
44	// Currency
45	$('#form-currency .currency-select').on('click', function(e) {
46		e.preventDefault();
47
48		$('#form-currency input[name=\'code\']').val($(this).attr('name'));
49
50		$('#form-currency').submit();
51	});
52
53	// Language
54	$('#form-language .language-select').on('click', function(e) {
55		e.preventDefault();
56
57		$('#form-language input[name=\'code\']').val($(this).attr('name'));
58
59		$('#form-language').submit();
60	});
61
62	/* Search */
63	$('#search input[name=\'search\']').parent().find('button').on('click', function() {
64		var url = $('base').attr('href') + 'index.php?route=product/search';
65
66		var value = $('header #search input[name=\'search\']').val();
67
68		if (value) {
69			url += '&search=' + encodeURIComponent(value);
70		}
71
72		location = url;
73	});
74
75	$('#search input[name=\'search\']').on('keydown', function(e) {
76		if (e.keyCode == 13) {
77			$('header #search input[name=\'search\']').parent().find('button').trigger('click');
78		}
79	});
80
81	// Menu
82	$('#menu .dropdown-menu').each(function() {
83		var menu = $('#menu').offset();
84		var dropdown = $(this).parent().offset();
85
86		var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth());
87
88		if (i > 0) {
89			$(this).css('margin-left', '-' + (i + 10) + 'px');
90		}
91	});
92
93	// Product List
94	$('#list-view').click(function() {
95		$('#content .product-grid > .clearfix').remove();
96
97		$('#content .row > .product-grid').attr('class', 'product-layout product-list col-xs-12');
98		$('#grid-view').removeClass('active');
99		$('#list-view').addClass('active');
100
101		localStorage.setItem('display', 'list');
102	});
103
104	// Product Grid
105	$('#grid-view').click(function() {
106		// What a shame bootstrap does not take into account dynamically loaded columns
107		var cols = $('#column-right, #column-left').length;
108
109		if (cols == 2) {
110			$('#content .product-list').attr('class', 'product-layout product-grid col-lg-6 col-md-6 col-sm-12 col-xs-12');
111		} else if (cols == 1) {
112			$('#content .product-list').attr('class', 'product-layout product-grid col-lg-4 col-md-4 col-sm-6 col-xs-12');
113		} else {
114			$('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-3 col-sm-6 col-xs-12');
115		}
116
117		$('#list-view').removeClass('active');
118		$('#grid-view').addClass('active');
119
120		localStorage.setItem('display', 'grid');
121	});
122
123	if (localStorage.getItem('display') == 'list') {
124		$('#list-view').trigger('click');
125		$('#list-view').addClass('active');
126	} else {
127		$('#grid-view').trigger('click');
128		$('#grid-view').addClass('active');
129	}
130
131	// Checkout
132	$(document).on('keydown', '#collapse-checkout-option input[name=\'email\'], #collapse-checkout-option input[name=\'password\']', function(e) {
133		if (e.keyCode == 13) {
134			$('#collapse-checkout-option #button-login').trigger('click');
135		}
136	});
137
138	// tooltips on hover
139	$('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
140
141	// Makes tooltips work on ajax generated content
142	$(document).ajaxStop(function() {
143		$('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
144	});
145});
146
147// Cart add remove functions
148var cart = {
149	'add': function(product_id, quantity) {
150		$.ajax({
151			url: 'index.php?route=checkout/cart/add',
152			type: 'post',
153			data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
154			dataType: 'json',
155			beforeSend: function() {
156				$('#cart > button').button('loading');
157			},
158			complete: function() {
159				$('#cart > button').button('reset');
160			},
161			success: function(json) {
162				$('.alert-dismissible, .text-danger').remove();
163
164				if (json['redirect']) {
165					location = json['redirect'];
166				}
167
168				if (json['success']) {
169					$('#content').parent().before('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
170
171					// Need to set timeout otherwise it wont update the total
172					setTimeout(function () {
173						$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
174					}, 100);
175
176					$('html, body').animate({ scrollTop: 0 }, 'slow');
177
178					$('#cart > ul').load('index.php?route=common/cart/info ul li');
179				}
180			},
181			error: function(xhr, ajaxOptions, thrownError) {
182				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
183			}
184		});
185	},
186	'update': function(key, quantity) {
187		$.ajax({
188			url: 'index.php?route=checkout/cart/edit',
189			type: 'post',
190			data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
191			dataType: 'json',
192			beforeSend: function() {
193				$('#cart > button').button('loading');
194			},
195			complete: function() {
196				$('#cart > button').button('reset');
197			},
198			success: function(json) {
199				// Need to set timeout otherwise it wont update the total
200				setTimeout(function () {
201					$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
202				}, 100);
203
204				if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
205					location = 'index.php?route=checkout/cart';
206				} else {
207					$('#cart > ul').load('index.php?route=common/cart/info ul li');
208				}
209			},
210			error: function(xhr, ajaxOptions, thrownError) {
211				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
212			}
213		});
214	},
215	'remove': function(key) {
216		$.ajax({
217			url: 'index.php?route=checkout/cart/remove',
218			type: 'post',
219			data: 'key=' + key,
220			dataType: 'json',
221			beforeSend: function() {
222				$('#cart > button').button('loading');
223			},
224			complete: function() {
225				$('#cart > button').button('reset');
226			},
227			success: function(json) {
228				// Need to set timeout otherwise it wont update the total
229				setTimeout(function () {
230					$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
231				}, 100);
232
233				if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
234					location = 'index.php?route=checkout/cart';
235				} else {
236					$('#cart > ul').load('index.php?route=common/cart/info ul li');
237				}
238			},
239			error: function(xhr, ajaxOptions, thrownError) {
240				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
241			}
242		});
243	}
244}
245
246var voucher = {
247	'add': function() {
248
249	},
250	'remove': function(key) {
251		$.ajax({
252			url: 'index.php?route=checkout/cart/remove',
253			type: 'post',
254			data: 'key=' + key,
255			dataType: 'json',
256			beforeSend: function() {
257				$('#cart > button').button('loading');
258			},
259			complete: function() {
260				$('#cart > button').button('reset');
261			},
262			success: function(json) {
263				// Need to set timeout otherwise it wont update the total
264				setTimeout(function () {
265					$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
266				}, 100);
267
268				if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
269					location = 'index.php?route=checkout/cart';
270				} else {
271					$('#cart > ul').load('index.php?route=common/cart/info ul li');
272				}
273			},
274			error: function(xhr, ajaxOptions, thrownError) {
275				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
276			}
277		});
278	}
279}
280
281var wishlist = {
282	'add': function(product_id) {
283		$.ajax({
284			url: 'index.php?route=account/wishlist/add',
285			type: 'post',
286			data: 'product_id=' + product_id,
287			dataType: 'json',
288			success: function(json) {
289				$('.alert-dismissible').remove();
290
291				if (json['redirect']) {
292					location = json['redirect'];
293				}
294
295				if (json['success']) {
296					$('#content').parent().before('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
297				}
298
299				$('#wishlist-total span').html(json['total']);
300				$('#wishlist-total').attr('title', json['total']);
301
302				$('html, body').animate({ scrollTop: 0 }, 'slow');
303			},
304			error: function(xhr, ajaxOptions, thrownError) {
305				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
306			}
307		});
308	},
309	'remove': function() {
310
311	}
312}
313
314var compare = {
315	'add': function(product_id) {
316		$.ajax({
317			url: 'index.php?route=product/compare/add',
318			type: 'post',
319			data: 'product_id=' + product_id,
320			dataType: 'json',
321			success: function(json) {
322				$('.alert-dismissible').remove();
323
324				if (json['success']) {
325					$('#content').parent().before('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
326
327					$('#compare-total').html(json['total']);
328
329					$('html, body').animate({ scrollTop: 0 }, 'slow');
330				}
331			},
332			error: function(xhr, ajaxOptions, thrownError) {
333				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
334			}
335		});
336	},
337	'remove': function() {
338
339	}
340}
341
342/* Agree to Terms */
343$(document).delegate('.agree', 'click', function(e) {
344	e.preventDefault();
345
346	$('#modal-agree').remove();
347
348	var element = this;
349
350	$.ajax({
351		url: $(element).attr('href'),
352		type: 'get',
353		dataType: 'html',
354		success: function(data) {
355			html  = '<div id="modal-agree" class="modal">';
356			html += '  <div class="modal-dialog">';
357			html += '    <div class="modal-content">';
358			html += '      <div class="modal-header">';
359			html += '        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>';
360			html += '        <h4 class="modal-title">' + $(element).text() + '</h4>';
361			html += '      </div>';
362			html += '      <div class="modal-body">' + data + '</div>';
363			html += '    </div>';
364			html += '  </div>';
365			html += '</div>';
366
367			$('body').append(html);
368
369			$('#modal-agree').modal('show');
370		}
371	});
372});
373
374// Autocomplete */
375(function($) {
376	$.fn.autocomplete = function(option) {
377		return this.each(function() {
378			this.timer = null;
379			this.items = new Array();
380
381			$.extend(this, option);
382
383			$(this).attr('autocomplete', 'off');
384
385			// Focus
386			$(this).on('focus', function() {
387				this.request();
388			});
389
390			// Blur
391			$(this).on('blur', function() {
392				setTimeout(function(object) {
393					object.hide();
394				}, 200, this);
395			});
396
397			// Keydown
398			$(this).on('keydown', function(event) {
399				switch(event.keyCode) {
400					case 27: // escape
401						this.hide();
402						break;
403					default:
404						this.request();
405						break;
406				}
407			});
408
409			// Click
410			this.click = function(event) {
411				event.preventDefault();
412
413				value = $(event.target).parent().attr('data-value');
414
415				if (value && this.items[value]) {
416					this.select(this.items[value]);
417				}
418			}
419
420			// Show
421			this.show = function() {
422				var pos = $(this).position();
423
424				$(this).siblings('ul.dropdown-menu').css({
425					top: pos.top + $(this).outerHeight(),
426					left: pos.left
427				});
428
429				$(this).siblings('ul.dropdown-menu').show();
430			}
431
432			// Hide
433			this.hide = function() {
434				$(this).siblings('ul.dropdown-menu').hide();
435			}
436
437			// Request
438			this.request = function() {
439				clearTimeout(this.timer);
440
441				this.timer = setTimeout(function(object) {
442					object.source($(object).val(), $.proxy(object.response, object));
443				}, 200, this);
444			}
445
446			// Response
447			this.response = function(json) {
448				html = '';
449
450				if (json.length) {
451					for (i = 0; i < json.length; i++) {
452						this.items[json[i]['value']] = json[i];
453					}
454
455					for (i = 0; i < json.length; i++) {
456						if (!json[i]['category']) {
457							html += '<li data-value="' + json[i]['value'] + '"><a href="#">' + json[i]['label'] + '</a></li>';
458						}
459					}
460
461					// Get all the ones with a categories
462					var category = new Array();
463
464					for (i = 0; i < json.length; i++) {
465						if (json[i]['category']) {
466							if (!category[json[i]['category']]) {
467								category[json[i]['category']] = new Array();
468								category[json[i]['category']]['name'] = json[i]['category'];
469								category[json[i]['category']]['item'] = new Array();
470							}
471
472							category[json[i]['category']]['item'].push(json[i]);
473						}
474					}
475
476					for (i in category) {
477						html += '<li class="dropdown-header">' + category[i]['name'] + '</li>';
478
479						for (j = 0; j < category[i]['item'].length; j++) {
480							html += '<li data-value="' + category[i]['item'][j]['value'] + '"><a href="#">&nbsp;&nbsp;&nbsp;' + category[i]['item'][j]['label'] + '</a></li>';
481						}
482					}
483				}
484
485				if (html) {
486					this.show();
487				} else {
488					this.hide();
489				}
490
491				$(this).siblings('ul.dropdown-menu').html(html);
492			}
493
494			$(this).after('<ul class="dropdown-menu"></ul>');
495			$(this).siblings('ul.dropdown-menu').delegate('a', 'click', $.proxy(this.click, this));
496
497		});
498	}
499})(window.jQuery);

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.