PageSourceSearch

https://www.sportaberdeen.co.uk/wp-content/plugins/MtcEventsExtension/assets/js/mtc-events.js?ver=598851397

js sportaberdeen.co.uk collected 2026-09-24 12:15:54 UTC 4,142 bytes, 121 lines download raw bytes

1jQuery(document).ready(function ($) {
2    setTimeout(function () {
3        var event_table = $('#mage_event_submit'),
4            tickets_left = parseInt(event_table.find('.total-col .qty').attr('max')),
5            quantities = event_table.find('[name="option_qty[]"]'),
6            qty_left = tickets_left,
7            total_added = 0,
8            adult_required = $('#adult_required').val(),
9            adults_tickets = 0;
10
11        event_table.removeAttr('novalidate')
12        quantities.each(function () {
13            var _this = $(this),
14                current_qty = parseInt(_this.val());
15
16            // change the inout on read only
17            _this.prop('readonly', true);
18
19            // check if qty is increasing or decreasing
20            _this.on('keyup', function (e) {
21                var new_qty = parseInt($(this).val()),
22                    qty_left = tickets_left - total_added;
23
24                // check if the qty adde is more than the total left
25                if (new_qty) {
26                    // if (new_qty > qty_left) {
27                    //     new_qty = qty_left;
28                    // }
29
30                    if (new_qty > current_qty) {
31                        var qty_to_add = new_qty - current_qty;
32                        total_added += qty_to_add;
33                    }
34
35                    if (new_qty < current_qty) {
36                        var qty_to_remove = current_qty - new_qty;
37                        total_added -= qty_to_remove;
38                    }
39
40                    // generate qty left after all the above finished
41
42
43                    // console.log('total: ' + total_added);
44                    // console.log('new qty: ' + new_qty);
45                    // console.log('current qty: ' + current_qty);
46                    // console.log('qty left: ' + qty_left, );
47                    // console.log('all tickets: ' + tickets_left);
48                }
49            });
50
51            _this.attr('max', tickets_left);
52        });
53
54        $('.qty_dec').on('click', function () {
55            let target = $(this).siblings('input'),
56                value = parseInt(target.val());
57
58            if (value != 0 && value > 0) {
59                total_added--;
60                qty_left = tickets_left - total_added;
61            }
62
63            // console.log('total: ' + total_added);
64            // console.log('qty left: ' + qty_left, );
65        });
66
67        $('.qty_inc').on('click', function (e) {
68            let target = $(this).siblings('input'),
69                value = parseInt(target.val()),
70                _id = target.attr('id');
71
72            // get qty added on the others
73            let _inputs = event_table.find('[name="option_qty[]"]'),
74                _totals = [];
75
76
77            _inputs.each(function () {
78                var _val = parseInt($(this).val()),
79                    _other_id = $(this).attr('id');
80
81                if (_id != _other_id) {
82                    _totals.push(_val);
83                }
84
85            });
86            let _max = _totals.reduce((total, size) => {
87                return total + size
88            });
89            target.attr('max', tickets_left - _max);
90
91            if (qty_left != 0 && value > 0) {
92                total_added++;
93                qty_left = tickets_left - total_added;
94            }
95
96            // console.log('total: ' + _totals);
97            // console.log('qty left: ' + qty_left, );
98        });
99
100        $('.btn-mep-event-cart').click(function (e) {
101            $('#adult_alert').remove();
102        });
103
104        event_table.on('submit', function (e) {
105
106            adults_tickets = $('#eventpxtp_1').val();
107
108            if (adult_required == 'yes' && adults_tickets == 0) {
109                $('html, body').animate({
110                    scrollTop: $('#mage_event_submit').offset().top - 100
111                }, 'slow');
112
113                $('#mage_event_submit').prepend('<div class="alert" id="adult_alert">Adult is required for this booking. Please add one adult at least to continue!</div>');
114
115                return false;
116            } else {
117                return true;
118            }
119        });
120    }, 3000);
121});

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.