projects
/
pazpar2-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updates to pz:authentication documentation
[pazpar2-moved-to-github.git]
/
js
/
pz2.js
diff --git
a/js/pz2.js
b/js/pz2.js
index
8ae1379
..
1ee8096
100644
(file)
--- a/
js/pz2.js
+++ b/
js/pz2.js
@@
-32,6
+32,7
@@
var pz2 = function ( paramArray )
throw new Error("Pz2.js: Array with parameters has to be supplied.");
//supported pazpar2's protocol version
throw new Error("Pz2.js: Array with parameters has to be supplied.");
//supported pazpar2's protocol version
+ this.windowid = paramArray.windowid || window.name;
this.suppProtoVer = '1';
if (typeof paramArray.pazpar2path != "undefined")
this.pz2String = paramArray.pazpar2path;
this.suppProtoVer = '1';
if (typeof paramArray.pazpar2path != "undefined")
this.pz2String = paramArray.pazpar2path;
@@
-170,7
+171,7
@@
pz2.prototype =
this.stop();
if ( this.resetCallback )
this.stop();
if ( this.resetCallback )
- this.resetCallback();
+ this.resetCallback(this.windowid);
},
init: function (sessionId, serviceId)
},
init: function (sessionId, serviceId)
@@
-214,7
+215,7
@@
pz2.prototype =
context.keepAlive
);
if ( context.initCallback )
context.keepAlive
);
if ( context.initCallback )
- context.initCallback();
+ context.initCallback(context.windowid);
}
else
context.throwError('Init failed. Malformed WS resonse.',
}
else
context.throwError('Init failed. Malformed WS resonse.',
@@
-240,7
+241,7
@@
pz2.prototype =
var request = new pzHttpRequest(this.pz2String, this.errorHandler);
request.safeGet(
var request = new pzHttpRequest(this.pz2String, this.errorHandler);
request.safeGet(
- { "command": "ping", "session": this.sessionID, "windowid" : window.name },
+ { "command": "ping", "session": this.sessionID, "windowid" : context.windowid },
function(data) {
if ( data.getElementsByTagName("status")[0]
.childNodes[0].nodeValue == "OK" ) {
function(data) {
if ( data.getElementsByTagName("status")[0]
.childNodes[0].nodeValue == "OK" ) {
@@
-290,7
+291,7
@@
pz2.prototype =
"command": "search",
"query": this.currQuery,
"session": this.sessionID,
"command": "search",
"query": this.currQuery,
"session": this.sessionID,
- "windowid" : window.name
+ "windowid" : this.windowid
};
if( sort !== undefined ) {
};
if( sort !== undefined ) {
@@
-318,7
+319,8
@@
pz2.prototype =
.childNodes[0].nodeValue == "OK" ) {
context.searchStatusOK = true;
//piggyback search
.childNodes[0].nodeValue == "OK" ) {
context.searchStatusOK = true;
//piggyback search
- context.show(start, num, sort);
+ if (context.showCallback)
+ context.show(start, num, sort);
if (context.statCallback)
context.stat();
if (context.termlistCallback)
if (context.statCallback)
context.stat();
if (context.termlistCallback)
@@
-343,7
+345,7
@@
pz2.prototype =
var context = this;
var request = new pzHttpRequest(this.pz2String, this.errorHandler);
request.safeGet(
var context = this;
var request = new pzHttpRequest(this.pz2String, this.errorHandler);
request.safeGet(
- { "command": "stat", "session": this.sessionID, "windowid" : window.name },
+ { "command": "stat", "session": this.sessionID, "windowid" : context.windowid },
function(data) {
if ( data.getElementsByTagName("stat") ) {
var activeClients =
function(data) {
if ( data.getElementsByTagName("stat") ) {
var activeClients =
@@
-365,7
+367,7
@@
pz2.prototype =
},
delay
);
},
delay
);
- context.statCallback(stat);
+ context.statCallback(stat, context.windowid);
}
else
context.throwError('Stat failed. Malformed WS resonse.',
}
else
context.throwError('Stat failed. Malformed WS resonse.',
@@
-401,7
+403,7
@@
pz2.prototype =
"sort": this.currentSort,
"block": 1,
"type": this.showResponseType,
"sort": this.currentSort,
"block": 1,
"type": this.showResponseType,
- "windowid" : window.name
+ "windowid" : this.windowid
};
if (query_state)
requestParameters["query-state"] = query_state;
};
if (query_state)
requestParameters["query-state"] = query_state;
@@
-471,7
+473,7
@@
pz2.prototype =
context.show();
},
delay);
context.show();
},
delay);
- context.showCallback(show);
+ context.showCallback(show, context.windowid);
}
);
},
}
);
},
@@
-490,7
+492,7
@@
pz2.prototype =
"command": "record",
"session": this.sessionID,
"id": this.currRecID,
"command": "record",
"session": this.sessionID,
"id": this.currRecID,
- "windowid" : window.name
+ "windowid" : this.windowid
};
this.currRecOffset = null;
};
this.currRecOffset = null;
@@
-523,7
+525,7
@@
pz2.prototype =
record = new Array();
record['xmlDoc'] = data;
record['offset'] = context.currRecOffset;
record = new Array();
record['xmlDoc'] = data;
record['offset'] = context.currRecOffset;
- callback(record, args);
+ callback(record, args, context.windowid);
//pz2 record
} else if ( recordNode =
data.getElementsByTagName("record")[0] ) {
//pz2 record
} else if ( recordNode =
data.getElementsByTagName("record")[0] ) {
@@
-553,7
+555,7
@@
pz2.prototype =
},
delay
);
},
delay
);
- callback(record, args);
+ callback(record, args, context.windowid);
}
else
context.throwError('Record failed. Malformed WS resonse.',
}
else
context.throwError('Record failed. Malformed WS resonse.',
@@
-579,7
+581,7
@@
pz2.prototype =
"command": "termlist",
"session": this.sessionID,
"name": this.termKeys,
"command": "termlist",
"session": this.sessionID,
"name": this.termKeys,
- "windowid" : window.name,
+ "windowid" : this.windowid,
"version" : this.version
},
"version" : this.version
},
@@
-642,7
+644,7
@@
pz2.prototype =
delay
);
delay
);
- context.termlistCallback(termList);
+ context.termlistCallback(termList, context.windowid);
}
else
context.throwError('Termlist failed. Malformed WS resonse.',
}
else
context.throwError('Termlist failed. Malformed WS resonse.',
@@
-672,7
+674,7
@@
pz2.prototype =
"command": "bytarget",
"session": this.sessionID,
"block": 1,
"command": "bytarget",
"session": this.sessionID,
"block": 1,
- "windowid" : window.name,
+ "windowid" : this.windowid,
"version" : this.version
},
function(data) {
"version" : this.version
},
function(data) {
@@
-707,11
+709,6
@@
pz2.prototype =
} else if (bytarget[i]["state"]=="Client_Working") {
bytarget[i]["hits"] = "...";
}
} else if (bytarget[i]["state"]=="Client_Working") {
bytarget[i]["hits"] = "...";
}
- if (bytarget[i].diagnostic == "1") {
- bytarget[i].diagnostic = "Permanent system error";
- } else if (bytarget[i].diagnostic == "2") {
- bytarget[i].diagnostic = "Temporary system error";
- }
var targetsSuggestions = targetNodes[i].getElementsByTagName("suggestions");
if (targetsSuggestions != undefined && targetsSuggestions.length>0) {
var suggestions = targetsSuggestions[0];
var targetsSuggestions = targetNodes[i].getElementsByTagName("suggestions");
if (targetsSuggestions != undefined && targetsSuggestions.length>0) {
var suggestions = targetsSuggestions[0];
@@
-731,7
+728,7
@@
pz2.prototype =
delay
);
delay
);
- context.bytargetCallback(bytarget);
+ context.bytargetCallback(bytarget, context.windowid);
}
else
context.throwError('Bytarget failed. Malformed WS resonse.',
}
else
context.throwError('Bytarget failed. Malformed WS resonse.',
@@
-768,7
+765,7
@@
pz2.prototype =
** AJAX HELPER CLASS ***********************************************************
********************************************************************************
*/
** AJAX HELPER CLASS ***********************************************************
********************************************************************************
*/
-var pzHttpRequest = function (url, errorHandler, cookieDomain) {
+var pzHttpRequest = function (url, errorHandler, cookieDomain, windowId) {
this.maxUrlLength = 2048;
this.request = null;
this.url = url;
this.maxUrlLength = 2048;
this.request = null;
this.url = url;
@@
-778,6
+775,7
@@
var pzHttpRequest = function (url, errorHandler, cookieDomain) {
this.isXDR = false;
this.domainRegex = /https?:\/\/([^:/]+).*/;
this.cookieDomain = cookieDomain || null;
this.isXDR = false;
this.domainRegex = /https?:\/\/([^:/]+).*/;
this.cookieDomain = cookieDomain || null;
+ this.windowId = windowId || window.name;
var xhr = new XMLHttpRequest();
var domain = this._getDomainFromUrl(url);
var xhr = new XMLHttpRequest();
var domain = this._getDomainFromUrl(url);
@@
-905,9
+903,9
@@
pzHttpRequest.prototype =
//session cookie, resend it
var domain = this._getDomainFromUrl(url);
if (domain && this._isCrossDomain(domain) &&
//session cookie, resend it
var domain = this._getDomainFromUrl(url);
if (domain && this._isCrossDomain(domain) &&
- this.getCookie(domain+":SESSID")) {
+ this.getCookie(domain+":"+this.windowId+":SESSID")) {
//rewrite the URL
//rewrite the URL
- var sessparam = ';jsessionid=' + this.getCookie(domain+":SESSID");
+ var sessparam = ';jsessionid=' + this.getCookie(domain+":"+this.windowId+":SESSID");
var q = url.indexOf('?');
if (q == -1) {
url += sessparam;
var q = url.indexOf('?');
if (q == -1) {
url += sessparam;
@@
-1019,7
+1017,7
@@
pzHttpRequest.prototype =
var jsessionId = this.request.responseXML
.documentElement.getAttribute('jsessionId');
if (jsessionId)
var jsessionId = this.request.responseXML
.documentElement.getAttribute('jsessionId');
if (jsessionId)
- this.setCookie(domain+":SESSID", jsessionId);
+ this.setCookie(domain+":"+this.windowId+":SESSID", jsessionId);
}
this.callback(this.request.responseXML);
} else {
}
this.callback(this.request.responseXML);
} else {