+++ /dev/null
-/*
-DISCLAIMER: THESE JAVASCRIPT FUNCTIONS ARE SUPPLIED 'AS IS', WITH
-NO WARRANTY EXPRESSED OR IMPLIED. YOU USE THEM AT YOUR OWN RISK.
-PAUL STEPHENS DOES NOT ACCEPT ANY LIABILITY FOR
-ANY LOSS OR DAMAGE RESULTING FROM THEIR USE, HOWEVER CAUSED.
-
-Paul Stephens' cookie-handling object library
-
-Version 2.1
-2.0 - Introduces field names
-2.1 - Fixes bug where undefined embedded fields[] elements weren't written to disk
-
-www.paulspages.co.uk
-
-TO USE THIS LIBRARY, INSERT ITS CONTENTS IN THE <HEAD> SECTION
-OF YOUR WEB PAGE SOURCE, BEFORE ANY OTHER JAVASCRIPT ROUTINES.
-
-(C) Paul Stephens, 2001-2003. Feel free to use this code, but please leave this comment block in. This code must not be sold, either alone or as part of an application, without the consent of the author.
-*/
-
-function cookieObject(name, expires, accessPath) {
-var i, j
-this.name = name
-this.fieldSeparator = "#"
-this.found = false
-this.expires = expires
-this.accessPath = accessPath
-this.rawValue = ""
-this.fields = new Array()
-this.fieldnames = new Array()
-if (arguments.length > 3) {
- j = 0
- for (i = 3; i < arguments.length; i++) {
- this.fieldnames[j] = arguments[i]
- j++
- }
- this.fields.length = this.fieldnames.length
-}
-this.read = ucRead
-this.write = ucWrite
-this.remove = ucDelete
-this.get = ucFieldGet
-this.put = ucFieldPut
-this.namepos = ucNamePos
-this.read()
-}
-
-function ucFieldGet(fieldname) {
-var i = this.namepos(fieldname)
-if (i >=0) {
- return this.fields[i]
-} else {
- return "BadFieldName!"
-}
-}
-function ucFieldPut (fieldname, fieldval) {
-var i = this.namepos(fieldname)
-if(i < 0) {
- i = this.fieldnames.length;
- this.fieldnames[i] = fieldname;
-}
-this.fields[i] = fieldval
-return true
-}
-function ucNamePos(fieldname) {
-var i
-for (i = 0; i < this.fieldnames.length; i++) {
- if (fieldname == this.fieldnames[i]) {
- return i
- }
-}
-return -1
-}
-function ucWrite() {
- var cookietext = this.name + "="
-if (this.fields.length == 1) {
- cookietext += escape(this.fields[0])
- } else {
- for (i= 0; i < this.fields.length; i++) {
- cookietext += escape(this.fields[i]) + this.fieldSeparator }
- }
- if (this.expires != null) {
- if (typeof(this.expires) == "number") {
- var today=new Date()
- var expiredate = new Date()
- expiredate.setTime(today.getTime() + 1000*60*60*24*this.expires)
- cookietext += "; expires=" + expiredate.toGMTString()
- } else {
- cookietext += "; expires=" + this.expires.toGMTString()
- }
- }
- if (this.accessPath != null) {
- cookietext += "; PATH="+this.accessPath }
- document.cookie = cookietext
- return null
-}
-function ucRead() {
- var search = this.name + "="
- var CookieString = document.cookie
- if(CookieString == null) CookieString = "";
- this.rawValue = null
- this.found = false
- if (CookieString.length > 0) {
- offset = CookieString.indexOf(search)
- if (offset != -1) {
- offset += search.length
- end = CookieString.indexOf(";", offset)
- if (end == -1) {
- end = CookieString.length }
- this.rawValue = CookieString.substring(offset, end)
- this.found = true
- }
- }
-if (this.rawValue != null) { // unpack into fields
- var sl = this.rawValue.length
- var startidx = 0
- var endidx = 0
- var i = 0
-if (this.rawValue.substr(sl-1, 1) != this.fieldSeparator) {
- this.fields[0] = unescape(this.rawValue)
- } else {
- do
- {
- endidx = this.rawValue.indexOf(this.fieldSeparator, startidx)
- if (endidx !=-1) {
- this.fields[i] = unescape(this.rawValue.substring(startidx, endidx))
- i++
- startidx = endidx + 1}
- }
- while (endidx !=-1 & endidx != (this.rawValue.length -1));
-}
-}
- return this.found
-}
-function ucDelete() {
- this.expires = -10
- this.write()
- return this.read()
-}
// HTTP.Cookies - Burak Gürsoy <burak[at]cpan[dot]org>
+
+/*
+I removed all the docs (except author and license info) to reduce download size
+-bill erickson <billserickson@gmail.com>
+*/
+
if (!HTTP) var HTTP = {}; // create base class if undefined
HTTP.Cookies = function () { // HTTP.Cookies constructor
HTTP.Cookies - JavaScript class for reading, writing and deleting cookies
-=head1 SYNOPSIS
-
- var cookie = new HTTP.Cookies;
- var password = cookie.read('password');
- var lastvisit = cookie.read('lastvisit');
- cookie.write('lastvisit',1079383075,'+1y');
- cookie.remove('password');
-
-=head1 DESCRIPTION
-
-HTTP.Cookies is a class for http cookies manipulation. It defines
-three object methods to read, write and remove cookies. Implementation
-is somehow similar to the Perl module CGI.pm' s C<cookie()> method.
-
-=head1 METHODS
-
-=head2 read NAME
-
-Reads the cookie named C<name> and returns it's value or an empty
-string upon failure.
-
-=head2 write NAME, VALUE [, EXPIRES, PATH, DOMAIN, SECURE]
-
-Creates a new cookie with C<NAME> and C<VALUE>. Optional C<EXPIRES>
-value sets the cookie lifetime.
-
-Expire date format: you can use negative or positive numbers combined
-with 's', 'm', 'h', 'd', 'w', 'M', 'y' or you can use 'now' to
-expire as soon as possible. Meanings:
-
- s = second
- m = minute
- h = hour
- d = day
- w = week
- M = month
- y = year
- now = immediately
-
-for a session cookie; pass "-1" as the expires value.
-
-Optional parameter C<DOMAIN> can be used to define the domain
-for which the HTTP cookie is valid.
-
-Optional parameter C<EXPIRES> can be used to make it a secure cookie
-(secure cookies can only be used with HTTPS protocol).
-
-=head2 remove NAME [, PATH, DOMAIN, SECURE]
-
-Deletes/removes the named cookie from the client.
-
-=head1 SEE ALSO
-
-=head1 BUGS
-
-Contact the author if you find any.
-
-This library is tested with: Opera 8.01, MSIE 6.0,
-Netscape Communicator 4.77, Mozilla 1.7.8
-and Mozilla FireFox 1.0.4 under Windows XP Professional SP2.
-
=head1 AUTHOR
Burak Gürsoy, E<lt>burakE<64>cpan.orgE<gt>
/* define it again here for pages that don't load RemoteRequest */
function isXUL() { try { if(IAMXUL) return true;}catch(e){return false;}; }
+var cookieManager = new HTTP.Cookies();
+
var __ilsEvent; /* the last event the occurred */
function Request(type) {
function initCookies() {
FONTSIZE = "medium";
- var font = fontCookie.get(COOKIE_FONT);
+ var font = cookieManager.read(COOKIE_FONT);
if(font) FONTSIZE = font;
- SKIN = skinCookie.get(COOKIE_SKIN);
+ SKIN = cookieManager.read(COOKIE_SKIN);
}
/* URL param accessors */
to find one in the cookies. If 'force' is true we retrieve the
user from the server even if there is already a global user present.
if ses != G.user.session, we also force a grab */
-var cookie = new cookieObject("ses", 1, "/", COOKIE_SES);
function grabUser(ses, force) {
if(!ses && isXUL()) ses = xulG['authtoken'];
- if(!ses) ses = cookie.get(COOKIE_SES);
+ if(!ses) ses = cookieManager.read(COOKIE_SES);
if(!ses) return false;
if(!force)
G.user = user;
G.user.fleshed = false;
G.user.session = ses;
- cookie.put(COOKIE_SES, ses);
- cookie.write();
+ cookieManager.write(COOKIE_SES, ses, '+1y');
grabUserPrefs();
if(G.user.prefs['opac.hits_per_page'])
if(!G.user || G.user.length == 0) {
G.user = null; return false;
- cookie.remove(COOKIE_SES);
+ cookieManager.remove(COOKIE_SES);
}
G.user.session = ses;
G.user.fleshed = true;
- cookie.put(COOKIE_SES, ses); /* update the cookie */
- cookie.write();
-
+ cookieManager.write(COOKIE_SES, ses, '+1y'); /* update the cookie */
return G.user;
}
-var skinCookie = new cookieObject("skin", 1, "/", COOKIE_SKIN);
function checkUserSkin(new_skin) {
return; /* XXX do some debugging with this... */
if(grabUser()) {
if(grabUserPrefs()) {
user_skin = G.user.prefs["opac.skin"];
- skinCookie.put( COOKIE_SKIN, user_skin );
- skinCookie.write();
+ cookieManager.write( COOKIE_SKIN, user_skin, '+1y' );
}
}
}
}
G.user = null;
- cookie.remove(COOKIE_SES);
- skinCookie.remove(COOKIE_SKIN);
+ cookieManager.remove(COOKIE_SES);
+ cookieManager.remove(COOKIE_SKIN);
checkUserSkin("default");
COUNT = 10;
G.ui.common.now_searching.appendChild(text(findOrgUnit(id).name()));
}
-var fontCookie = new cookieObject("fonts", 1, "/", COOKIE_FONT);
+var fontCookie = new HTTP.Cookies();
function setFontSize(size) {
scaleFonts(size);
- fontCookie.put(COOKIE_FONT, size);
- fontCookie.write();
+ fontCookie.write(COOKIE_FONT, size, '+1y');
}
<!ENTITY opac.session_expiring
- "Your login session will timeout in 1 minute unless there is activity">
+ "Your login session will timeout in 1 minute unless there is activity.">
<!ENTITY opac.session_expired "Your login session has expired">
<!ENTITY navigate.home "Home">
var onlyrecord = {};
var table;
var mresultPreCache = 200;
-//var idsCookie = new cookieObject("ids", 1, "/", COOKIE_IDS);
-//var idsCookie;
-var idsCookie = new HTTP.Cookies();
var searchTimer;
attachEvt("common", "unload", mresultUnload);
attachEvt("result", "idsReceived", mresultSetRecords);
attachEvt("result", "idsReceived", mresultCollectRecords);
-
function mresultUnload() { removeChildren(table); table = null;}
function mresultDoSearch() {
function mresultLoadCachedSearch() {
if( (getOffset() > 0) && (getOffset() < mresultPreCache) ) {
- var c = JSON2js(idsCookie.read(COOKIE_IDS));
+ var c = JSON2js(cookieManager.read(COOKIE_IDS));
if(c) { records = c[0]; ranks = c[1]; }
}
}
}
if(getOffset() == 0) {
- idsCookie.remove(COOKIE_IDS);
- idsCookie.write(COOKIE_IDS, js2JSON([ records, ranks ]), '+1d' );
- //alert('Set cookies: ' + idsCookie.read(COOKIE_IDS) + ' : ' + idsCookie.read(COOKIE_IDS).length );
+ cookieManager.remove(COOKIE_IDS);
+ cookieManager.write(COOKIE_IDS, js2JSON([ records, ranks ]), '+1d' );
}
TOPRANK = ranks[getOffset()];