PageSourceSearch

https://www.sportaberdeen.co.uk/wp-content/plugins/mage-eventpress…/frontend/mpwem_script.js?ver=1790252085

js sportaberdeen.co.uk collected 2026-09-24 12:15:47 UTC 28,251 bytes, 649 lines download raw bytes

1function mpwem_price_calculation(parent) {
2    try {
3        const total_qty = mpwem_qty(parent);
4        mpwem_attendee_management(parent, total_qty);
5        const target_summary = parent.find('.mpwem_total');
6        let total = mpwem_price(parent);
7        if (total_qty > 0) {
8            parent.find('.mpwem_ex_service').slideDown('fast');
9            parent.find('.mpwem_form_submit_area button').removeAttr('disabled');
10            total += mpwem_ex_price(parent);
11        } else {
12            parent.find('.mpwem_ex_service').slideUp('fast');
13            parent.find('.mpwem_form_submit_area button').attr('disabled', 'disabled');
14        }
15        target_summary.html(mpwem_price_format(total));
16    } catch (error) {
17        console.error('Error in price calculation:', error);
18    }
19}
20function mpwem_qty(parent) {
21    let total_qty = 0;
22    if (parent.find('.mpwem_seat_plan_area').length > 0) {
23        // Count selected seats
24        total_qty = parent.find('.mpwem_seat_available.mage_seat_selected').length;
25    } else {
26        // Sum up ticket quantities
27        parent.find('[name="option_qty[]"]').each(function () {
28            const qty = parseInt(jQuery(this).val()) || 0;
29            total_qty += qty;
30        });
31    }
32    return total_qty;
33}
34function mpwem_qty_ex(parent) {
35    let total_qty = 0;
36    parent.find('[name="event_extra_service_qty[]"]').each(function () {
37        const qty = parseInt(jQuery(this).val()) || 0;
38        total_qty += qty;
39    });
40    return total_qty;
41}
42function mpwem_price(parent) {
43    let total = 0;
44    if (parent.find('.mpwem_seat_plan_area').length > 0) {
45        parent.find('.mpwem_seat_available.mage_seat_selected').each(function () {
46            const seatPrice = parseFloat(jQuery(this).attr('data-seat_price')) || 0;
47            total += seatPrice;
48        });
49    } else {
50        // Calculate from ticket quantities and prices
51        parent.find('[name="option_qty[]"]').each(function () {
52            const qty = parseInt(jQuery(this).val()) || 0;
53            const price = parseFloat(jQuery(this).attr('data-price')) || 0;
54            total += price * qty;
55        });
56    }
57    return total;
58}
59function mpwem_ex_price(parent) {
60    let total = 0;
61    parent.find('[name="event_extra_service_qty[]"]').each(function () {
62        const ex_qty = parseInt(jQuery(this).val()) || 0;
63        const ex_price = parseFloat(jQuery(this).attr('data-price')) || 0;
64        total += ex_price * ex_qty;
65    });
66    return total;
67}
68function mpwem_attendee_management(parent, total_qty) {
69    let form_target = parent.find('.mep_attendee_info');
70    let same_attendee = parent.find('[name="mep_same_attendee"]').val();
71    if (form_target.length > 0 && total_qty > 0) {
72        if (same_attendee === 'yes' || same_attendee === 'must') {
73            form_target.slideDown('fast');
74        } else {
75            let hidden_target = parent.find('.mep_attendee_info_hidden');
76            if (parent.find('.mpwem_seat_plan_area').length > 0) {
77                let current_parent = parent.find('.mpwem_seat_plan_area');
78                let form_length = current_parent.find('.mep_form_item').length;
79                form_target = current_parent.find('.mep_attendee_info');
80                form_target.slideDown('fast');
81                if (form_length !== total_qty) {
82                    parent.find('.mpwem_seat_available.mage_seat_selected').each(function () {
83                        let seat_name = jQuery(this).attr('data-seat-name');
84                        let ticket_name = jQuery(this).attr('data-seat-type');
85                        if (form_target.find('[data-seat_name="' + seat_name + '"]').length === 0) {
86                            hidden_target.find('.mpwem_ticket_name').html(ticket_name);
87                            hidden_target.find('.mep_form_item').attr('data-seat_name', seat_name);
88                            hidden_target.find('.mpwem_ticket_count').html(seat_name).promise().done(function () {
89                                form_target.append(hidden_target.html());
90                            }).promise().done(function () {
91                                mpwem_load_date_picker(parent);
92                            });
93                        }
94                    }).promise().done(function () {
95                        form_length = form_target.find('.mep_form_item').length;
96                        if (form_length !== total_qty) {
97                            form_target.find('.mep_form_item').each(function () {
98                                let seat_name = jQuery(this).attr('data-seat_name');
99                                if (parent.find('.mpwem_seat_available.mage_seat_selected[data-seat-name="' + seat_name + '"]').length === 0) {
100                                    jQuery(this).remove();
101                                }
102                            });
103                        }
104                    });
105                }
106            } else {
107                parent.find('[name="option_qty[]"]').each(function () {
108                    let current_parent = jQuery(this).closest('.mep_ticket_item');
109                    let qty = parseInt(jQuery(this).val());
110                    if (current_parent.find('[name="ticket_group_qty"]').length > 0) {
111                        qty = qty * parseInt(current_parent.find('[name="ticket_group_qty"]').val());
112                    }
113                    let form_length = current_parent.find('.mep_form_item').length;
114                    form_target = current_parent.find('.mep_attendee_info');
115                    form_target.slideDown('fast');
116                    if (form_length !== qty) {
117                        if (form_length > qty) {
118                            for (let i = form_length; i > qty; i--) {
119                                form_target.find('.mep_form_item:last-child').slideUp(250).remove();
120                            }
121                        } else {
122                            for (let i = form_length; i < qty; i++) {
123                                let ticket_name = current_parent.find('[name="option_name[]"]').val();
124                                hidden_target.find('.mpwem_ticket_name').html(ticket_name);
125                                hidden_target.find('.mpwem_ticket_count').html(i + 1).promise().done(function () {
126                                    form_target.append(hidden_target.html()).promise().done(function () {
127                                        jQuery(this).find('.mp_form_item').each(function () {
128                                            let condition_type = jQuery(this).attr('data-depend');
129                                            let current_ticket_name = jQuery(this).attr('data-condition-value');
130                                            if (condition_type === 'mep_ticket_type' && current_ticket_name === ticket_name) {
131                                                jQuery(this).slideDown('fast').removeClass('dNone');
132                                            }
133                                        });
134                                    });
135                                }).promise().done(function () {
136                                    mpwem_load_date_picker(parent);
137                                });
138                            }
139                        }
140                    }
141                });
142            }
143        }
144    } else {
145        if (same_attendee === 'yes' || same_attendee === 'must') {
146            form_target.slideUp(250);
147        } else {
148            form_target.html('').slideUp(250);
149        }
150    }
151}
152(function ($) {
153    "use strict";
154    $(document).ready(function () {
155        $('body').find('.mpwem_registration_area').each(function () {
156            mpwem_price_calculation($(this));
157        });
158    });
159    $(document).on('change', '.mpwem_registration_area [name="mpwem_date_time"]', function () {
160        const parent = $(this).closest('.mpwem_registration_area');
161        const time_slot = parent.find('#mpwem_time');
162        if (time_slot.length > 0) {
163            const post_id = parent.find('[name="mpwem_post_id"]').val();
164            const dates = parent.find('[name="mpwem_date_time"]').val();
165            const target = parent.find('.mpwem_time_area');
166            jQuery.ajax({
167                type: 'POST',
168                url: mpwem_ajax_url,
169                data: {
170                    action: "get_mpwem_time",
171                    post_id: post_id,
172                    dates: dates,
173                },
174                beforeSend: function () {
175                    mpwem_loader_xs(target);
176                },
177                success: function (data) {
178                    target.html(data).slideDown('fast').promise().done(function () {
179                        const date = parent.find('[name="mpwem_time"]').val();
180                        get_mpwem_ticket(target, date);
181                    });
182                },
183                error: function (xhr, status, error) {
184                    console.error('Error loading time slots:', error);
185                    target.html('<p class="error">Error loading time slots. Please try again.</p>');
186                },
187                complete: function () {
188                    mpwem_loader_remove(target);
189                }
190            });
191        } else {
192            get_mpwem_ticket($(this));
193        }
194    });
195    $(document).on('change', '.mpwem_registration_area [name="mpwem_time"]', function () {
196        let parent = $(this).closest('.mpwem_registration_area');
197        let date = parent.find('[name="mpwem_time"]').val();
198        get_mpwem_ticket($(this), date);
199    });
200    function get_mpwem_ticket(current, date = '') {
201        let parent = current.closest('.mpwem_registration_area');
202        let post_id = parent.find('[name="mpwem_post_id"]').val();
203        let dates = date ? date : parent.find('[name="mpwem_date_time"]').val();
204        let target = parent.find('.mpwem_booking_panel');
205        jQuery.ajax({
206            type: 'POST',
207            url: mpwem_ajax_url,
208            data: {
209                "action": "get_mpwem_ticket",
210                "post_id": post_id,
211                "dates": dates,
212                "backend_order": window.location.href.search("backend_order"),
213            },
214            beforeSend: function () {
215                mpwem_loader_xs(target);
216            },
217            success: function (data) {
218                target.html(data).slideDown('fast').promise().done(function () {
219                    mpwem_load_seat_status(parent.closest('.mpwem_wrapper'));
220                    mpwem_price_calculation(parent);
221                });
222            }
223        });
224    }
225    function mpwem_load_seat_status(parent) {
226        let target = parent.find('.mpwem_seat_status');
227        if (target.length > 0) {
228            let post_id = parent.find('[name="mpwem_post_id"]').val();
229            let dates = parent.find('[name="mpwem_date_time"]').val();
230            jQuery.ajax({
231                type: 'POST',
232                url: mpwem_script_var.url,
233                data: {
234                    "action": "mpwem_load_seat_status",
235                    "post_id": post_id,
236                    "dates": dates,
237                    "nonce": mpwem_script_var.nonce
238                },
239                beforeSend: function () {
240                    mpwem_loader_xs(target);
241                },
242                success: function (data) {
243                    target.html(data);
244                }
245            });
246        }
247    }
248    $(document).on("click", "div.mpwem_style .decQty, div.mpwem_style .incQty", function () {
249        let parent = $(this).closest('.mpwem_registration_area');
250        let current = $(this);
251        if (!current.hasClass('mpDisabled')) {
252            let target = current.closest('.qtyIncDec').find('input');
253            let newValue = parseInt(target.val()) || 0;
254            let min = parseInt(target.attr('min')) || 0;
255            let max = parseInt(target.attr('max')) || Infinity;
256            let minQty = parseInt(target.attr('data-min-qty')) || 0;
257            if (current.hasClass('incQty')) {
258                newValue = newValue + 1;
259                if (newValue < min) {
260                    newValue = min;
261                }
262            } else {
263                newValue = newValue - 1;
264                if (newValue < min) {
265                    newValue = 0;
266                }
267            }
268            if (minQty > 0) {
269                newValue = Math.max(newValue, min);
270            }
271            newValue = Math.min(newValue, max);
272            target.val(newValue);
273            parent.find('.qtyIncDec').each(function () {
274                let $this = $(this);
275                $this.find('.incQty, .decQty').removeClass('mpDisabled');
276                let loop_target = $(this).find('input');
277                let loop_value = parseInt(loop_target.val()) || 0;
278                //let loop_min = parseInt(loop_target.attr('min')) || 0;
279                let loop_max = parseInt(loop_target.attr('max')) || Infinity;
280                let loop_minQty = parseInt(loop_target.attr('data-min-qty')) || 0;
281                if (loop_value >= loop_max) {
282                    $this.find('.incQty').addClass('mpDisabled');
283                }
284                if (loop_value <= loop_minQty) {
285                    $this.find('.decQty').addClass('mpDisabled');
286                }
287            }).promise().done(function () {
288                target.trigger('change').trigger('input');
289            });
290        }
291    });
292    $(document).on('change', '.mpwem_registration_area [name="option_qty[]"]', function () {
293        let parent = $(this).closest('.mpwem_registration_area');
294        let qty = $(this).val();
295        let total_qty = mpwem_qty(parent);
296        if (parent.find('[name="mepgq_max_qty"]').length > 0) {
297            let max_qty_gq = parseInt(parent.find('[name="mepgq_max_qty"]').val());
298            if (max_qty_gq > 0 && total_qty > max_qty_gq) {
299                qty = qty - total_qty + max_qty_gq;
300                $(this).val(qty);
301                mpwem_price_calculation(parent);
302            } else {
303                mpwem_price_calculation(parent);
304            }
305        } else if (parent.find('[name="mepmm_min_qty"]').length > 0) {
306            let max_qty = parseInt(parent.find('[name="mepmm_max_qty"]').val());
307            if (max_qty > 0 && total_qty > max_qty) {
308                qty = qty - total_qty + max_qty;
309                $(this).val(qty);
310                mpwem_price_calculation(parent);
311            } else {
312                mpwem_price_calculation(parent);
313            }
314        } else {
315            mpwem_price_calculation(parent);
316        }
317    });
318    $(document).on("click", ".mpwem_book_now", function (e) {
319        e.preventDefault();
320        let parent = $(this).closest('.mpwem_registration_area');
321        let total_qty = mpwem_qty(parent);
322        if (total_qty > 0) {
323            if (parent.find('[name="mepmm_min_qty"]').length > 0) {
324                let min_qty = parseInt(parent.find('[name="mepmm_min_qty"]').val());
325                if (total_qty < min_qty) {
326                    alert('must buy minimum number of ticket : ' + min_qty);
327                } else {
328                    parent.find('.mpwem_add_to_cart').trigger('click');
329                }
330            } else {
331                parent.find('.mpwem_add_to_cart').trigger('click');
332            }
333        } else {
334            alert('Please Select Ticket Type');
335            let currentTarget = $(this).closest('.mpwem_registration_area').find('[name="option_qty[]"]');
336            currentTarget.addClass('error');
337            return false;
338        }
339    });
340    $(document).on('change', '.mpwem_registration_area [name="event_extra_service_qty[]"]', function () {
341        let parent = $(this).closest('.mpwem_registration_area');
342        if (parent.find('[name="mepgq_max_ex_qty"]').length > 0) {
343            let qty = $(this).val();
344            let total_qty = mpwem_qty_ex(parent);
345            let max_qty_gq = parseInt(parent.find('[name="mepgq_max_ex_qty"]').val());
346            if (total_qty > max_qty_gq) {
347                qty = qty - total_qty + max_qty_gq;
348                $(this).val(qty);
349                mpwem_price_calculation(parent);
350            } else {
351                mpwem_price_calculation(parent);
352            }
353        } else {
354            mpwem_price_calculation(parent);
355        }
356    });
357    /************File Upload*************/
358    $(document).on('change', '.mep_form_item .mep_file_item input[type="file"]', function (e) {
359        let parent = $(this).closest('.mep_file_item');
360        let input = this;
361        let url = input.value;
362        let ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase();
363        if (input.files && input.files[0] && (ext === "gif" || ext === "png" || ext === "jpg" || ext === "pdf")) {
364            if (input.files[0].size <= 1024000) {
365                let reader = new FileReader();
366                reader.onload = function (e) {
367                    if (ext === "pdf") {
368                        parent.find('.attach_file_view img').slideUp(250);
369                        parent.find('.attach_file_view span').slide
369Up(250);
370                        parent.find('.attach_file_view iframe').attr('src', e.target.result).slideDown(250);
371                    } else {
372                        parent.find('.attach_file_view iframe').slideUp(250);
373                        parent.find('.attach_file_view span').slideUp(250);
374                        parent.find('.attach_file_view img').attr('src', e.target.result).slideDown(250);
375                    }
376                }
377                reader.readAsDataURL(input.files[0]);
378            } else {
379                alert('Maximum size 1MB');
380                parent.find('.attach_file_view img').slideUp(250);
381                parent.find('.attach_file_view span').slideDown(250);
382                parent.find('.attach_file_view iframe').slideUp(250);
383                $(this).val('');
384            }
385        } else {
386            parent.find('.attach_file_view img').slideUp(250);
387            parent.find('.attach_file_view span').slideDown(250);
388            parent.find('.attach_file_view iframe').slideUp(250);
389            $(this).val('');
390        }
391    });
392    /************conditional form*************/
393    $(document).on('change', '.mep_form_item [data-target-condition-id]', function () {
394        let condition_id = $(this).attr('data-target-condition-id');
395        //alert(condition_id);
396        if (condition_id) {
397            //alert(condition_id);
398            let child_id = $(this).find('option:selected').attr('data-target-child-id');
399            let parent = $(this).closest('.mep_form_item');
400            $(this).find('option').each(function () {
401                parent.find('[data-condition-id="' + condition_id + '"]').each(function () {
402                    let condition_value = $(this).attr('data-condition-value');
403                    if (condition_value) {
404                        if (condition_value === child_id) {
405                            $(this).removeClass('dNone').slideDown('fast');
406                        } else {
407                            $(this).slideUp('fast')
408                        }
409                    }
410                });
411            });
412        }
413    });
414}(jQuery));
415//*****************************Related Event***********************************//
416(function ($) {
417    "use strict";
418    $(document).ready(function () {
419        $('.mpwem_related_area .related_item').slick({
420            dots: false,
421            arrows: true,
422            prevArrow: '.related_prev',
423            nextArrow: '.related_next',
424            infinite: true,
425            centerMode: false, // Make sure centerMode is false
426            autoplay: true,
427            autoplaySpeed: 2000,
428            centerPadding: '0px',
429            slidesToShow: 4,
430            slidesToScroll: 1,
431            responsive: [
432                {
433                    breakpoint: 1024,
434                    settings: {
435                        slidesToShow: 3,
436                        slidesToScroll: 1,
437                        infinite: true,
438                        dots: false,
439                        centerMode: false // Ensure left alignment on responsive
440                    }
441                },
442                {
443                    breakpoint: 767,
444                    settings: {
445                        slidesToShow: 2,
446                        slidesToScroll: 1,
447                        infinite: true,
448                        dots: false,
449                        centerMode: false // Ensure left alignment on responsive
450                    }
451                },
452                {
453                    breakpoint: 480,
454                    settings: {
455                        slidesToShow: 1,
456                        slidesToScroll: 1,
457                        centerMode: false // Ensure left alignment on mobile
458                    }
459                }
460            ]
461        });
462    });
463}(jQuery));
464//*****************************Event list***********************************//
465(function ($) {
466    "use strict";
467    $(document).on('click', 'button.mpwem_get_date_list', function () {
468        let $this = $(this);
469        let parent = $this.closest('.mpwem_list_date_list');
470        let target = parent.find('.date_list_area');
471        if (target.find('.date_item').length === 0) {
472            let event_id = $this.data('event-id');
473            jQuery.ajax({
474                type: 'POST',
475                url: mpwem_script_var.url,
476                data: {
477                    "action": "mpwem_get_date_list",
478                    "post_id": event_id,
479                    "nonce": mpwem_script_var.nonce
480                },
481                beforeSend: function () {
482                    mpwem_loader_xs($this);
483                },
484                success: function (data) {
485                    target.html(data);
486                    target.addClass('open_list');
487                    mpwem_loader_remove($this);
488                }
489            });
490        }
491    });
492}(jQuery));
493(function ($) {
494    "use strict";
495    //*****************************Faq***********************************//
496    $(document).on('click', '.mep-event-faq-set > a', function () {
497        let current = $(this);
498        if (current.hasClass("active")) {
499            current.removeClass("active");
500            current.siblings(".mep-event-faq-content").slideUp(200);
501            $(".mep-event-faq-set > a i").removeClass("fa-minus").addClass("fa-plus");
502        } else {
503            $(".mep-event-faq-set > a i").removeClass("fa-minus").addClass("fa-plus");
504            current.find("i").removeClass("fa-plus").addClass("fa-minus");
505            $(".mep-event-faq-set > a").removeClass("active");
506            current.addClass("active");
507            $(".mep-event-faq-content").slideUp(200);
508            current.siblings(".mep-event-faq-content").slideDown(200);
509        }
510    });
511}(jQuery));
512(function ($) {
513    $(document).on('click', 'button.mep_view_vr_btn', function () {
514        $(this).closest('tr').next('tr.mep_virtual_event_info_sec').slideToggle('fast');
515    });
516    $(document).on('click', '.faq_items [data-collapse-target]', function () {
517        $(this).find('i').toggleClass('fa-chevron-right fa-chevron-down');
518    });
519}(jQuery));
520/******************** Remove below function after 2025**********************/
521(function ($) {
522    "use strict";
523    $(document).on('click', '.mep-event-list-loop .mp_event_visible_event_time', function (e) {
524        e.preventDefault();
525        let target = $(this);
526        $('.mep-event-list-loop .mp_event_visible_event_time').each(function () {
527            let current = $(this).siblings('ul.mp_event_more_date_list');
528            if (current.is(':visible')) {
529                let active_text = $(this).data('active-text');
530                $(this).html(active_text);
531                current.slideUp(200);
532            }
533        }).promise().done(function () {
534            let current_list = target.siblings('ul.mp_event_more_date_list');
535            if (current_list.length > 0) {
536                if (current_list.is(':visible')) {
537                    current_list.slideUp(200);
538                    target.html(target.data('active-text'));
539                } else {
540                    current_list.slideDown(200);
541                    target.html(target.data('hide-text'));
542                }
543            } else {
544                let event_id = target.data('event-id');
545                $.ajax({
546                    type: 'POST',
547                    url: mpwem_ajax_url,
548                    data: {"action": "mep_event_list_date_schedule", "event_id": event_id},
549                    beforeSend: function () {
550                        target.html('<span class="fas fa-spinner fa-pulse"></span>');
551                    },
552                    success: function (data) {
553                        $(data).insertAfter(target);
554                        target.html(target.data('hide-text'));
555                    }
556                });
557            }
558        });
559    });
560}(jQuery));
561
562
563
564
565
566// DatePicker Function
567jQuery(document).ready(function ($) {
568
569    if (typeof mpwemDateData === 'undefined') {
570        return;
571    }
572
573    let selector       = mpwemDateData.selector;
574    let availableDates = mpwemDateData.availableDates;
575    let minDateData    = mpwemDateData.minDate;
576    let maxDateData    = mpwemDateData.maxDate;
577
578    $(selector).datepicker({
579
580        dateFormat: mpwem_date_format,
581
582        minDate: new window.Date(
583            minDateData.year,
584            minDateData.month,
585            minDateData.day
586        ),
587
588        maxDate: new window.Date(
589            maxDateData.year,
590            maxDateData.month,
591            maxDateData.day
592        ),
593
594        autoSize: true,
595        changeMonth: true,
596        changeYear: true,
597
598        beforeShowDay: function (date) {
599
600            let d = date.getDate();
601            let m = date.getMonth() + 1;
602            let y = date.getFullYear();
603
604            let dmy = d + "-" + m + "-" + y;
605
606            if ($.inArray(dmy, availableDates) !== -1) {
607                return [true, "", "Available"];
608            }
609
610            return [false, "", "Unavailable"];
611        },
612        onSelect: function (dateText, data) {
613
614            let date = data.selectedYear + '-' +
615                ('0' + (parseInt(data.selectedMonth) + 1)).slice(-2) + '-' +
616                ('0' + parseInt(data.selectedDay)).slice(-2);
617
618            $(this)
619                .closest('label')
620                .find('input[type="hidden"]')
621                .val(date)
622                .trigger('change');
623        }
624
625    });
626
627});
628
629
630document.querySelectorAll('li').forEach(function(li) {
631    // চেক করুন এই li তে price আছে কিনা
632    if (li.querySelector('.woocommerce-Price-amount')) {
633        let strong = li.querySelector('.wc-item-meta-label');
634
635        if (strong) {
636            // strong element এর ভিতরের সব child nodes চেক করুন
637            strong.childNodes.forEach(function(node) {
638                // চেক করুন এটি text node কিনা
639                if (node.nodeType === Node.TEXT_NODE) {
640                    // সব text node থেকে : এবং - রিমুভ করে স্পেস দিন
641                    node.textContent = node.textContent.replace(/[:-]/g, '  ');
642
643                    // অতিরিক্ত স্পেস কমাতে চাইলে (optional)
644                    //node.textContent = node.textContent.replace(/\s+/g, ' ').trim();
645                }
646            });
647        }
648    }
649});

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.