"start": $.now(),
"last": $.now()
};
+ var m_paz; // will be initialised below
// if (console && console.log) // disabled, will fail in IE8
}
}
- // protocol independend link for pazpar2: "//mkws/sp" -> "https://mkws/sp"
+ // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp"
if (mkws_config.pazpar2_url.match(/^\/\//)) {
mkws_config.pazpar2_url = document.location.protocol + mkws_config.pazpar2_url;
- debug("adjust protocol independend links: " + mkws_config.pazpar2_url);
+ debug("adjust protocol independent links: " + mkws_config.pazpar2_url);
}
debug("Create main pz2 object");
// create a parameters array and pass it to the pz2's constructor
// then register the form submit event with the pz2.search function
// autoInit is set to true on default
- if (!mkws.paz) {
- mkws.paz = new pz2({ "onshow": my_onshow,
- "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way
- "pazpar2path": mkws_config.pazpar2_url,
- "oninit": my_oninit,
- "onstat": my_onstat,
- "onterm": my_onterm,
- "termlist": "xtargets,subject,author",
- "onbytarget": my_onbytarget,
- "usesessions" : mkws_config.use_service_proxy ? false : true,
- "showResponseType": '', // or "json" (for debugging?)
- "onrecord": my_onrecord });
- }
+ m_paz = new pz2({ "onshow": my_onshow,
+ "windowid": teamName,
+ "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way
+ "pazpar2path": mkws_config.pazpar2_url,
+ "oninit": my_oninit,
+ "onstat": my_onstat,
+ "onterm": my_onterm,
+ "termlist": "xtargets,subject,author",
+ "onbytarget": my_onbytarget,
+ "usesessions" : mkws_config.use_service_proxy ? false : true,
+ "showResponseType": '', // or "json" (for debugging?)
+ "onrecord": my_onrecord });
if (!isNaN(parseInt(mkws_config.perpage_default))) {
m_recPerPage = parseInt(mkws_config.perpage_default);
//
// pz2.js event handlers:
//
- function my_oninit() {
- mkws.paz.stat();
- mkws.paz.bytarget();
+ function my_oninit(teamName) {
+ debug("init for " + teamName);
+ m_paz.stat();
+ m_paz.bytarget();
}
- function my_onshow(data) {
+ function my_onshow(data, teamName) {
+ debug("show for " + teamName);
m_totalRec = data.merged;
// move it out
var pager = document.getElementById("mkwsPager");
}
- function my_onstat(data) {
+ function my_onstat(data, teamName) {
+ debug("stat for " + teamName);
var stat = document.getElementById("mkwsStat");
if (stat == null)
return;
}
- function my_onterm(data) {
+ function my_onterm(data, teamName) {
+ debug("term for " + teamName);
// no facets
if (!mkws_config.facets || mkws_config.facets.length == 0) {
$("#mkwsTermlists").hide();
}
- function my_onrecord(data) {
+ function my_onrecord(data, teamName) {
+ debug("record for " + teamName);
// FIXME: record is async!!
- clearTimeout(mkws.paz.recordTimer);
+ clearTimeout(m_paz.recordTimer);
// in case on_show was faster to redraw element
var detRecordDiv = document.getElementById('mkwsDet_'+data.recid);
if (detRecordDiv) return;
}
- function my_onbytarget(data) {
+ function my_onbytarget(data, teamName) {
+ debug("target for " + teamName);
var targetDiv = document.getElementById("mkwsBytarget");
if (!targetDiv) {
// No mkwsTargets div.
if (!m_submitted) return false;
resetPage();
loadSelect();
- mkws.paz.show(0, m_recPerPage, m_sort);
+ m_paz.show(0, m_recPerPage, m_sort);
return false;
}
}
debug("triggerSearch(" + m_query + "): filters = " + $.toJSON(m_filters) + ", pp2filter = " + pp2filter + ", params = " + $.toJSON(params));
- mkws.paz.search(m_query, m_recPerPage, m_sort, pp2filter, undefined, params);
+ m_paz.search(m_query, m_recPerPage, m_sort, pp2filter, undefined, params);
}
mkws.showPage = function (pageNum)
{
m_curPage = pageNum;
- mkws.paz.showPage(m_curPage - 1);
+ m_paz.showPage(m_curPage - 1);
}
// simple paging functions
mkws.pagerNext = function () {
if (m_totalRec - m_recPerPage*m_curPage > 0) {
- mkws.paz.showNext();
+ m_paz.showNext();
m_curPage++;
}
}
mkws.pagerPrev = function () {
- if (mkws.paz.showPrev() != false)
+ if (m_paz.showPrev() != false)
m_curPage--;
}
return;
}
// request the record
- mkws.paz.record(recId);
+ m_paz.record(recId);
}
}
- function run_auto_searches() {
+ mkws.run_auto_searches = function() {
debug("running auto searches");
$('[id^="mkwsRecords"]').each(function () {
}
- /*
- * Run service-proxy authentication in background (after page load).
- * The username/password is configured in the apache config file
- * for the site.
- */
- mkws.service_proxy_auth = function(auth_url, auth_domain, pp2_url) {
- debug("Run service proxy auth URL: " + auth_url);
-
- if (!auth_domain) {
- auth_domain = pp2_url.replace(/^(https?:)?\/\/(.*?)\/.*/, '$2');
- debug("guessed auth_domain '" + auth_domain + "' from pp2_url '" + pp2_url + "'");
- }
-
- var request = new pzHttpRequest(auth_url, function(err) {
- alert("HTTP call for authentication failed: " + err)
- return;
- }, auth_domain);
-
- request.get(null, function(data) {
- if (!$.isXMLDoc(data)) {
- alert("service proxy auth response document is not valid XML document, give up!");
- return;
- }
- var status = $(data).find("status");
- if (status.text() != "OK") {
- alert("service proxy auth repsonse status: " + status.text() + ", give up!");
- return;
- }
-
- debug("Service proxy auth successfully done");
- mkws.authenticated = true;
- run_auto_searches();
- });
- }
-
-
/* create locale language menu */
function mkws_html_lang() {
var lang_default = "en";
mkws_config.pazpar2_url);
} else {
// raw pp2
- run_auto_searches();
+ mkws.run_auto_searches();
}
});
+
+
+ /*
+ * Run service-proxy authentication in background (after page load).
+ * The username/password is configured in the apache config file
+ * for the site.
+ */
+ mkws.service_proxy_auth = function(auth_url, auth_domain, pp2_url) {
+ debug("Run service proxy auth URL: " + auth_url);
+
+ if (!auth_domain) {
+ auth_domain = pp2_url.replace(/^(https?:)?\/\/(.*?)\/.*/, '$2');
+ debug("guessed auth_domain '" + auth_domain + "' from pp2_url '" + pp2_url + "'");
+ }
+
+ var request = new pzHttpRequest(auth_url, function(err) {
+ alert("HTTP call for authentication failed: " + err)
+ return;
+ }, auth_domain);
+
+ request.get(null, function(data) {
+ if (!$.isXMLDoc(data)) {
+ alert("service proxy auth response document is not valid XML document, give up!");
+ return;
+ }
+ var status = $(data).find("status");
+ if (status.text() != "OK") {
+ alert("service proxy auth repsonse status: " + status.text() + ", give up!");
+ return;
+ }
+
+ debug("Service proxy auth successfully done");
+ mkws.authenticated = true;
+ mkws.run_auto_searches();
+ });
+ }
})(jQuery);