PageSourceSearch

https://edmontonccchoir.org/scripts/cookies.js

js edmontonccchoir.org collected 2026-10-06 13:16:59 UTC 4,785 bytes, 109 lines download raw bytes

1/**********************************************************************
2  Cookie Functions -- codes based on samples from cookiecentral.com
3**********************************************************************/
4
5// "Internal" function to return the decoded value of a cookie
6function getCookieVal (offset) {
7  var endstr = document.cookie.indexOf (";", offset);
8  if (endstr == -1)
9    endstr = document.cookie.length;
10  return unescape(document.cookie.substring(offset, endstr));
11}
12
13//  Function to correct for 2.x Mac date bug.  Call this function to
14//  fix a date object prior to passing it to SetCookie.
15//  IMPORTANT:  This function should only be called *once* for
16//  any given date object!  See example at the end of this document.
17function FixCookieDate (date) {
18  var base = new Date(0);
19  var skew = base.getTime(); // dawn of (Unix) time - should be 0
20  if (skew > 0)  // Except on the Mac - ahead of its time
21    date.setTime (date.getTime() - skew);
22}
23
24//  Function to return the value of the cookie specified by "name".
25//    name - String object containing the cookie name.
26//    returns - String object containing the cookie value, or null if
27//      the cookie does not exist.
28function GetCookie (name) {
29  var arg = name + "=";
30  var alen = arg.length;
31  var clen = document.cookie.length;
32  var i = 0;
33  while (i < clen) {
34    var j = i + alen;
35    if (document.cookie.substring(i, j) == arg)
36      return getCookieVal (j);
37    i = document.cookie.indexOf(" ", i) + 1;
38    if (i == 0) break; 
39  }
40  return null;
41}
42
43//  Function to create or update a cookie.
44//    name - String object containing the cookie name.
45//    value - String object containing the cookie value.  May contain
46//      any valid string characters.
47//    [expires] - Date object containing the expiration data of the cookie.  If
48//      omitted or null, expires the cookie at the end of the current session.
49//    [path] - String object indicating the path for which the cookie is valid.
50//      If omitted or null, uses the path of the calling document.
51//    [domain] - String object indicating the domain for which the cookie is
52//      valid.  If omitted or null, uses the domain of the calling document.
53//    [secure] - Boolean (true/false) value indicating whether cookie transmission
54//      requires a secure channel (HTTPS).  
55//  The first two parameters are required.  The others, if supplied, must
56//  be passed in the order listed above.  To omit an unused optional field,
57//  use null as a place holder.  For example, to call SetCookie using name,
58//  value and path, you would code:
59//      SetCookie ("myCookieName", "myCookieValue", null, "/");
60//  Note that trailing omitted parameters do not require a placeholder.
61//  To set a secure cookie for path "/myPath", that expires after the
62//  current session, you might code:
63//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
64function SetCookie (name,value,expires,path,domain,secure) {
65  document.cookie = name + "=" + escape (value) +
66    ((expires) ? "; expires=" + expires.toGMTString() : "") +
67    ((path) ? "; path=" + path : "") +
68    ((domain) ? "; domain=" + domain : "") +
69    ((secure) ? "; secure" : "");
70}
71
72//  Function to delete a cookie. (Sets expiration date to start of epoch)
73//    name -   String object containing the cookie name
74//    path -   String object containing the path of the cookie to delete.  This MUST
75//             be the same as the path used to create the cookie, or null/omitted if
76//             no path was specified when creating the cookie.
77//    domain - String object containing the domain of the cookie to delete.  This MUST
78//             be the same as the domain used to create the cookie, or null/omitted if
79//             no domain was specified when creating the cookie.
80function DeleteCookie (name,path,domain) {
81  if (GetCookie(name)) {
82    document.cookie = name + "=" +
83      ((path) ? "; path=" + path : "") +
84      ((domain) ? "; domain=" + domain : "") +
85      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
86  }
87}
88
89//  Function to read object properties
90function getSelectValue(selectObject) {
91	return selectObject.options[selectObject.selectedIndex].value
92}
93
94
95//  Function to store calling page information
96//  No parameters
97//  Cookie name is PageInfo
98//  Record calling page URL and valid for 30sec
99function StorePageInfo() {
100  // Use cookie to store the current page info if page called without frame
101  var expdate=new Date();
102  var tempstr
103  if (self==parent){
104    tempstr=document.location.href
105    //set expire date to 30sec
106    expdate.setTime(expdate.getTime() + (30*1000));
107    SetCookie("PageInfo",tempstr,expdate,"/");
108  }
109}

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.