PageSourceSearch

https://www.letsroam.com/assets/js/store/source/helpers.js

js letsroam.com collected 2026-09-24 09:24:41 UTC 3,414 bytes, 109 lines download raw bytes

1var formInputFields = document.querySelectorAll(
2  '.form-control,.c-vtb__form--input'
3);
4
5// Pricing Checkout owns the selected pass configuration, so its cart item
6// cannot safely return to the generic bundle editor. Match the same cookie and
7// bundle contract enforced by Cart::pricing_checkout_v1_selection_matches_cart().
8function pricingCheckoutSelectionMatchesCartItem(cartItem) {
9  try {
10    var match = document.cookie.match(/(?:^|;\s*)pcv1_selection=([^;]*)/);
11    if (!match) { return false; }
12
13    var selection = JSON.parse(decodeURIComponent(match[1]));
14    var selectedBundleId = parseInt(selection.bundle && selection.bundle.bundleId, 10);
15    var cartBundleId = parseInt(cartItem && cartItem.bundleId, 10);
16
17    if (parseInt(selection.version, 10) === 3) {
18      var players = parseInt(selection.playerCount || selection.band, 10);
19      return selection.experimentName === 'SCH_PRICING_CHECKOUT_V3' &&
20        players >= 1 && players <= 10 &&
21        cartItem.pricingCheckoutV3 === true &&
22        parseInt(cartItem.pricingCheckoutV3Players, 10) === players &&
23        cartItem.pricingCheckoutV3Tier === selection.tier &&
24        cartBundleId === selectedBundleId;
25    }
26
27    return parseInt(selection.version, 10) === 2 &&
28      selection.band === '3-10' &&
29      [209, 346, 348].indexOf(selectedBundleId) !== -1 &&
30      cartBundleId === selectedBundleId;
31  } catch (selectionError) {
32    return false;
33  }
34}
35
36function checkAddLabel(field) {
37  // console.log({ field });
38  var label = field.parentElement.querySelector('.sm-label');
39  if (typeof clearErrors != 'undefined') {
40    clearErrors();
41  }
42  if (field.value && label) {
43    // console.log('showing label');
44    label.style.display = 'block';
45    field.classList.remove('form-control-no-label');
46  } else if (label) {
47    // console.log('hiding label');
48    label.style.display = 'none';
49    field.classList.add('form-control-no-label');
50  } else {
51    // console.log('no label');
52  }
53}
54
55if (formInputFields) {
56  formInputFields.forEach(function (field) {
57    checkAddLabel(field);
58    field.addEventListener('keyup', function (e) {
59      checkAddLabel(field);
60    });
61  });
62}
63
64if (
65  typeof String.prototype.replaceAll == 'undefined' &&
66  !window.location.href.includes('app_dash')
67) {
68  String.prototype.replaceAll = function (search, replacement) {
69    var target = this;
70    console.log({ search, replacement });
71    return target.replace(new RegExp(search, 'g'), replacement);
72  };
73}
74
75var openButton = document.querySelector('#btnLeftPanel');
76var leftNav = document.querySelector('#bchLeftPanel');
77if (openButton) {
78  openButton.onclick = function () {
79    leftNav.style.display = leftNav.style.display == 'block' ? 'none' : 'block';
80  };
81}
82
83if (leftNav) {
84  leftNav.onclick = function (event) {
85    if (event.target.closest('a.nav-link')) {
86      leftNav.style.display = 'none';
87      return;
88    }
89    if (event.target.id == 'bchLeftPanel') {
90      console.log('closing left nav panel');
91      leftNav.style.display =
92        leftNav.style.display == 'block' ? 'none' : 'block';
93    }
94  };
95}
96
97function getValue(selector = '') {
98  trace('getValue-' + selector);
99  var item = document.querySelector(selector);
100  return item ? item.value : '';
101}
102
103function setValue(selector = '', value = '') {
104  trace('setValue-' + selector);
105  var item = document.querySelector(selector);
106  item.value = value;
107}
108
109console.log('helpers loaded');

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.