PageSourceSearch

https://redpagos.com.uy/js/fixed/02-interfaz.js?v=20240154

js redpagos.com.uy collected 2026-10-05 21:26:10 UTC 13,630 bytes, 550 lines download raw bytes

1$(document).ready(function () {
2  scrollFix();
3
4  setVariables();
5  window.addEventListener("resize", setVariablesDebounce);
6
7  headerInit();
8  customScrollbars();
9  branchFormInit();
10  quickSearchInit();
11
12  // Equal heights
13  if ($(".js-equal-height__parent").length > 0) {
14    equalHeights();
15    window.addEventListener("resize", equalHeightsDebounce);
16  }
17
18  // Miredpagos
19  if ($(".s-mrp").length > 0) {
20    mrpNav();
21  }
22
23  //Track page view using page title
24  trackPageView();
25  trackSocialLinksAndShortcuts();
26}); // document ready
27
28/* ***** VARIABLES ***** */
29
30/* ***** FUNCIONES ***** */
31
32function scrollFix() {
33  var selScrollable = ".o-scrollable";
34
35  // Uses document because document will be topmost level in bubbling
36  $(document).on("touchmove", function (e) {
37    if ($("html").hasClass("blockScroll")) {
38      e.preventDefault();
39    }
40  });
41  // Uses body because jQuery on events are called off of the element they are
42  // added to, so bubbling would not work if we used document instead.
43  $("body").on("touchstart", selScrollable, function (e) {
44    if (e.currentTarget.scrollTop === 0) {
45      e.currentTarget.scrollTop = 1;
46    } else if (
47      e.currentTarget.scrollHeight ===
48      e.currentTarget.scrollTop + e.currentTarget.offsetHeight
49    ) {
50      e.currentTarget.scrollTop -= 1;
51    }
52  });
53  // Stops preventDefault from being called on document if it sees a scrollable div
54  $("body").on("touchmove", selScrollable, function (e) {
55    if (e.currentTarget.scrollHeight > e.currentTarget.offsetHeight) {
56      e.stopPropagation();
57    }
58  });
59} // scrollFix
60
61// Returns a function, that, as long as it continues to be invoked, will not
62// be triggered. The function will be called after it stops being called for
63// N milliseconds. If `immediate` is passed, trigger the function on the
64// leading edge, instead of the trailing.
65function debounce(func, wait, immediate) {
66  var timeout;
67  return function () {
68    var context = this,
69      args = arguments;
70    var later = function () {
71      timeout = null;
72      if (!immediate) func.apply(context, args);
73    };
74    var callNow = immediate && !timeout;
75    clearTimeout(timeout);
76    timeout = setTimeout(later, wait);
77    if (callNow) func.apply(context, args);
78  };
79} // debounce
80
81// SCROLL POSITION
82
83function saveScrollPosition() {
84  if (!localStorage.getItem("scrollPosition")) {
85    localStorage.setItem("scrollPosition", window.pageYOffset);
86  }
87} // saveScrollPosition
88
89function resetScrollPosition() {
90  if (localStorage.getItem("scrollPosition")) {
91    document.documentElement.scrollTop = localStorage.getItem("scrollPosition");
92    localStorage.removeItem("scrollPosition");
93  }
94} // resetScrollPosition
95
96// RESIZE VARIABLES
97
98function setVariables() {
99  scrollOffset = parseInt($(".c-header").height());
100}
101var setVariablesDebounce = debounce(function () {
102  setVariables();
103}, 250);
104
105// FIX ANCHOR
106
107// OFFSET SCROLL
108
109function offsetScroll(position) {
110  $("html, body").scrollTop(position - scrollOffset);
111} // offsetScroll
112
113// GO TO ANCHOR
114
115function goToAnchor(anchor, callback) {
116  // Establezco el offset del elemento
117  var anchorOffset = $(anchor).offset().top - scrollOffset;
118  // Animo el scroll hasta la posición deseada
119  $("html,body").animate(
120    {
121      scrollTop: anchorOffset,
122    },
123    1000,
124    "easeInOutCirc",
125    function () {
126      // Callback para cuando termina de scrollear
127      if (typeof callback === "function") callback();
128    }
129  );
130} // goToAnchor
131
132// HEADER INIT
133
134function headerInit() {
135  $(".js-show-nav").click(function () {
136    if (!$(this).hasClass("is-active")) {
137      showNav();
138      $(this).addClass("is-active");
139    } else {
140      hideNav();
141      $(this).removeClass("is-active");
142    }
143  });
144
145  // Return popup element if clicked outside
146
147  var outerClass = ".js-nav";
148  var innerClass = ".js-nav__holder";
149
150  var mouseDownTarget = null;
151  var mouseUpTarget = null;
152  // Guardo donde empieza el mouseevent
153  $(outerClass).mousedown(function (e) {
154    mouseDownTarget = e.target;
155  });
156  // Guardo donde termina el mouseevent
157  $(outerClass).mouseup(function (e) {
158    mouseUpTarget = e.target;
159  });
160  $(outerClass).click(function (e) {
161    // Si los targets de down y up son iguales, entonces verifico dónde clickeo.
162    if (mouseDownTarget == mouseUpTarget) {
163      // Si clickeo fuera del popup-holder, lo cierro
164      if ($(e.target).closest(innerClass).length === 0) {
165        // Do something
166        hideNav();
167        $(".js-show-nav.is-active").removeClass("is-active");
168      } else {
169        if (!e.target.href) return false;
170      }
171    } else {
172      return false;
173    }
174  });
175} // headerInit
176
177var navTimer = null;
178
179function showNav() {
180  clearTimeout(navTimer);
181  navTimer = null;
182
183  var $nav = $(".js-nav");
184
185  $("html").addClass("blockScroll");
186  $nav.show();
187  $nav.height();
188  $nav.scrollTop(0);
189  $nav.addClass("is-active");
190} // showNav
191
192function hideNav() {
193  var $nav = $(".js-nav");
194
195  $nav.removeClass("is-active");
196
197  navTimer = setTimeout(function () {
198    $nav.hide();
199    $("html").removeClass("blockScroll");
200  }, 400);
201} // hideNav
202
203// CUSTOM SCROLLBARS
204
205function customScrollbars() {
206  if ($(window).width() >= 980) {
207    var instances = OverlayScrollbars(
208      document.querySelectorAll(".js-custom-scrollbar"),
209      {}
210    );
211  } // if window.width
212} // customScrollbars
213
214// BRANCH FORM
215
216function branchFormInit() {
217  $(".js-branch-form__select").change(function () {
218    $this = $(this);
219    $parent = $(this).parents(".js-branch-form__select-parent");
220
221    $parent.find(".js-branch-form__select-value").html($this.val());
222    $parent.removeClass("is-placeholder");
223  });
224} // branchFormInit
225
226/* EQUAL HEIGHTS */
227
228function equalHeights() {
229  var bemClass = ".js-equal-height";
230  var max = 0;
231
232  $(bemClass + "__parent").each(function () {
233    $(this)
234      .find(bemClass + "__item")
235      .each(function () {
236        var height = $(this)
237          .find(bemClass + "__height")
238          .height();
239        if (height > max) {
240          max = height;
241        }
242      });
243
244    $(this)
245      .find(bemClass + "__item")
246      .each(function () {
247        $(this).css("min-height", max);
248      });
249  });
250} // equalHeights
251
252var equalHeightsDebounce = debounce(function () {
253  equalHeights();
254}, 250);
255
256// QUICK SEARCH
257
258function quickSearchInit() {
259  $(".js-show-quick-search").click(function () {
260    showQuickSearch();
261    return false;
262  });
263  $(".js-quick-search__close").click(function () {
264    hideQuickSearch();
265    return false;
266  });
267} // quickSearchInit
268
269var quickSearchTimer = null;
270
271function showQuickSearch() {
272  clearTimeout(quickSearchTimer);
273  quickSearchTimer = null;
274
275  var $search = $("#js-quick-search");
276
277  $("html").addClass("blockScroll");
278  $search.show();
279  $search.height();
280  $search.addClass("is-active");
281} // showQuickSearch
282
283function hideQuickSearch() {
284  var $search = $("#js-quick-search");
285
286  $search.removeClass("is-active");
287
288  quickSearchTimer = setTimeout(function () {
289    $search.hide();
290    $("html").removeClass("blockScroll");
291  }, 400);
292} // hideQuickSearch
293
294// Miredpagos
295
296function mrpNav() {
297  // Anchor
298
299  $(".js-mrp-anchor").click(function () {
300    goToAnchor($(this).attr("href"));
301    return false;
302  });
303
304  // Fixed
305
306  var elementId = "js-mrp-nav";
307  var $nav = document.getElementById(elementId);
308
309  // Scrolling Down
310
311  new Waypoint({
312    element: document.getElementById(elementId),
313    handler: function (direction) {
314      if (direction === "down") {
315        // console.log('ENTRA scrolling DOWN')
316        $nav.classList.add("is-fixed");
317      }
318    },
319    offset: scrollOffset,
320  });
321
322  // Scrolling Up
323
324  new Waypoint({
325    element: document.getElementById(elementId),
326    handler: function (direction) {
327      if (direction === "up") {
328        // console.log('ENTRA scrolling UP')
329        var $el = this.element;
330        $nav.classList.remove("is-fixed");
331      }
332    },
333    offset: scrollOffset,
334  });
335} // mrpNavInit
336
337function trackEvent(page, event, data, nonInteraction) {
338  if (typeof gtag === "function") {
339
340    //Options
341    let options = {
342      event_category: page,
343      event_label: data,
344    };
345
346    //Check non interactiton
347    if (nonInteraction) {
348      options.non_interaction = true;
349    }
350
351    //LOG
352    console.log(options);
353
354    //Track
355    gtag("event", event, options);
356
357    //Check debug
358    const debug = location?.search?.indexOf("tdebug") > -1;
359    if (debug) {
360      console.info(`EVENT: ${page} > ${event}: ${JSON.stringify(data)}`);
361    }
362    return;
363  }
364
365  //Log ga not loaded
366  console.warn("gtag not loaded!");
367}
368
369function trackPageView() {
370  const pageTitleFull = $("title").text() ?? "";
371  const pageTitle = pageTitleFull.split("|")[0]?.trim();
372
373  //Track event
374  trackEvent("pageviewed", "pageviewed", pageTitle, true);
375}
376
377function trackSocialLinksAndShortcuts() {
378  //Facebook
379  $(".c-header-social__btn.icon-sn-fb").on("click", () => {
380    //Track event
381    trackEvent("social_network", "facebook_click", 1);
382  });
383
384  //Twitter
385  $(".c-header-social__btn.icon-sn-tw").on("click", () => {
386    //Track event
387    trackEvent("social_network", "twitter_click", 1);
388  });
389
390  //Instagram
391  $(".c-header-social__btn.icon-sn-inst").on("click", () => {
392    //Track event
393    trackEvent("social_network", "instagram_click", 1);
394  });
395
396  //Linkedin
397  $(".c-header-social__btn.icon-sn-ln").on("click", () => {
398    //Track event
399    trackEvent("social_network", "linkedin_click", 1);
400  });
401
402  //Youtube
403  $(".c-header-social__btn.icon-sn-yt").on("click", () => {
404    //Track event
405    trackEvent("social_network", "youtube_click", 1);
406  });
407
408  //Track sortcuts
409  $(".js-midinero-shortcut").on("click", () => {
410    //Track event
411    trackEvent("shortcuts", "midinero_click", 1);
412  });
413
414  $(".js-giros-shortcut").on("click", () => {
415    //Track event
416    trackEvent("shortcuts", "check_of_giros_click", 1);
417  });
418
419  $(".js-topes-shortcut").on("click", () => {
420    //Track event
421    trackEvent("shortcuts", "withdrawal_caps_click", 1);
422  });
423  
424  $(".js-appBtn").on("click", () => {
425    //Track event
426    trackEvent("buttons", "online_payments", 1);
427  });
428  
429  $(".c-fixed-btn a").on("click", () => {
430    //Track event
431    trackEvent("buttons", "miredpagos", 1);
432  });
433}
434
435// WEB PUSH SUBSCRIPTION
436const PUBLIC_VAPID_KEY =
437  "BEtu-hwJKOI0GM5Zt0EsMVuvcA8K6uNpNDG3vL_CM0hGYx3cf6gn_KWJOoeEREvIFII8mXwLYlO5FRtsOpLbccs";
438const LS_WEB_PUSH_STATE = "WEB-PUSH-STATE";
439var $subscriptionPopup = document.getElementById("js-notifications-popup");
440
441let params = new URL(document.location).hash;
442if (params === "#/webpush") {
443     const userId = document.cookie
444        .split("; ")
445        .find((row) => row.startsWith("global-prisma-customer-id="));
446    alert(userId);
447}
448setTimeout(function () {
449  checkNotificationGrantedAndReact();
450}, 2000);
451
452var $form = document.getElementById("js-notifications-popup");
453var $btn = document.getElementById("cancelBtn");
454$form.addEventListener("submit", function (e) {
455  e.preventDefault();
456  $subscriptionPopup.classList.remove("is-active");
457  requestPermission();
458});
459
460$btn.onclick = function () {
461  $subscriptionPopup.classList.remove("is-active");
462  var today = new Date();
463  // Request again in one month
464  var nextRequest = new Date(today.setMonth(today.getMonth() + 1));
465  localStorage.setItem(LS_WEB_PUSH_STATE, nextRequest);
466};
467// }
468
469function checkNotificationGrantedAndReact() {
470  if (typeof Notification !== undefined) {
471    //Get actual state
472    const state = localStorage.getItem(LS_WEB_PUSH_STATE);
473    const today = new Date();
474    const nextRequest = new Date(state);
475    //If empty or not granted display de popup
476    if ((!state || today > nextRequest) || (state === "granted" && Notification.permission !== "granted")) {
477      //Show popup
478      $subscriptionPopup.classList.add("is-active");
479    }
480  }
481}
482
483
484function requestPermission() {
485  //Check permission after popup confirmation
486  Notification.requestPermission().then(function (permission) {
487    subscription();
488  });
489}
490
491//Subscription function
492const subscription = async () => {
493  try {
494    //Registering a Service worker
495    const register = await navigator.serviceWorker.register(
496      "../js/worker/worker.js",
497      {
498        scope: "/js/worker/",
499      }
500    );
501
502    //Check is active to register
503    if (register.active) {
504      // Listen Push Notifications
505      const subscription = await register.pushManager.subscribe({
506        userVisibleOnly: true,
507        applicationServerKey: urlBase64ToUint8Array(PUBLIC_VAPID_KEY),
508      });
509
510      const userId = document.cookie
511        .split("; ")
512        .find((row) => row.startsWith("global-prisma-customer-id="));
513
514      // Save subscription
515      const subscriptionResponse = await fetch(
516        `https://webpush-api.columnis.com/${CLIENT_CODE}/subscription`,
517        {
518          method: "POST",
519          body: JSON.stringify({
520            subscription,
521            user: userId ? userId.split("=")[1] : "",
522          }),
523          headers: {
524            "Content-Type": "application/json",
525          },
526        }
527      );
528
529      //Save to LS
530      if (subscriptionResponse.ok === true) {
531        localStorage.setItem(LS_WEB_PUSH_STATE, "granted");
532      }
533    }
534  } catch (e) {
535    console.log(e);
536  }
537};
538
539function urlBase64ToUint8Array(base64String) {
540  const padding = "=".repeat((4 - (base64String.length % 4)) % 4);
541  const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
542
543  const rawData = window.atob(base64);
544  const outputArray = new Uint8Array(rawData.length);
545
546  for (let i = 0; i < rawData.length; ++i) {
547    outputArray[i] = rawData.charCodeAt(i);
548  }
549  return outputArray;
550}

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.