Click to See Complete Forum and Search --> : What are these cookie codes doing?


SA Heat
11-19-2003, 02:13 AM
What to yall does it look like this code is doing? Is the code telling it to do 3 things here? Its for my yahoo fantasy Football site, I like the way they run theres and am trying to disect the way they did theres. Heres the code

<SCRIPT>
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function getCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function getLeagueCookie (leagueAbbr, leagueId) {
var resultArray = null;
var cookieLeagueId = "l" + leagueId;
var trackerId = leagueAbbr + "st";
var cookie = getCookie (trackerId);

if (cookie != null) {
var cookieArray = cookie.split (",");
for (var i = 0; i < cookieArray.length; i++) {
if (cookieArray[i] == cookieLeagueId) {
resultArray = cookieArray.slice (i + 1, i + 3);
break;
}
}
}

return resultArray;
}
function launchTracker (leagueAbbr, leagueId, url, defaultWidth, defaultHeight) {
var width;
var height;
var windowName = "stattracker_" + leagueAbbr + "_" + leagueId;
var dims = getLeagueCookie (leagueAbbr, leagueId);
if (dims != null) {
width = dims[0];
height = dims[1];
}
else {
width = defaultWidth;
height = defaultHeight;
}

rs (windowName, url, width, height, 0);
}
</SCRIPT>

The page has Option boxes,list boxes if this helps.