PageSourceSearch

https://www.arthuss.com.ua/catalog/view/javascript/common1.js

js arthuss.com.ua collected 2026-09-24 18:32:51 UTC 34,922 bytes, 963 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    }
23}
24
25$(document).ready(function () {
26    $('input[type="tel"]').mask('+38 (999) 999-99-99');
27    // Highlight any found errors
28    $('.text-danger').each(function () {
29        var element = $(this).parent().parent();
30
31        if (element.hasClass('form-group')) {
32            element.addClass('has-error');
33        }
34    });
35
36    // Currency
37    $('#form-currency .currency-select').on('click', function (e) {
38        e.preventDefault();
39
40        $('#form-currency input[name=\'code\']').val($(this).attr('name'));
41
42        $('#form-currency').submit();
43    });
44
45    // Language
46    $('#form-language .language-select').on('click', function (e) {
47        e.preventDefault();
48
49        $('#form-language input[name=\'code\']').val($(this).attr('name'));
50
51        $('#form-language').submit();
52    });
53
54    /* Search */
55    $('.search-page #search input[name=\'search\']').parent().find('button').on('click', function () {
56        var url = $('base').attr('href') + 'index.php?route=product/search';
57
58        var value = $('.search-page #search input[name=\'search\']').val();
59
60        if (value) {
61            url += '&search=' + encodeURIComponent(value);
62        }
63
64        location = url;
65    });
66
67    $('.search-page #search input[name=\'search\']').on('keydown', function (e) {
68        if (e.keyCode == 13) {
69            $('.search-page #search input[name=\'search\']').parent().find('button').trigger('click');
70        }
71    });
72
73    $('header #button-search').on('click', function () {
74        $(this).parent().find('.more').trigger('click');
75    });
76
77    $('header #search input[name=\'search\']').on('keydown', function (e) {
78        if (e.keyCode == 13) {
79            $(this).parent().find('.more').trigger('click');
80        }
81    });
82
83    // Menu
84    $('#menu .dropdown-menu').each(function () {
85        var menu = $('#menu').offset();
86        var dropdown = $(this).parent().offset();
87
88        var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth());
89
90        if (i > 0) {
91            $(this).css('margin-left', '-' + (i + 10) + 'px');
92        }
93    });
94
95    // Product List
96    $('#list-view').click(function () {
97        $('.shop .shop__products').attr('class', 'shop__products shop__products_list');
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        $('.shop .shop__products').attr('class', 'shop__products shop__products_grid');
107        $('#list-view').removeClass('active');
108        $('#grid-view').addClass('active');
109
110        localStorage.setItem('display', 'grid');
111    });
112
113    if (localStorage.getItem('display') == 'list') {
114        $('#list-view').trigger('click');
115        $('#list-view').addClass('active');
116    } else {
117        $('#grid-view').trigger('click');
118        $('#grid-view').addClass('active');
119    }
120
121    // Checkout
122    $(document).on('keydown', '#collapse-checkout-option input[name=\'email\'], #collapse-checkout-option input[name=\'password\']', function (e) {
123        if (e.keyCode == 13) {
124            $('#collapse-checkout-option #button-login').trigger('click');
125        }
126    });
127
128    // tooltips on hover
129    $('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
130
131    // Makes tooltips work on ajax generated content
132    $(document).ajaxStop(function () {
133        $('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
134    });
135});
136
137// Cart add remove functions
138/*var cart = {
139	'add': function(product_id, quantity) {
140		$.ajax({
141			url: 'index.php?route=checkout/cart/add',
142			type: 'post',
143			data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
144			dataType: 'json',
145			beforeSend: function() {
146				$('#cart > button').button('loading');
147			},
148			complete: function() {
149				$('#cart > button').button('reset');
150			},
151			success: function(json) {
152				$('.alert-dismissible, .text-danger').remove();
153
154				if (json['redirect']) {
155					location = json['redirect'];
156				}
157
158				if (json['success']) {
159					$('#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>');
160
161					// Need to set timeout otherwise it wont update the total
162					setTimeout(function () {
163						$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
164					}, 100);
165
166					$('html, body').animate({ scrollTop: 0 }, 'slow');
167
168					$('#cart > ul').load('index.php?route=common/cart/info ul li');
169				}
170			},
171			error: function(xhr, ajaxOptions, thrownError) {
172				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
173			}
174		});
175	},
176	'update': function(key, quantity) {
177		$.ajax({
178			url: 'index.php?route=checkout/cart/edit',
179			type: 'post',
180			data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
181			dataType: 'json',
182			beforeSend: function() {
183				$('#cart > button').button('loading');
184			},
185			complete: function() {
186				$('#cart > button').button('reset');
187			},
188			success: function(json) {
189				// Need to set timeout otherwise it wont update the total
190				setTimeout(function () {
191					$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
192				}, 100);
193
194				if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
195					location = 'index.php?route=checkout/cart';
196				} else {
197					$('#cart > ul').load('index.php?route=common/cart/info ul li');
198				}
199			},
200			error: function(xhr, ajaxOptions, thrownError) {
201				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
202			}
203		});
204	},
205	'remove': function(key) {
206		$.ajax({
207			url: 'index.php?route=checkout/cart/remove',
208			type: 'post',
209			data: 'key=' + key,
210			dataType: 'json',
211			beforeSend: function() {
212				$('#cart > button').button('loading');
213			},
214			complete: function() {
215				$('#cart > button').button('reset');
216			},
217			success: function(json) {
218				// Need to set timeout otherwise it wont update the total
219				setTimeout(function () {
220					$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
221				}, 100);
222
223				if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
224					location = 'index.php?route=checkout/cart';
225				} else {
226					$('#cart > ul').load('index.php?route=common/cart/info ul li');
227				}
228			},
229			error: function(xhr, ajaxOptions, thrownError) {
230				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
231			}
232		});
233	}
234}*/
235function updateItems() {
236    $.ajax({
237        url: 'index.php?route=common/cart/getItems',
238        type: 'post',
239        dataType: 'json',
240        success: function (json) {
241            if (json['text_items']) {
242                if ($('#cart-total').val() === '') {
243                    $('#cart-total').css('display', 'flex');
244                    $('#cart-total').text(json['text_items']);
245                    $('.bag > svg').html('<use href="catalog/view/theme/arthuss/img/sprite/sprite.svg#basketActive"></use>');
246                } else {
247                    $('#cart-total').text(json['text_items']);
248                }
249            }
250        },
251        error: function () {
252            alert('Ошибка');
253        }
254    });
255}
256
257var cart = {
258    'add2': function (product_id, list_name, quantity) {
259
260        $.ajax({
261            url: 'index.php?route=checkout/cart/add',
262            type: 'post',
263            data: 'product_id=' + product_id + '&quantity=' + (typeof (quantity) != 'undefined' ? quantity : 1),
264            dataType: 'json',
265            success: function (json) {
266                $('.alert, .text-danger').remove();
267
268                if (json['redirect']) {
269                    location = json['redirect'];
270                }
271
272                if (json['success']) {
273                    $('.shop__alert').prepend('<div class="shop__alert-text">' + json['success'] + '</div>');
274                    $('.shop__alert').addClass('active');
275
276                    setTimeout(function () {
277                        $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
278                    }, 100);
279                    updateItems();
280
281                    $('#cart > ul').load('index.php?route=common/cart/info ul li');
282                    $('body').addClass('background');
283
284                    // --- GA4 AddToCart ---
285                    dataLayer.push({ecommerce: null});
286                    const eventIdConversion = generateEventId('cart_
286conv_');
287                    const eventIdRemarketing = generateEventId('cart_remark_');
288
289                    let o = {
290                        event: "add_to_cart",
291                        ecommerce: {
292                            currency: "UAH",
293                            value: json['price'],
294                            items: [
295                                {
296                                    item_id: product_id,
297                                    item_name: json['item_name'],
298                                    author: json['manufacturer'],
299                                    price: json['price'],
300                                    item_category: json.item_category,
301                                    item_category2: json.item_category2,
302                                    item_category3: json.item_category3
303                                }
304                            ],
305                            event_id: eventIdConversion // важливо для дедуплікації
306                        }
307                    };
308                    dataLayer.push(o);
309                    console.log(o);
310
311                    // --- Meta Conversions API ---
312                    const hashedEmail = umGetCookie('u_em') || null;
313                    const hashedPhone = umGetCookie('u_ph') || null;
314
315                    // 1. Звичайна конверсія
316                    sendEventToServer({
317                        event_name: 'AddToCart',
318                        event_id: eventIdConversion,
319                        event_source_url: window.location.href,
320                        em: hashedEmail,
321                        ph: hashedPhone,
322                        custom_data: {
323                            value: json['price'],
324                            currency: 'UAH'
325                        }
326                    });
327
328                    // 2. Динамічний ремаркетинг
329                    sendEventToServer({
330                        event_name: 'AddToCart',
331                        event_id: eventIdRemarketing,
332                        event_source_url: window.location.href,
333                        em: hashedEmail,
334                        ph: hashedPhone,
335                        custom_data: {
336                            content_ids: [product_id.toString()],
337                            value: json['price'],
338                            currency: 'UAH',
339                            content_name: json['item_name'],
340                            content_category: json.item_category,
341                            content_type: 'product',
342                            contents: [{
343                                id: product_id.toString(),
344                                quantity: (typeof (quantity) != 'undefined' ? quantity : 1),
345                                item_price: json['price']
346                            }]
347                        }
348                    });
349                }
350            },
351            error: function (xhr, ajaxOptions, thrownError) {
352                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
353            }
354        });
355    },
356    'add4': function (product_id, quantity) {
357
358        $.ajax({
359            url: 'index.php?route=checkout/cart/add',
360            type: 'post',
361            data: 'product_id=' + product_id + '&quantity=' + (typeof (quantity) != 'undefined' ? quantity : 1),
362            dataType: 'json',
363
364            success: function (json) {
365                $('.alert, .text-danger').remove();
366
367                if (json['redirect']) {
368                    location = json['redirect'];
369                }
370
371                if (json['success']) {
372                    // Need to set timeout otherwise it wont update the total
373                    setTimeout(function () {
374                        $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
375                    }, 100);
376
377                    updateItems();
378                    $('html, body').animate({scrollTop: 0}, 'slow');
379
380                    $('#cart > ul').load('index.php?route=common/cart/info ul li');
381                }
382            },
383            error: function (xhr, ajaxOptions, thrownError) {
384                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
385            }
386        });
387    },
388    'add5': function (product_id, quantity) {
389
390        $.ajax({
391            url: 'index.php?route=checkout/cart/add',
392            type: 'post',
393            data: 'product_id=' + product_id + '&quantity=' + (typeof (quantity) != 'undefined' ? quantity : 1),
394            dataType: 'json',
395
396            success: function (json) {
397
398                dataLayer.push({ecommerce: null});
399
400                const eventIdConversion = generateEventId('cart_
400conv_');
401                const eventIdRemarketing = generateEventId('cart_remark_');
402
403                let o = {
404                    event: "add_to_cart",
405                    ecommerce: {
406                        currency: "UAH",
407                        value: json['price'],
408                        items: [
409                            {
410                                item_id: product_id,
411                                item_name: json['item_name'],
412                                author: json['manufacturer'],
413                                price: json['price'],
414                                item_category: json.item_category,
415                                item_category2: json.item_category2,
416                                item_category3: json.item_category3
417                            }
418                        ],
419                        event_id: eventIdConversion // важливо для дедуплікації
420                    }
421                };
422                dataLayer.push(o);
423                console.log(o);
424
425                // Meta Conversions API
426                const hashedEmail = umGetCookie('u_em') || null;
427                const hashedPhone = umGetCookie('u_ph') || null;
428
429                // 1. Звичайна конверсія
430                sendEventToServer({
431                    event_name: 'AddToCart',
432                    event_id: eventIdConversion,
433                    event_source_url: window.location.href,
434                    em: hashedEmail,
435                    ph: hashedPhone,
436                    custom_data: {
437                        value: json['price'],
438                        currency: 'UAH'
439                    }
440                });
441
442                // 2. Динамічний ремаркетинг
443                sendEventToServer({
444                    event_name: 'AddToCart',
445                    event_id: eventIdRemarketing,
446                    event_source_url: window.location.href,
447                    em: hashedEmail,
448                    ph: hashedPhone,
449                    custom_data: {
450                        content_ids: [product_id.toString()],
451                        value: json['price'],
452                        currency: 'UAH',
453                        content_name: json['item_name'],
454                        content_category: json.item_category,
455                        content_type: 'product',
456                        contents: [{
457                            id: product_id.toString(),
458                            quantity: (typeof (quantity) != 'undefined' ? quantity : 1),
459                            item_price: json['price']
460                        }]
461                    }
462                });
463            },
464            error: function (xhr, ajaxOptions, thrownError) {
465                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
466            }
467        });
468    },
469    'add3': function (product_id, quantity) {
470
471        $.ajax({
472            url: 'index.php?route=checkout/cart/add',
473            type: 'post',
474            data: 'product_id=' + product_id + '&quantity=' + (typeof (quantity) != 'undefined' ? quantity : 1),
475            dataType: 'json',
476            success: function (json) {
477                if (json['success']) {
478                    dataLayer.push({ecommerce: null});  // Clear the previous ecommerce object.
479
480                    const eventIdConversion = generateEventId('cart_conv_');
481                    const eventIdRemarketing = generateEventId('cart_remark_');
482
483                    let o = {
484                        event: "add_to_cart",
485                        ecommerce: {
486                            currency: "UAH",
487                            value: json['price'],
488                            items: [
489                                {
490                                    item_id: product_id,
491                                    item_name: json['item_name'],
492                                    author: json['manufacturer'],
493                                    price: json['price'],
494                                    item_category: json.item_category,
495                                    item_category2: json.item_category2,
496                                    item_category3: json.item_category3
497                                }
498                            ],
499                            event_id: eventIdConversion // важливо для дедуплікації
500                        }
501                    };
502                    dataLayer.push(o);
503                    console.log(o);
504
505                    // Meta Conversions API
506                    const hashedEmail = umGetCookie('u_em') || null;
507                    const hashedPhone = umGetCookie('u_ph') || null;
508
509                    // 1. Звичайна конверсія
510                    sendEventToServer({
511                        event_name: 'AddToCart',
512                        event_id: eventIdConversion,
513                        event_source_url: window.location.href,
514                        em: hashedEmail,
515                        ph: hashedPhone,
516                        custom_data: {
517                            value: json['price'],
518                            currency: 'UAH'
519                        }
520                    });
521
522                    // 2. Динамічний ремаркетинг
523                    sendEventToServer({
524                        event_name: 'AddToCart',
525                        event_id: eventIdRemarketing,
526                        event_source_url: window.location.href,
527                        em: hashedEmail,
528                        ph: hashedPhone,
529                        custom_data: {
530                            content_ids: [product_id.toString()],
531                            value: json['price'],
532                            currency: 'UAH',
533                            content_name: json['item_name'],
534                            content_category: json.item_category,
535                            content_type: 'product',
536                            contents: [{
537                                id: product_id.toString(),
538                                quantity: (typeof (quantity) != 'undefined' ? quantity : 1),
539                                item_price: json['price']
540                            }]
541                        }
542                    });
543
544                    location.reload();
545                }
546            },
547            error: function (xhr, ajaxOptions, thrownError) {
548                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
549            }
550        });
551    },
552    'add': function (product_id, quantity) {
553
554        $.ajax({
555            url: 'index.php?route=checkout/cart/add',
556            type: 'post',
557            data: 'product_id=' + product_id + '&quantity=' + (typeof (quantity) != 'undefined' ? quantity : 1),
558            dataType: 'json',
559            success: function (json) {
560                $('.alert, .text-danger').remove();
561
562                if (json['redirect']) {
563                    location = json['redirect'];
564                }
565
566                if (json['success']) {
567                    $('.shop__alert').prepend('<div class="shop__alert-text">' + json['success'] + '</div>');
568                    $('.shop__alert').addClass('active');
569                    updateItems();
570                    $('#cart > ul').load('index.php?route=common/cart/info ul li');
571
572                    dataLayer.push({ecommerce: null});  // Clear the previous ecommerce object.
573
574                    const eventIdConversion = generateEventId('cart_
574conv_');
575                    const eventIdRemarketing = generateEventId('cart_remark_');
576
577                    let o = {
578                        event: "add_to_cart",
579                        ecommerce: {
580                            currency: "UAH",
581                            value: json['price'],
582                            items: [
583                                {
584                                    item_id: product_id,
585                                    item_name: json['item_name'],
586                                    author: json['manufacturer'],
587                                    price: json['price'],
588                                    item_category: json.item_category,
589                                    item_category2: json.item_category2,
590                                    item_category3: json.item_category3
591                                }
592                            ],
593                            event_id: eventIdConversion // важливо для дедуплікації
594                        }
595                    };
596                    dataLayer.push(o);
597                    console.log(o);
598
599                    // Meta Conversions API
600                    const hashedEmail = umGetCookie('u_em') || null;
601                    const hashedPhone = umGetCookie('u_ph') || null;
602
603                    // 1. Звичайна конверсія
604                    sendEventToServer({
605                        event_name: 'AddToCart',
606                        event_id: eventIdConversion,
607                        event_source_url: window.location.href,
608                        em: hashedEmail,
609                        ph: hashedPhone,
610                        custom_data: {
611                            value: json['price'],
612                            currency: 'UAH'
613                        }
614                    });
615
616                    // 2. Динамічний ремаркетинг
617                    sendEventToServer({
618                        event_name: 'AddToCart',
619                        event_id: eventIdRemarketing,
620                        event_source_url: window.location.href,
621                        em: hashedEmail,
622                        ph: hashedPhone,
623                        custom_data: {
624                            content_ids: [product_id.toString()],
625                            value: json['price'],
626                            currency: 'UAH',
627                            content_name: json['item_name'],
628                            content_category: json.item_category,
629                            content_type: 'product',
630                            contents: [{
631                                id: product_id.toString(),
632                                quantity: (typeof (quantity) != 'undefined' ? quantity : 1),
633                                item_price: json['price']
634                            }]
635                        }
636                    });
637                }
638            },
639            error: function (xhr, ajaxOptions, thrownError) {
640                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
641            }
642        });
643    },
644
645    'update': function (key, quantity) {
646        $.ajax({
647            url: 'index.php?route=checkout/cart/edit',
648            type: 'post',
649            data: 'key=' + key + '&quantity=' + (typeof (quantity) != 'undefined' ? quantity : 1),
650            dataType: 'json',
651            beforeSend: function () {
652                $('#cart > button').button('loading');
653            },
654            complete: function () {
655                $('#cart > button').button('reset');
656            },
657            success: function (json) {
658                // Need to set timeout otherwise it wont update the total
659                setTimeout(function () {
660                    $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
661                }, 100);
662
663                if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
664                    location = 'index.php?route=checkout/cart';
665                } else {
666                    $('#cart > ul').load('index.php?route=common/cart/info ul li');
667                }
668            },
669            error: function (xhr, ajaxOptions, thrownError) {
670                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
671            }
672        });
673    },
674    'remove': function (key) {
675        $.ajax({
676            url: 'index.php?route=checkout/cart/remove',
677            type: 'post',
678            data: 'key=' + key,
679            dataType: 'json',
680            beforeSend: function () {
681                $('#cart > button').button('loading');
682            },
683            complete: function () {
684                $('#cart > button').button('reset');
685            },
686            success: function (json) {
687                // Need to set timeout otherwise it wont update the total
688                location.reload();
689                /*setTimeout(function () {
690                  $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
691                }, 100);
692        
693                var now_location = String(document.location.pathname);
694        
695                if ((now_location == '/cart/') || (now_location == '/checkout/') || (getURLVar('route') == 'checkout/cart') || (getURLVar('route') == 'checkout/checkout')) {
696                  location = 'index.php?route=checkout/cart';
697                } else {
698                  $('#cart > ul').load('index.php?route=common/cart/info ul li');
699                }*/
700            },
701            error: function (xhr, ajaxOptions, thrownError) {
702                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
703            }
704        });
705    }
706}
707
708var voucher = {
709    'add': function () {
710
711    },
712    'remove': function (key) {
713        $.ajax({
714            url: 'index.php?route=checkout/cart/remove',
715            type: 'post',
716            data: 'key=' + key,
717            dataType: 'json',
718            beforeSend: function () {
719                $('#cart > button').button('loading');
720            },
721            complete: function () {
722                $('#cart > button').button('reset');
723            },
724            success: function (json) {
725                // Need to set timeout otherwise it wont update the total
726                setTimeout(function () {
727                    $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
728                }, 100);
729
730                if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
731                    location = 'index.php?route=checkout/cart';
732                } else {
733                    $('#cart > ul').load('index.php?route=common/cart/info ul li');
734                }
735            },
736            error: function (xhr, ajaxOptions, thrownError) {
737                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
738            }
739        });
740    }
741}
742
743var wishlist = {
744    'add': function (product_id) {
745        $.ajax({
746            url: 'index.php?route=account/wishlist/add',
747            type: 'post',
748            data: 'product_id=' + product_id,
749            dataType: 'json',
750            success: function (json) {
751                $('.alert-dismissible').remove();
752
753                if (json['redirect']) {
754                    location = json['redirect'];
755                }
756
757                if (json['success']) {
758                    $('.product__mid .wishlist').after('<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>');
759                    $('header .wishlist span').html(json['total']);
760                }
761
762                $('header .wishlist span').addClass('no_empty');
763
764                $('#wishlist-total').attr('title', json['total']);
765
766                /*$('html, body').animate({ scrollTop: 0 }, 'slow');*/
767            },
768            error: function (xhr, ajaxOptions, thrownError) {
769                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
770            }
771        });
772    },
773    'remove': function () {
774
775    }
776}
777
778var compare = {
779    'add': function (product_id) {
780        $.ajax({
781            url: 'index.php?route=product/compare/add',
782            type: 'post',
783            data: 'product_id=' + product_id,
784            dataType: 'json',
785            success: function (json) {
786                $('.alert-dismissible').remove();
787
788                if (json['success']) {
789                    $('#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>');
790
791                    $('#compare-total').html(json['total']);
792
793                    $('html, body').animate({scrollTop: 0}, 'slow');
794                }
795            },
796            error: function (xhr, ajaxOptions, thrownError) {
797                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
798            }
799        });
800    },
801    'remove': function () {
802
803    }
804}
805
806/* Agree to Terms */
807$(document).delegate('.agree', 'click', function (e) {
808    e.preventDefault();
809
810    $('#modal-agree').remove();
811
812    var element = this;
813
814    $.ajax({
815        url: $(element).attr('href'),
816        type: 'get',
817        dataType: 'html',
818        success: function (data) {
819            html = '<div id="modal-agree" class="modal">';
820            html += '  <div class="modal-dialog">';
821            html += '    <div class="modal-content">';
822            html += '      <div class="modal-header">';
823            html += '        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>';
824            html += '        <h4 class="modal-title">' + $(element).text() + '</h4>';
825            html += '      </div>';
826            html += '      <div class="modal-body">' + data + '</div>';
827            html += '    </div>';
828            html += '  </div>';
829            html += '</div>';
830
831            $('body').append(html);
832
833            $('#modal-agree').modal('show');
834        }
835    });
836});
837
838// Autocomplete */
839/*(function($) {
840	$.fn.autocomplete = function(option) {
841		return this.each(function() {
842			this.timer = null;
843			this.items = new Array();
844
845			$.extend(this, option);
846
847			$(this).attr('autocomplete', 'off');
848
849			// Focus
850			$(this).on('focus', function() {
851				this.request();
852			});
853
854			// Blur
855			$(this).on('blur', function() {
856				setTimeout(function(object) {
857					object.hide();
858				}, 200, this);
859			});
860
861			// Keydown
862			$(this).on('keydown', function(event) {
863				switch(event.keyCode) {
864					case 27: // escape
865						this.hide();
866						break;
867					default:
868						this.request();
869						break;
870				}
871			});
872
873			// Click
874			this.click = function(event) {
875				event.preventDefault();
876
877				value = $(event.target).parent().attr('data-value');
878
879				if (value && this.items[value]) {
880					this.select(this.items[value]);
881				}
882			}
883
884			// Show
885			this.show = function() {
886				var pos = $(this).position();
887
888				$(this).siblings('ul.dropdown-menu').css({
889					top: pos.top + $(this).outerHeight(),
890					left: pos.left
891				});
892
893				$(this).siblings('ul.dropdown-menu').show();
894			}
895
896			// Hide
897			this.hide = function() {
898				$(this).siblings('ul.dropdown-menu').hide();
899			}
900
901			// Request
902			this.request = function() {
903				clearTimeout(this.timer);
904
905				this.timer = setTimeout(function(object) {
906					object.source($(object).val(), $.proxy(object.response, object));
907				}, 200, this);
908			}
909
910			// Response
911			this.response = function(json) {
912				html = '';
913
914				if (json.length) {
915					for (i = 0; i < json.length; i++) {
916						this.items[json[i]['value']] = json[i];
917					}
918
919					for (i = 0; i < json.length; i++) {
920						if (!json[i]['category']) {
921							html += '<li data-value="' + json[i]['value'] + '"><a href="#">' + json[i]['label'] + '</a></li>';
922						}
923					}
924
925					// Get all the ones with a categories
926					var category = new Array();
927
928					for (i = 0; i < json.length; i++) {
929						if (json[i]['category']) {
930							if (!category[json[i]['category']]) {
931								category[json[i]['category']] = new Array();
932								category[json[i]['category']]['name'] = json[i]['category'];
933								category[json[i]['category']]['item'] = new Array();
934							}
935
936							category[json[i]['category']]['item'].push(json[i]);
937						}
938					}
939
940					for (i in category) {
941						html += '<li class="dropdown-header">' + category[i]['name'] + '</li>';
942
943						for (j = 0; j < category[i]['item'].length; j++) {
944							html += '<li data-value="' + category[i]['item'][j]['value'] + '"><a href="#">&nbsp;&nbsp;&nbsp;' + category[i]['item'][j]['label'] + '</a></li>';
945						}
946					}
947				}
948
949				if (html) {
950					this.show();
951				} else {
952					this.hide();
953				}
954
955				$(this).siblings('ul.dropdown-menu').html(html);
956			}
957
958			$(this).after('<ul class="dropdown-menu"></ul>');
959			$(this).siblings('ul.dropdown-menu').delegate('a', 'click', $.proxy(this.click, this));
960
961		});
962	}
963})(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.