2 function isXUL() { return IAMXUL; }
5 /* - Request ------------------------------------------------------------- */
6 function Request(type) {
7 var s = type.split(":");
8 this.request = new RemoteRequest(s[0], s[1]);
9 for( var x = 1; x!= arguments.length; x++ )
10 this.request.addParam(arguments[x]);
13 Request.prototype.callback = function(cal) { this.request.setCompleteCallback(cal); }
14 Request.prototype.send = function(block){this.request.send(block);}
15 /* ----------------------------------------------------------------------- */
18 /* finds the name of the current page */
19 function findCurrentPage() {
20 for( var p in config.page ) {
21 var path = location.pathname;
23 if(!path.match(/.*\.xml$/))
24 path += "index.xml"; /* in case they go to / */
26 if( config.page[p] == path)
33 /* builds an opac URL. If no page is defined, the current page is used
34 if slim, then only everything after the ? is returned (no host portion)
36 function buildOPACLink(args, slim) {
41 var string = location.protocol + "//" + location.host;
42 if(args.page) string += config.page[args.page];
43 else string += config.page[findCurrentPage()];
48 for( var x in args ) {
49 if(x == "page" || args[x] == null) continue;
50 string += "&" + x + "=" + encodeURIComponent(args[x]);
53 string += _appendParam(TERM, PARAM_TERM, args, getTerm, string);
54 string += _appendParam(STYPE, PARAM_STYPE, args, getStype, string);
55 string += _appendParam(LOCATION, PARAM_LOCATION, args, getLocation, string);
56 string += _appendParam(DEPTH, PARAM_DEPTH, args, getDepth, string);
57 string += _appendParam(FORM, PARAM_FORM, args, getForm, string);
58 string += _appendParam(OFFSET, PARAM_OFFSET, args, getOffset, string);
59 string += _appendParam(COUNT, PARAM_COUNT, args, getDisplayCount, string);
60 string += _appendParam(HITCOUNT, PARAM_HITCOUNT, args, getHitCount, string);
61 string += _appendParam(MRID, PARAM_MRID, args, getMrid, string);
62 string += _appendParam(RID, PARAM_RID, args, getRid, string);
63 return string.replace(/\&$/,'').replace(/\?\&/,"?");
66 function _appendParam( fieldVar, fieldName, overrideArgs, getFunc, string ) {
68 if( fieldVar != null && overrideArgs[fieldName] == null )
69 ret = "&" + fieldName + "=" + encodeURIComponent(getFunc());
77 /* ----------------------------------------------------------------------- */
78 /* some useful exceptions */
79 function EX(message) { this.init(message); }
81 EX.prototype.init = function(message) {
82 this.message = message;
85 EX.prototype.toString = function() {
86 return "\n *** Exception Occured \n" + this.message;
89 EXCommunication.prototype = new EX();
90 EXCommunication.prototype.constructor = EXCommunication;
91 EXCommunication.baseClass = EX.prototype.constructor;
93 function EXCommunication(message) {
94 this.init("EXCommunication: " + message);
96 /* ----------------------------------------------------------------------- */
98 function cleanISBN(isbn) {
100 isbn = isbn.toString().replace(/^\s+/,"");
101 var idx = isbn.indexOf(" ");
102 if(idx > -1) { isbn = isbn.substring(0, idx); }
112 /* ----------------------------------------------------------------------- */
113 /* builds a link that goes to the title listings for a metarecord */
114 function buildTitleLink(rec, link) {
117 t = normalize(truncate(t, 65));
118 link.appendChild(text(t));
122 args[PARAM_OFFSET] = 0;
123 args[PARAM_MRID] = rec.doc_id();
124 link.setAttribute("href", buildOPACLink(args));
127 /* builds an author search link */
128 function buildAuthorLink(rec, link) {
130 var a = rec.author();
131 a = normalize(truncate(a, 65));
132 link.appendChild(text(a));
136 args[PARAM_OFFSET] = 0;
137 args[PARAM_STYPE] = "author";
138 args[PARAM_TERM] = rec.author();
139 link.setAttribute("href", buildOPACLink(args));
142 /* ----------------------------------------------------------------------- */