PageSourceSearch

https://online.maryville.edu/wp-content/themes/twoyou/dist/static/scripts/cpra-one-trust.js?m=1790762540g

js maryville.edu collected 2026-10-01 09:04:31 UTC 6,056 bytes, 167 lines download raw bytes

1/* eslint-disable */
2function OptanonWrapper() {
3  // Get initial OnetrustActiveGroups ids
4  if (typeof OptanonWrapperCount == 'undefined') {
5    otGetInitialGrps();
6  }
7
8  //Delete cookies
9  otDeleteCookie(otIniGrps);
10  // Assign OnetrustActiveGroups to custom variable
11  function otGetInitialGrps() {
12    OptanonWrapperCount = '';
13    otIniGrps = OnetrustActiveGroups;
14    // console.log("otGetInitialGrps", otIniGrps)
15  }
16
17  function otDeleteCookie(iniOptGrpId) {
18    var otDomainGrps = JSON.parse(JSON.stringify(Optanon.GetDomainData().Groups));
19    var otDeletedGrpIds = otGetInactiveId(iniOptGrpId, OnetrustActiveGroups);
20    if (otDeletedGrpIds.length != 0 && otDomainGrps.length != 0) {
21      for (var i = 0; i < otDomainGrps.length; i++) {
22        //Check if CustomGroupId matches
23        if (
24          otDomainGrps[i]['CustomGroupId'] != '' &&
25          otDeletedGrpIds.includes(otDomainGrps[i]['CustomGroupId'])
26        ) {
27          for (var j = 0; j < otDomainGrps[i]['Cookies'].length; j++) {
28            // console.log("otDeleteCookie",otDomainGrps[i]['Cookies'][j]['Name'])
29            //Delete cookie
30            eraseCookie(otDomainGrps[i]['Cookies'][j]['Name']);
31          }
32        }
33
34        //Check if Hostid matches
35        if (otDomainGrps[i]['Hosts'].length != 0) {
36          for (var j = 0; j < otDomainGrps[i]['Hosts'].length; j++) {
37            //Check if HostId presents in the deleted list and cookie array is not blank
38            if (
39              otDeletedGrpIds.includes(otDomainGrps[i]['Hosts'][j]['HostId']) &&
40              otDomainGrps[i]['Hosts'][j]['Cookies'].length != 0
41            ) {
42              for (var k = 0; k < otDomainGrps[i]['Hosts'][j]['Cookies'].length; k++) {
43                //Delete cookie
44                eraseCookie(otDomainGrps[i]['Hosts'][j]['Cookies'][k]['Name']);
45              }
46            }
47          }
48        }
49      }
50    }
51    otGetInitialGrps(); //Reassign new group ids
52  }
53
54  //Get inactive ids
55  function otGetInactiveId(customIniId, otActiveGrp) {
56    //Initial OnetrustActiveGroups
57    // console.log("otGetInactiveId",customIniId)
58    customIniId = customIniId.split(',');
59    customIniId = customIniId.filter(Boolean);
60
61    //After action OnetrustActiveGroups
62    otActiveGrp = otActiveGrp.split(',');
63    otActiveGrp = otActiveGrp.filter(Boolean);
64
65    var result = [];
66    for (var i = 0; i < customIniId.length; i++) {
67      if (otActiveGrp.indexOf(customIniId[i]) <= -1) {
68        result.push(customIniId[i]);
69      }
70    }
71    return result;
72  }
73
74  //Delete cookie
75  function eraseCookie(name) {
76    //Delete root path cookies
77    domainName = window.location.origin.replace(/^https?:\/\//, '');
78    document.cookie = name + '=; Max-Age=-99999999; Path=/;Domain=' + domainName;
79    document.cookie = name + '=; Max-Age=-99999999; Path=/;';
80
81    //Delete LSO incase LSO being used, cna be commented out.
82    localStorage.removeItem(name);
83
84    //Check for the current path of the page
85    pathArray = window.location.pathname.split('/'); // phpcs:ignore WordPressVIPMinimum.JS.Window.VarAssignment
86    //Loop through path hierarchy and delete potential cookies at each path.
87    for (var i = 0; i < pathArray.length; i++) {
88      if (pathArray[i]) {
89        //Build the path string from the Path Array e.g /site/login
90        var currentPath = pathArray.slice(0, i + 1).join('/');
91        document.cookie =
92          name + '=; Max-Age=-99999999; Path=' + currentPath + ';Domain=' + domainName;
93        document.cookie = name + '=; Max-Age=-99999999; Path=' + currentPath + ';';
94        //Maybe path has a trailing slash!
95        document.cookie =
96          name + '=; Max-Age=-99999999; Path=' + currentPath + '/;Domain=' + domainName;
97        document.cookie = name + '=; Max-Age=-99999999; Path=' + currentPath + '/;';
98      }
99    }
100  }
101}
102
103function doNotSellCookieChange() {
104  const hostname = window.location.origin.replace(/^https?:\/\//, '');
105  document.cookie = `barnacle_do_not_sell=true; path=/; domain= + ${hostname};max-age=157680000`;
106}
107
108function removeCookie(name) {
109  let host = window.location.origin.replace(/^https?:\/\//, '');
110  let splitHostArray = host.split(".");
111
112  function expireCookie(cookieName, host) {
113    document.cookie = cookieName + "='';max-age=-1; Path=/; Domain=" + host;
114  }
115
116  //need to iterate through the subdomains to TLD to ensure cookie is removed at the proper domain level
117  //no harm in removing it for domains it wasn't set at, so just run all the way up to TLD
118  function removeSubdomain(host) {
119    let tempSplitHostArray = host.split(".");
120    tempSplitHostArray.shift();
121    return tempSplitHostArray.join(".");
122  }
123
124  for (let count = 0; count < splitHostArray.length - 1; count++) {
125    expireCookie(name, host);
126    host = removeSubdomain(host);
127  }
128}
129
130function deleteCookieIfConsentChanged(cookieName, firstConsentString, secondConsentString) {
131  if (firstConsentString !== secondConsentString) {
132    removeCookie(cookieName);
133  }
134}
135
136function addOptimizelyEventListeners(OTInitialConsentGroups) {
137  const OTSaveButtons = document.querySelectorAll('.save-preference-btn-handler');
138
139  if (OTSaveButtons.length > 0) {
140    OTSaveButtons.forEach(el => {
141      el.addEventListener('click', () => {
142        //captures change in consent groups after a user saves new preferences
143        let OTSubsequentConsentGroups = (typeof otIniGrps != 'undefined') ? otIniGrps : '';
144        deleteCookieIfConsentChanged(
145          'optimizelyEndUserId',
146          OTInitialConsentGroups,
147          OTSubsequentConsentGroups
148        );
149      });
150    });
151  }
152}
153
154window.addEventListener('DOMContentLoaded', () => {
155  const twoyouCrpa = document.querySelectorAll('.twoyou-cpra-ot');
156
157  if (twoyouCrpa.length > 0) {
158    let OTConsentGroups = (typeof otIniGrps != 'undefined') ? otIniGrps : '';
159    twoyouCrpa.forEach(el => {
160      el.addEventListener('click', () => {
161        doNotSellCookieChange();
162        OneTrust.ToggleInfoDisplay(); // eslint-disable-linef
163        addOptimizelyEventListeners(OTConsentGroups);
164      });
165    });
166  }
167});

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.