PageSourceSearch

https://www.jhrl.com/sites/all/modules/rescms/rc_riot/js/mixins/RCRiotSpecials.js?tlse4v

js jhrl.com collected 2026-10-06 13:19:14 UTC 3,728 bytes, 86 lines download raw bytes

1var RCRiotSpecials = {
2  init: function() {
3    (function($, tag, opts) {
4      // Gets the relevant special for a given stay range and unit.
5      tag.getApplicableSpecials = function(price, isDetailedQuoteRequest = false) {
6        if (!Drupal ||
7          !Drupal.settings ||
8          !Drupal.settings.rc_specials ||
9          !Drupal.settings.rc_specials.specials) {
10          // console.warn('No rc_specials data found; skipping applying specials.');
11          return false;
12        }
13
14        var begin = price.bt;
15        var end = price.et;
16
17        var specials = Drupal.settings.rc_specials.specials;
18        var firstSpecialEid = Object.keys(specials)[0];
19
20        // @TODO: possibly parse more than one active special in the future
21        // grabs the first object in our specials array.
22        var activeSpecial = specials[firstSpecialEid];
23
24        var currentUnit = price.eid.toString();
25
26        if(!activeSpecial.units.includes(currentUnit)) {
27          return false;
28        }
29
30        // Validate our special type.
31        // 1 = Promo Code special
32        // 2 = PMS Applied Discount (i.e. we don't do anything
33        // other than advertise this special.)
34        if(activeSpecial.special_type === '2' && isDetailedQuoteRequest) {
35          // console.warn('Skipping application of special because the special type indicates this should not be a promo code.');
36          return false;
37        }
38
39        // Validate the selected stay-range.
40        var beginMinusMilliseconds = Math.floor((begin / 1000));
41        var endMinusMilliseconds = Math.floor((end / 1000));
42        if(beginMinusMilliseconds < activeSpecial.stay_begin || endMinusMilliseconds > activeSpecial.stay_end) {
43          // console.warn('Skipping application of special because stay is outside of special range.');
44          return false;
45        }
46
47        // Get current timestamp to see if we are in a bookable range.
48        var currentTimestamp = Math.floor((Date.now() / 1000));
49        if(currentTimestamp < activeSpecial.book_begin || currentTimestamp > activeSpecial.book_end) {
50          // console.warn("Skipping application of special because the time of booking is outside the allowed range.");
51          return false;
52        }
53
54        //  Validate our traveler/guest count.
55        var selectedAdults = price.qp.rcav.adult || 1;
56        var selectedChildren = price.qp.rcav.child || 0;
57        var totalSelectedGuests = selectedAdults + selectedChildren;
58        if(activeSpecial.max_guests > 0 && totalSelectedGuests > activeSpecial.max_guests) {
59          // console.warn('Skipping application of special because the selected total guest count is over the allowed max.');
60          return false;
61        }
62        if(activeSpecial.min_guests > 0 && totalSelectedGuests < activeSpecial.min_guests) {
63          // console.warn('Skipping application of special because the selected total guest count is less than the allowed min.');
64          return false;
65        }
66
67        // Validate our min/max stay.
68        var maxNights = activeSpecial.max_nights;
69        var minNights = activeSpecial.min_nights;
70        var numOfNightsBetween = price.nt;
71        if(maxNights > 0 && numOfNightsBetween > maxNights) {
72          // console.warn('Skipping application of special because the stay did not meet the nightly maximum requirement.');
73          return false;
74        }
75        if(minNights > 0 && numOfNightsBetween < minNights) {
76          // console.warn('Skipping application of special because the stay did not meet the nightly minimum requirement.');
77          return false;
78        }
79
80        return activeSpecial;
81      };
82    })(jQuery, this, this.opts);
83  },
84};
85
86riot.mixin('RCRiotSpecials', RCRiotSpecials);

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.