PageSourceSearch

https://www.successfulmat.com/frontend/js/cart.js

js successfulmat.com collected 2026-10-04 04:51:20 UTC 5,656 bytes, 145 lines download raw bytes

1$( document ).ready( function() {
2    window.carRequest = {};
3    window.onEvent = 0;
4    window.upper = 999;
5
6    $('body').delegate("[data-amount]:attrStart(data-car)", 'click', function(e){
7        let $this = $(this);
8        let amount = $this.attr("data-amount");
9        let id = $this.attr("data-id");
10        let token = $('meta[name=csrf-token]').attr('content');
11        let isPut =  $this.attr("data-put");
12        let type, deleteTarget;
13        for (attr of this.attributes)
14            if (attr.name.startsWith('data-car'))
15                type = attr.name.replace('data-car-', '');
16
17        if ((amount != 0 || isPut == 'true') && type) {
18            if (window.carRequest[type] != null) {
19                e.preventDefault();
20                return;
21            }
22
23            $.ajax({
24                url: `/${type}/car`,
25                type : 'post',
26                data : {
27                    '_token' : token,
28                    'amount' : amount,
29                    'isPut' : isPut,
30                    'id': id,
31                },
32                beforeSend: function( xhr ) {
33                    $(":attrStart(data-car)").css('cursor', 'not-allowed');
34
35                    if (window.carRequest[type] != null){
36                        window.carRequest[type].abort();
37                    }
38                    window.carRequest[type] = xhr;
39                    $this.append(window.loadingIcon);
40                },
41                error: function(data){
42                    Swal.fire({
43                        icon: 'error',
44                        title: window.carText.inquiry.errorTitle,
45                        text: window.carText.inquiry.errorTxt,
46                    }).then(function() {
47                        window.location.reload()
48                    });
49                }
50            }).done(function(data) {
51                $(":attrStart(data-car)").css('cursor', '');
52                window.carRequest[type] = null;
53                $this.find(window.loadingIcon).remove();
54                data = JSON.parse(data);
55                $(`[data-${type}-count]`).text(data['count']);
56                $(`[data-${type}-amount]`).text(data['amount']);
57                $(`[data-${type}-count]`).parent()[(data['count'] < 1) ? 'addClass' : 'removeClass']('b-disabled')
58                $(`[data-${type}-amount]`).parent()[(data['amount'] < 1) ? 'addClass' : 'removeClass']('b-disabled')
59                if ($inputs = $('[data-cart-input]').length > 0) {
60                    var sum = 0;
61                    $('[data-cart-input]').each(function() {
62                        sum += Number($(this).val());
63                    });
64                    if (data['amount'] != sum) {
65                        $this.click()
66                    }
67                    if (data['amount'] == 0) {
68                        window.location.reload()
69                    }
70                }
71
72
73                let amount = $this.attr('data-amount') ?? 0;
74
75                if (amount > 0) {
76                    $modal = $(`[data-${type}-modal]`).modal();
77                    $modal.find('[data-name]').text($this.attr("data-modal-name"))
78                    $modal.find('[data-model]').text($this.attr("data-modal-model"))
79                    $modal.find('[data-img]').attr('src',$this.attr("data-modal-img"))
80                }
81                if ($this.is('[data-only]')) {
82                    $this.attr("data-amount", 0)
83                    $this.html('<i class="fa fa-shopping-cart" aria-hidden="true"></i>'+window.carText.inquiry.InInquiry);
84                }
85                if (data['count'] == 0 && data['amount'] == 0) {
86                    window.location.reload()
87                }
88            });
89
90            if (deleteTarget = $this.attr('data-delete')) {
91                $this.closest(deleteTarget).remove();
92            }
93        }
94
95    }).delegate("[data-cart-changer]", 'click', function () {
96        window.onEvent += 1;
97        if (window.onEvent != 1) {
98            window.onEvent -= 1;
99            e.preventDefault();
100            return
101        }
102        $allCar = $(":attrStart(data-car)").css('cursor', 'not-allowed');
103
104        let $input, id;
105        id = $(this).attr('data-id');
106        $input = $(this).siblings("[data-cart-input]");
107        amount = Number($input.val()) + Number($(this).attr('data-change'));
108        amount = amount > window.upper ? window.upper : amount;
109        $input.val(amount);
110
111        $button = $(`[data-id=${id}][data-amount]:attrStart(data-car)`);
112        if (amount < 1) {
113            amount = 0;
114            $button.attr('data-delete',"tr")
115        }
116        $button.attr('data-amount',amount);
117        $button.attr('data-link') == "true" ? $button.click() : $allCar.css('cursor', '');
118        window.onEvent -= 1
119    }).delegate("[data-cart-input]", 'change', function () {
120        window.onEvent += 1;
121        if (window.onEvent != 1) {
122            window.onEvent -= 1;
123            e.preventDefault();
124            return
125        }
126        $allCar = $(":attrStart(data-car)").css('cursor', 'not-allowed');
127
128        let id;
129        id = $(this).attr('data-id');
130        amount = Number($(this).val());
131        if (amount > window.upper) {
132            amount = window.upper;
133            $(this).val(amount)
134        }
135
136        $button = $(`[data-id=${id}][data-amount]:attrStart(data-car)`);
137        if (amount < 1 || isNaN(amount)) {
138            amount = 0;
139            $button.attr('data-delete',"tr")
140        }
141        $button.attr('data-amount',amount);
142        $button.attr('data-link') == "true" ? $button.click() : $allCar.css('cursor', '');
143        window.onEvent -= 1;
144    });
145} );

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.