PageSourceSearch

https://www.empiretoday.com/assets/scripts/url-parameters.js

js empiretoday.com collected 2026-09-25 14:12:05 UTC 2,704 bytes, 77 lines download raw bytes

1// Global Variables
2var incomingUrl = window.location.href;
3var urlLenght = incomingUrl.length;
4
5jQuery.extend({
6    getQueryParameters: function (str) {
7        return (str || document.location.search).replace(/(^\?)/, '').split("&").map(function (n) { return n = n.split("="), this[n[0].toLowerCase()] = n[1] == undefined ? n[1] : decodeURIComponent(n[1]), this }.bind({}))[0];
8    }
9});
10var queryParams = $.getQueryParameters();
11
12
13// PromoCode Url Parameter
14var promoParam = "promocode=";
15
16
17if (incomingUrl.toLowerCase().indexOf(promoParam) >= 0) {
18    // create session storage
19    localStorage.setItem("urlPromoCode", queryParams.promocode);
20    localStorage.setItem("promoAdded", false);
21}
22
23// Url Parameter if comming from the business thank you page
24var commercialLandingPage = "businesslp=true";
25
26if (incomingUrl.toLowerCase().indexOf(commercialLandingPage) >= 0) {
27    // create session storage for business property
28    localStorage.setItem("property", "Business or Professionally-Managed Property");
29}
30
31
32
33
34
35// Google Analytics Parameters
36var actypeParam = "actype=";
37var utmSourceParam = "utm_source=";
38var actype = "";
39var utmSource = "";
40
41if (incomingUrl.toLowerCase().indexOf(actypeParam) >= 0 && incomingUrl.toLowerCase().indexOf(utmSourceParam) >= 0 ) {
42    // Indexes of Url Params
43    var actypeBegins = incomingUrl.toLowerCase().indexOf(actypeParam) + actypeParam.length;
44    var utmSourceBegins = incomingUrl.toLowerCase().indexOf(utmSourceParam) + utmSourceParam.length;
45    // Get URL Param values
46    actype = getUrlParam(actypeBegins);
47    utmSource = getUrlParam(utmSourceBegins);
48    // Create cookie
49    setCookie("gtag_actype", actype);
50    setCookie("gtag_utm-source", utmSource);
51}
52
53
54
55
56
57// Functions
58function getUrlParam(start) {
59    var paramValue = "";
60    for (x = start; x < urlLenght; x++) {
61        // check if charCode is between 48-57 & 65-90 & 97-122 (no special characters allowed except for "-" & "_")
62        if ((incomingUrl.charCodeAt(x) == 45) || (incomingUrl.charCodeAt(x) > 47 && incomingUrl.charCodeAt(x) < 58) || (incomingUrl.charCodeAt(x) > 64 && incomingUrl.charCodeAt(x) < 91) || (incomingUrl.charCodeAt(x) == 95) || (incomingUrl.charCodeAt(x) > 96 && incomingUrl.charCodeAt(x) < 123)) {
63            paramValue += incomingUrl.charAt(x);
64        }
65        else {
66            break;
67        }
68    }
69    return paramValue;
70}
71
72function setCookie(cookieName, cookieValue) {
73    var date = new Date();
74    date.setDate(date.getDate() + 30);
75    var expiryDate = date.toGMTString();
76    document.cookie = cookieName + "=" + cookieValue + ";expires=" + expiryDate + ";path=/";
77}

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.