PageSourceSearch

https://www.oceanstatecu.org/mstinc/grp/web_banner/js/web_banner_test.js?v=

js oceanstatecu.org collected 2026-10-05 20:13:30 UTC 25,248 bytes, 680 lines download raw bytes

1"use strict";
2
3(function ($) {
4  $.mobile_dropdown = function (params) {
5    //check abort cases:
6    if (!$ || !$.fn.jquery) {
7      if (typeof console != "undefined" && typeof console.log != "undefined")
8        console.log(
9          "Global JS: Mobile Alert - Aborting because jQuery does not exist"
10        );
11      return;
12    }
13    var jQuery_version = $.fn.jquery.split(".");
14    if (jQuery_version.length < 2) {
15      if (typeof console != "undefined" && typeof console.log != "undefined")
16        console.log(
17          "Global JS: Mobile Alert - Aborting because jQuery version number " +
18            "does not contain minor and major version numbers"
19        );
20      return;
21    }
22    var jQuery_majorVersion = parseInt(jQuery_version[0]);
23    var jQuery_minorVersion = parseInt(jQuery_version[1]);
24    if (
25      jQuery_majorVersion < 1 ||
26      (jQuery_majorVersion === 1 && jQuery_minorVersion < 7)
27    ) {
28      if (typeof console != "undefined" && typeof console.log != "undefined")
29        console.log(
30          "Global JS: Mobile Alert - Aborting because jQuery version is not at least 1.7"
31        );
32      return;
33    }
34    // Framebusting code: if this is in a frame we shouldnt load the dropdown
35    if (
36      self.location.href != top.location.href ||
37      self.location.href.indexOf("onlineserv/HB") != -1 ||
38      self.location.href.indexOf("/bridge/") != -1 ||
39      self.location.href.indexOf("/preprod/") != -1 ||
40      self.location.href.indexOf("/disclosure") != -1 ||
41      self.location.href.indexOf("OnlineForm.cgi") != -1 ||
42      self.location.href.indexOf("onlineserv/HB/logout.html") != -1 ||
43      self.location.href.indexOf("usp/landing_dpv") != -1 ||
44      self.location.href.indexOf("ofs/live/forms") != -1 ||
45      self.location.href.indexOf("noGRS") != -1
46    ) {
47      return;
48    }
49    /*if ( document.compatMode.indexOf('BackCompat') != -1 ) {
50        	return;
51        }*/
52    var quirks = document.documentMode;
53    if (quirks == 5) {
54      return;
55    }
56
57    function getUrlVar(pkey) {
58      var results = new RegExp(pkey + "=([^&]*)", "i").exec(
59        window.location.search
60      );
61      return (results && results[1]) || "";
62    }
63
64    //setup cookie function
65    var cookie = function (key, value, options) {
66      // key and value given, set cookie...
67      if (
68        arguments.length > 1 &&
69        (value === null || typeof value !== "object")
70      ) {
71        if (!options || typeof options != "object") options = {};
72
73        if (value === null) {
74          options.expires = -1;
75        }
76
77        if (typeof options.expires === "number") {
78          var days = options.expires,
79            t = (options.expires = new Date());
80          t.setDate(t.getDate() + days);
81        }
82
83        return (document.cookie = [
84          encodeURIComponent(key),
85          "=",
86          options.raw ? String(value) : encodeURIComponent(String(value)),
87          options.expires ? "; expires=" + options.expires.toUTCString() : "", // use expires attribute, max-age is not supported by IE
88          options.path ? "; path=" + options.path : "; path=/",
89          options.domain ? "; domain=" + options.domain : "",
90          options.secure ? "; secure" : "",
91        ].join(""));
92      }
93
94      // key and possibly options given, get cookie...
95      options = value || {};
96      var result,
97        decode = options.raw
98          ? function (s) {
99              return s;
100            }
101          : decodeURIComponent;
102      return (result = new RegExp(
103        "(?:^|; )" + encodeURIComponent(key) + "=([^;]*)"
104      ).exec(document.cookie))
105        ? decode(result[1])
106        : null;
107    }; // .cookie()
108
109    //setup default properties
110    var default_params = {
111      attr: {
112        fi_name: "Your Financial Institution",
113        di_num: "none",
114        url: {
115          dpad: false,
116          droid: false,
117          itunes: false,
118          ipad: false,
119        },
120      },
121      app_alert: {
122        active: false,
123        ie8_disable: false,
124        animate_disable: true,
125        menu_fix: false,
126        is_third_party: false,
127        ib_url: false,
128        mobile_settings_file: false,
129        droidfix: false,
130        droidclick: "",
131        ga_account: "UA-34266234-1",
132        cookie_name: "MstIncGlobal_mobile_app_alert",
133        cookie_name_droid: "MstIncGlobal_droid_app_alert",
134        onclick: "",
135        bg: false,
136        learn_more: false,
137        blacklist: false,
138        variance: false,
139        qr: false,
140      },
141      lifecycle: {
142        active: false,
143      },
144      product: {
145        rdc: false,
146        atm: false,
147        cma: false,
148        mbp: false,
149      },
150      ttob: {
151        active: false,
152        url: "",
153        sweeps: false,
154      },
155      T2D: {
156        active: false,
157      },
158      is_third_party: false,
159    };
160
161    //console.log( params.toSource() );
162
163    //merge passed parameters with default, precendence on the passed parameters
164
165    //$.mobile_dropdown.test = function() { alert('here'); };
166    this.getFiData = function () {
167      if (params.is_third_party) {
168        $.ajax({
169          async: false,
170          dataType: "jsonp",
171          cache: false,
172          url:
173            "//www." +
174            params.ib_url +
175            "/mstinc/grp/acc_mobile/settings/" +
176            params.mobile_settings_file +
177            ".json",
178          jsonpCallback: "acc_mobile_inject",
179          success: function (json) {
180            //console.log( json.toSource() );
181            params = $.extend(true, default_params, json, params);
182            if (typeof params.ttob.active == "string") {
183              params.ttob.active = params.ttob.active == "true";
184            }
185
186            //console.log( params.toSource() );
187            //console.log( "TP - " + params.toSource() );
188            if (params.lifecycle.active || params.ttob.active) {
189              params.app_alert.cookie_name = "webAccelBanner";
190              $.mobile_dropdown.build_banner();
191            } else {
192              params.app_alert.cookie_name = false;
193            }
194            return true;
195          },
196          error: function (err) {
197            alert("fail");
198          },
199        });
200      } else {
201        $.ajax({
202          async: false,
203          dataType: "json",
204          url: "/settings.js2",
205          cache: false,
206          success: function (json) {
207            params = $.extend(true, default_params, json, params);
208            params.ttob.active = false;
209            var dparam = getUrlVar("accel");
210            var cookieparam = getUrlVar("mdsh");
211            //var cookieparam = MstIncGlobal.cookie("acc_mobile_test");
212            //var cookieparam = false;
213            //console.log( "TP - " + params.toSource() );
214            //
215            console.log(params);
216            if (params.lifecycle.active || params.ttob.active) {
217              params.app_alert.cookie_name = "webAccelBanner";
218              $.mobile_dropdown.build_banner();
219            } else {
220              params.app_alert.cookie_name = false;
221            }
222            return true;
223          },
224          error: function (err) {
225            return false;
226          },
227        });
228      }
229    };
230
231    //*************************** Setup helper functions ************************//
232
233    params.domain = top.document.location.href
234      .split("/")[2]
235      .replace("www.", "");
236
237    //browser detection
238    params.iPhone =
239      navigator.userAgent.indexOf("iPhone") > -1 ||
240      navigator.userAgent.indexOf("iPod") > -1
241        ? true
242        : false;
243    params.iPad = navigator.userAgent.indexOf("iPad") > -1 ? true : false;
244    params.android = navigator.userAgent.indexOf("Android") > -1 ? true : false;
245
246    $.mobile_dropdown.close_pad = function () {
247      _gaGRS("send", {
248        hitType: "event",
249        eventCategory: "iPad webAccelBanner",
250        eventAction: "Close",
251        eventLabel: params.attr.di_num,
252      });
253      $(
254        "#mstinc_mobile_alert_container, #mstinc_mobile_alert_background"
255      ).hide();
256      cookie(params.app_alert.cookie_name, params.cookie_count, {
257        expires: 365,
258      });
259      return false;
260    };
261    $.mobile_dropdown.close_droid = function () {
262      _gaGRS("send", {
263        hitType: "event",
264        eventCategory: "Android webAccelBanner",
265        eventAction: "Close",
266        eventLabel: params.attr.di_num,
267      });
268      $("#mstinc_mobile_android_container").hide();
269      cookie(params.app_alert.cookie_name_droid, params.cookie_count_droid, {
270        expires: 365,
271      });
272      $("body").css({ "background-position": "0px 0px", "margin-top": "0px" });
273      //_gaq.push(['grs._trackEvent', 'iPad Popup', 'Close Popup', params.domain]);
274      return false;
275    };
276    var bannerType = "";
277    $.mobile_dropdown.close_drop = function (bannerType) {
278      //$('body').css({"background-position": "0 0"});
279      cookie(params.app_alert.cookie_name, params.cookie_count, {
280        expires: 365,
281      });
282      return false;
283    };
284
285    var banner = "";
286    // BEGIN TEST SETTINGS
287    // params.ttob = {
288    // "active": true,
289    // "sweeps": false,
290    // "url": "https://turbotax.intuit.com/affiliate/wester2"
291    // };
292    // END TEST SETTINGS
293
294    var open_drop = function (banner) {
295      if (params.lifecycle.active || params.ttob.active) {
296        _gaGRS("send", {
297          hitType: "event",
298          eventCategory: "webAccelBanner",
299          eventAction: "Open Banner",
300          eventLabel: params.attr.di_num,
301        });
302      }
303      return false;
304    };
305
306    console.log(params);
307
308    //*************************** Setup helper functions ************************//
309
310    $.mobile_dropdown.build_banner = function () {
311      function getRandomInt(min, max) {
312        return Math.floor(Math.random() * (max - min + 1)) + min;
313      }
314
315      var random = 1;
316      /* BEGIN Google's Universal Analytics */
317
318      params.app_alert.ga_account = "UA-41942728-5";
319
320      (function (i, s, o, g, r, a, m) {
321        i["GoogleAnalyticsObject"] = r;
322        (i[r] =
323          i[r] ||
324          function () {
325            (i[r].q = i[r].q || []).push(arguments);
326          }),
327          (i[r].l = 1 * new Date());
328        (a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
329        a.async = 1;
330        a.src = g;
331        m.parentNode.insertBefore(a, m);
332      })(
333        window,
334        document,
335        "script",
336        "//www.google-analytics.com/analytics.js",
337        "_gaGRS"
338      );
339
340      _gaGRS("create", params.app_alert.ga_account, { cookieName: "_gaGRS" });
341      _gaGRS("set", { campaignName: "webAccelBanner" });
342      _gaGRS("send", "pageview");
343
344      // if user closed dropdown twice, no longer show it
345      var noApps = false;
346      params.cookie_count = cookie(params.app_alert.cookie_name);
347      if (!params.attr.url.itunes || !params.attr.url.droid) {
348        noApps = true;
349      }
350
351      if (
352        !cookie(params.app_alert.cookie_name) ||
353        cookie(params.app_alert.cookie_name) < 2
354      ) {
355        params.cookie_count = 1;
356
357        if (cookie(params.app_alert.cookie_name)) {
358          params.cookie_count =
359            parseInt(cookie(params.app_alert.cookie_name)) + 1;
360        }
361      } else {
362        return;
363      }
364      //Determine which banner they should see this time. Need to have cookie val parsed by now
365      //if ( !cookie( 'bannerPosition') ) {
366      //reset all FIs to use new banner
367      cookie("bannerPosition", "0,0", { expires: 365 });
368      //}
369      var c = cookie("bannerPosition");
370      // convert cookie val to array
371      params.currentBanner = parseInt(c.split(",")[0]);
372      params.bannerShown = parseInt(c.split(",")[1]);
373
374      if (params.is_third_party) {
375        params.base_url = "https://www." + params.ib_url;
376        _gaGRS("send", {
377          hitType: "event",
378          eventCategory: "Third Party",
379          eventAction: top.document.location.href,
380          eventLabel: params.attr.di_num,
381        });
382      } else {
383        params.base_url = "";
384      }
385
386      // Given banner copy and an identifier, create dropdown with copy in text_block and run analytics function that adds GA events with JQ on('click' method. TODO - create analytics function
387
388      params.full_reg_url =
389        "https://" + params.attr.url.ib + "/tob/live/usp-core/app/register";
390      var today = new Date();
391      console.log(params);
392      if (params.ttob.active) {
393        var customBanner = function () {
394          $("head").append("<link>");
395          var css = $("head").children(":last");
396          css
397            .attr({
398              rel: "stylesheet",
399              type: "text/css",
400              href:
401                params.base_url + "/mstinc/grp/web_banner/css/web_banner.css",
402            })
403            .one("load", function () {
404              jQuery("head").append(
405                '<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">'
406              );
407
408              params.phrase = "";
409
410              if (params.ttob.url == "") {
411                params.ttob.url = "https://turbotax.intuit.com/";
412              }
413
414              //Setting Sweeps to false since there is no sweepstakes for TurboTax Jan 2021.
415              params.ttob.sweeps = false;
416              var phraseParts = {
417                pre: "Ready for your tax refund? Save on ",
418                link: "TurboTax",
419                post: ".",
420              };
421
422              if (
423                params.ttob.tpw &&
424                params.ttob.tpw_msg &&
425                params.ttob.tpw_msg >= 1 &&
426                params.ttob.tpw_msg < 3
427              ) {
428                if (params.ttob.sweeps) {
429                  params.phrase =
430                    '<a href="' +
431                    params.ttob.url +
432                    '" onclick="return displayThirdPartyAlert("' +
433                    params.ttob.tpw_msg +
434                    '", this);" class="new_grs_link" target="_blank">Try TurboTax</a> by Feb 13<sup>th</sup> to enter to win $25K!';
435                } else if (params.ttob.extended) {
436                  if (random == 1) {
437                    params.phrase =
438                      phraseParts.pre +
439                      '<a href="' +
440                      params.ttob.url +
441                      '" onclick="return displayThirdPartyAlert(' +
442                      params.ttob.tpw_msg +
443                      ', this);" class="new_grs_link" target="_blank">' +
444                      phraseParts.link +
445                      "</a>" +
446                      phraseParts.post;
447                  } else if (random == 2) {
448                    params.phrase =
449                      'File simple returns free with <a href="' +
450                      params.ttob.url +
451                      '" onclick="return displayThirdPartyAlert(' +
452                      params.ttob.tpw_msg +
453                      ', this);" class="new_grs_link" target="_blank">TurboTax</a>.';
454                  }
455                } else {
456                  if (random == 1) {
457                    params.phrase =
458                      phraseParts.pre +
459                      '<a href="' +
460                      params.ttob.url +
461                      '" onclick="return displayThirdPartyAlert(' +
462                      params.ttob.tpw_msg +
463                      ', this);" class="new_grs_link" target="_blank">' +
464                      phraseParts.link +
465                      "</a>" +
466                      phraseParts.post;
467                  } else if (random == 2) {
468                    params.phrase =
469                      'File simple returns free with <a href="' +
470                      params.ttob.url +
471                      '" onclick="return displayThirdPartyAlert(' +
472                      params.ttob.tpw_msg +
473                      ', this);" class="new_grs_link" target="_blank">TurboTax</a>.';
474                  }
475                }
476              } else {
477                console.log("TPW is " + params.ttob.tpw);
478                console.log("TPW msg is " + params.ttob.tpw_msg);
479                if (params.ttob.sweeps) {
480                  params.phrase =
481                    '<a href="' +
482                    params.ttob.url +
483                    '" class="new_grs_link" target="_blank">Try TurboTax</a> by Feb 13<sup>th</sup> to enter to win $25K!';
484                } else if (params.ttob.extended) {
485                  if (random == 1) {
486                    params.phrase =
487                      phraseParts.pre +
488                      '<a href="' +
489                      params.ttob.url +
490                      '" class="new_grs_link" target="_blank">' +
491                      phraseParts.link +
492                      "</a>" +
493                      phraseParts.post;
494                  } else if (random == 2) {
495                    params.phrase =
496                      'File simple returns free with <a href="' +
497                      params.ttob.url +
498                      '" class="new_grs_link" target="_blank">TurboTax</a>.';
499                  }
500                } else {
501                  if (random == 1) {
502                    params.phrase =
503                      phraseParts.pre +
504                      '<a href="' +
505                      params.ttob.url +
506                      '" class="new_grs_link" target="_blank">' +
507                      phraseParts.link +
508                      "</a>" +
509                      phraseParts.post;
510                  } else if (random == 2) {
511                    params.phrase =
512                      'File simple returns free with <a href="' +
513                      params.ttob.url +
514                      '" class="new_grs_link" target="_blank">TurboTax</a>.';
515                  }
516                }
517              }
518
519              params.close =
520                '<div id="new_grs_alert_wrapper" class="ttob_close_wrapper"><div class="new_grs_alert_box_cc"><button id="new_grs_close" aria-label="Close this banner"></button></div></div>';
521
522              params.lc =
523                '<div id="new_grs_notification" class="new_grs_button"><p class="show-tablet show-desktop">' +
524                params.phrase +
525                '</p><p class="show-mobile">' +
526                params.phrase +
527                "</p></div>";
528
529              params.icon =
530                '<div class="new_grs_icon"><span id="ttob_icon"><img src="/mstinc/grp/web_banner/images/turbotax_logo.png" alt="TurboTax checkmark" /></span></div>';
531
532              //writing the content
533              jQuery("body").prepend(
534                '<div id="new_accelerate_banner"><div id="new_grs_container">' +
535                  params.icon +
536                  params.lc +
537                  "</div>" +
538                  params.close +
539                  "</div>"
540              );
541              jQuery("#new_accelerate_banner")
542                .show()
543                .animate({ bottom: "0px" }, 1000);
544
545              // replace with analytics function - cateogry is banner[0]
546              jQuery("#new_accelerate_banner a").on("click", function (event) {
547                var lnk = $(this);
548                if (params.ttob.sweeps) {
549                  var action = "Click Banner TTOB-Sweepstakes";
550                } else {
551                  var action = "Click Banner TTOB";
552                }
553                var href = lnk.attr("href");
554                _gaGRS("send", {
555                  hitType: "event",
556                  eventCategory: "webAccelBanner",
557                  eventAction: action,
558                  eventLabel: params.attr.di_num,
559                });
560              });
561              jQuery("#new_grs_close").on("click", function () {
562                jQuery("#new_accelerate_banner").fadeOut(200);
563                return jQ18.mobile_dropdown.close_drop("web_banner");
564              });
565            });
566        };
567      } else if (params.lifecycle.active || params.lifecycle.active == "true") {
568        /*
569         * This lifecycle stanza links to the registration URL (params.full_reg_url just above) based off of the IB domain in settings.js2.
570         * If that is wrong, update the domain on WSC.
571         * Then reach out to GRS/Marketing (Rischa Trent or Ababa Mention) and give them the FI number and correct domain.
572         * This is to ensure that any scripts you run do not overwrite the data you corrected with their bad data in the FIRE database.
573         */
574        var customBanner = function () {
575          $("head").append("<link>");
576          var css = $("head").children(":last");
577          css
578            .attr({
579              rel: "stylesheet",
580              type: "text/css",
581              href:
582                params.base_url + "/mstinc/grp/web_banner/css/web_banner.css",
583            })
584            .one("load", function () {
585              jQuery("head").append(
586                '<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">'
587              );
588              jQuery("head").append(
589                '<link href="' +
590                  params.base_url +
591                  '/IBPrompt.css" rel="stylesheet">'
592              );
593
594              /*html_droid = params.attr.url.droid ? '<div class="app_button"><a target="_blank" href="'+ params.attr.url.droid +'" id="accel_droid_badge" onclick="'+params.app_alert.oncl
594ick+'"><img src="'+ params.base_url+'/mstinc/grp/acc_mobile/images/androidbadge.png" alt="Android Badge" /></a></div>' : '';*/
595              /*html_itunes = params.attr.url.itunes ? '<div class="app_button"><a target="_blank" href="'+ params.attr.url.itunes +'" id="accel_iphone_badge" onclick="'+params.app_alert.onclick+'"><img src="'+ params.base_url+'/mstinc/grp/acc_mobile/images/applebadge.png" alt="iPhone Badge" /></a></div>' : '';*/
596              /*html_mobile = noApps ? '<div class="app_button"><img src="'+ params.base_url+'/mstinc/grp/acc_mobile/images/badge_mobile.png" border="0" /></div>' : '';*/
597
598              /*params.learn_more = '<div class="learn_more" id="learn_more"><a target="_blank" href="'+ params.base_url + '/mstinc/grp/ulpOB" id="accel_learn_more">Learn More<img src="' + params.base_url + '/mstinc/grp/acc_mobile/images/closeTriangle.png" alt="Learn More Link" /></a></div>';*/
599              params.close =
600                '<div id="new_grs_alert_wrapper"><div class="new_grs_alert_box_cc"><button class="colorFront" id="new_grs_close" aria-label="Close this banner"></button></div></div>';
601
602              params.lc =
603                '<div id="new_grs_notification" class="new_grs_button"><p class="show-tablet show-desktop"><a href="' +
604                params.full_reg_url +
605                '" class="new_grs_link" target="_blank">Online Banking</a> makes it easier to manage your finances.</p><p class="show-mobile"><a href="' +
606                params.full_reg_url +
607                '" class="new_grs_link" target="_blank">Online Banking</a> made easy.</p></div>';
608
609              params.icon =
610                '<div class="new_grs_icon"><span class="colorFront" id="new_grs_icon"></span></div>';
611
612              //writing the content
613              jQuery("body").prepend(
614                '<div id="new_accelerate_banner"><div id="new_grs_container">' +
615                  params.icon +
616                  params.lc +
617                  "</div>" +
618                  params.close +
619                  "</div>"
620              );
621              jQuery("#new_accelerate_banner")
622                .show()
623                .animate({ bottom: "0px" }, 1000);
624
625              jQuery("#new_accelerate_banner").on("show", function () {});
626
627              // replace with analytics function - cateogry is banner[0]
628              jQuery("#new_accelerate_banner a").on("click", function (event) {
629                var lnk = $(this);
630                var action = "Click Banner";
631                var href = lnk.attr("href");
632                _gaGRS("send", {
633                  hitType: "event",
634                  eventCategory: "webAccelBanner",
635                  eventAction: action,
636                  eventLabel: params.attr.di_num,
637                });
638              });
639              jQuery("#new_grs_close").on("click", function () {
640                jQuery("#new_accelerate_banner").fadeOut(200);
641                return jQ18.mobile_dropdown.close_drop("web_banner");
642              });
643            });
644        };
645      }
646
647      var active_drop = true;
648      var text_spacer = "";
649      var mobile_app_content_styles = "";
650      var html_droid = "";
651      var html_itunes = "";
652      var html_mobile = "";
653      var html_text = "";
654
655      if ($(document).width() < 1005) {
656        text_spacer = "<br />";
657        mobile_app_content_styles = noApps
658          ? ' style="min-width: 760px;"'
659          : ' style="min-width: 760px;"';
660      } else {
661        text_spacer = "&nbsp;";
662        mobile_app_content_styles = noApps ? ' style=""' : "";
663      }
664
665      if ($("#MstIncGlobal_pos_rel").length == 0 && params.app_alert.active) {
666        var uFocus = document.activeElement;
667        $("body script").detach();
668        $("body").wrapInner('<div id="mobile_alert_wrap" ></div>');
669        uFocus.focus();
670      }
671
672      if (params.lifecycle.active || params.ttob.active) {
673        customBanner();
674        open_drop(params.gaCategory);
675        //dropdown_fix();
676      }
677    }; //build_banner
678    this.getFiData();
679  };
680})(jQ18);

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.