PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | assets/js/booking.js +34 -4 3.0.10 → 3.0.16 View file →
@@ -35,8 +35,21 @@
35 35 if (typeof window.sprintf !== 'function') window.sprintf = function (fmt) { return fmt; };
36 36 }
37 37 })();
38 38
39 +// Parse a numeric min/max attribute while preserving a legitimate 0.
40 +// `parseInt(el.getAttribute('max')) || 20` treated max="0" — what a sold-out
41 +// departure renders — as "unset" and fell back to the placeholder ceiling, so
42 +// the guest selector stayed usable and ignored the departure's real capacity.
43 +// Only an absent or non-numeric value may fall back. Installed once and shared
44 +// by every frontend script, so load order does not matter.
45 +if (typeof window.yatraNumOr !== 'function') {
46 + window.yatraNumOr = function (raw, fallback) {
47 + var parsed = parseInt(raw, 10);
48 + return isNaN(parsed) ? fallback : parsed;
49 + };
50 +}
51 +
39 52 (function($) {
40 53 'use strict';
41 54
42 55 // API configuration - available throughout the module
@@ -717,10 +730,10 @@
717 730
718 731 const $btn = $(this);
719 732 const $input = $('#number-of-travelers');
720 733 let currentValue = parseInt($input.val()) || 1;
721 - const min = parseInt($input.attr('min')) || 1;
722 - const max = parseInt($input.attr('max')) || 20;
734 + const min = window.yatraNumOr($input.attr('min'), 1);
735 + const max = window.yatraNumOr($input.attr('max'), 20);
723 736
724 737 if ($btn.hasClass('yatra-qty-plus')) {
725 738 if (currentValue < max) {
726 739 currentValue++;
@@ -750,10 +763,10 @@
750 763 const $btn = $(this);
751 764 const $row = $btn.closest('.yatra-quantity-row');
752 765 const $input = $row.find('.yatra-qty-input');
753 766 let currentValue = parseInt($input.val()) || 0;
754 - const min = parseInt($input.attr('min')) || 0;
755 - const max = parseInt($input.attr('max')) || 20;
767 + const min = window.yatraNumOr($input.attr('min'), 0);
768 + const max = window.yatraNumOr($input.attr('max'), 20);
756 769
757 770 if ($btn.hasClass('yatra-qty-plus')) {
758 771 if (currentValue < max) {
759 772 currentValue++;
@@ -1894,8 +1907,24 @@
1894 1907 password: password,
1895 1908 confirm_password: confirmPassword
1896 1909 };
1897 1910
1911 + // reCAPTCHA v3: this form posts straight to /auth/register, so it must
1912 + // carry its own token when the operator protects registration — the
1913 + // server rejects an empty one outright, whatever the score threshold.
1914 + // Resolves to '' when reCAPTCHA is off or unavailable, so the normal
1915 + // (unprotected) flow is completely unchanged.
1916 + const yatraRcReg = window.yatraRecaptcha;
1917 + const regTokenPromise = (yatraRcReg && typeof yatraRcReg.protects === 'function'
1918 + && yatraRcReg.protects('registration') && typeof yatraRcReg.execute === 'function')
1919 + ? yatraRcReg.execute('registration')
1920 + : Promise.resolve('');
1921 +
1922 + regTokenPromise.catch(function () { return ''; }).then(function (regToken) {
1923 + if (regToken) {
1924 + registerData.recaptcha_token = regToken;
1925 + }
1926 +
1898 1927 fetch(apiUrl + '/auth/register', {
1899 1928 method: 'POST',
1900 1929 headers: {
1901 1930 'Content-Type': 'application/json',
@@ -1959,8 +1988,9 @@
1959 1988 $btn.prop('disabled', false);
1960 1989 $btnText.show();
1961 1990 $btnLoading.hide();
1962 1991 });
1992 + }); // end reCAPTCHA token wrapper
1963 1993 });
1964 1994
1965 1995 // ---------------------------------------------------------------------
1966 1996 // Date field picker upgrade (fast year navigation for Date of Birth)