PageSourceSearch

https://subscribe.writersdigest.com/js/olyticsLinkAssistance.js

js writersdigest.com collected 2026-10-01 09:01:20 UTC 4,150 bytes, 126 lines download raw bytes

1$(window).load(function(){
2	//to override this just set window.cookieNamesAndParamsOverride in a JS include before the footer
3	//array is cookie name : value to use as link param
4	//REMEMBER to update the generic level "This is not me" widget hosted content if cookie names change
5	var cookieNamesAndParams = window.cookieNamesAndParamsOverride || {
6			"oly_anon_id" : "oly_anon_id",
7			"oly_enc_id" : "oly_enc_id"
8	};//3.0 params (also need to update below to find new cookie name)
9	//to override this just set window.excludeLinkListOverride in a JS include before the footer
10	var excludeLinkList = window.excludeLinkListOverride || "";
11	generateLinks(cookieNamesAndParams,excludeLinkList.split("%%,,%%"));
12});
13
14function generateLinks(cookieNameArray,excludeLinkList) {
15	var applicableLinkIDs = $("a");
16	
17	for (var l = 0; l < applicableLinkIDs.length; l++){
18		var href = $(applicableLinkIDs[l]).attr("href");
19		var skipLink = false;
20		if (excludeLinkList.length>0) {
21			for (var x = 0; x < excludeLinkList.length; x++) {
22				if (href==excludeLinkList[x]) {
23					skipLink = true; 
24					break;
25				}
26			}
27		}
28		if (href && (href.indexOf('dragonforms')>-1 || href.charAt(0)=='/' || skipLink || href.indexOf('ViewCommInBrowser.jsp')>-1))
29			continue;//no need to add these to omeda links, also see OPS-65188 for excludeLinkList and ViewCommInBrowser changes
30		
31		var hasUrlParams = false;
32		if(href && href.indexOf('?') > -1)
33			hasUrlParams = true;
34		
35		for (var c in cookieNameArray){
36			var currentParam = cookieNameArray[c];
37			var currentCookie = getKey(cookieNameArray, currentParam);
38			var currentCookieVal = getCookie(currentCookie);
39
40			if (currentCookie=="oly_enc_id"){				
41				var encryptID = "";		
42				var tempEID = getUrlParameters("r","",true); //passing an empty string as the 2nd param lets the funct use the current url
43				if (tempEID!=null && tempEID!="")
44					encryptID=tempEID;
45				
46				if (encryptID!=null && encryptID!="")
47					currentCookieVal = encryptID;
48				else
49					currentCookieVal = trimString(currentCookieVal);
50			}
51			else{
52				currentCookieVal = trimString(currentCookieVal);
53			}
54			
55			if (currentCookieVal!=null && currentCookieVal!="null" && currentCookieVal!=""){
56				if(!hasUrlParams){
57					href += "?";
58					hasUrlParams = true;
59				}
60				else{
61					href += "&";
62				}
63				href += currentParam + "=" + currentCookieVal;
64			}
65		}
66		$(applicableLinkIDs[l]).attr("href", href);
67	}
68}
69
70function getUrlParameters(parameter, staticURL, decode){
71   /*
72    Function: getUrlParameters
73    Description: Get the value of URL parameters either from current URL or static URL
74    Author: Tirumal
75    URL: www.code-tricks.com
76   */
77   var currLocation = (staticURL.length)? staticURL : window.location.search;
78   if(currLocation == "")
79	   return "";
80   
81   var parArr = currLocation.split("?")[1].split("&"),
82       returnBool = true;
83   
84   for(var i = 0; i < parArr.length; i++){
85        parr = parArr[i].split("=");
86        if(parr[0] == parameter){
87            return (decode) ? decodeURIComponent(parr[1]) : parr[1];
88            returnBool = true;
89        }else{
90            returnBool = false;            
91        }
92   }
93   
94   if(!returnBool) return false;  
95}
96
97function getCookie(cookiename) {
98    var name = cookiename + "=";
99    var ca = document.cookie.split(';');
100    for(var i=0; i<ca.length; i++) {
101        var c = ca[i];
102        while (c.charAt(0)==' ') c = c.substring(1);
103        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
104    }
105    return "";
106}
107
108function trimString(currentCookie){
109	//%22 is no longer being added to the cookie per OPS-82792
110	/*if (currentCookie.length) {
111	    //remove the %22 from the front
112		currentCookie = currentCookie.substring(3);
113        //then trim %22 from the back
114		currentCookie = currentCookie.substring(0, currentCookie.length - 3);
115	}*/
116	return currentCookie;
117}
118
119function getKey(cookieNameArray, value){
120	for(var key in cookieNameArray){
121	    if(cookieNameArray[key] == value){
122	      return key;
123	    }
124	}
125	return null;
126}

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.