* See the file LICENSE for details
*/
-"use strict"; // HTML5: disable for debug_level >= 2
+"use strict"; // HTML5: disable for log_level >= 2
// Handlebars helpers
//
var mkws = {
authenticated: false,
- debug_level: 1, // Will be overridden from mkws_config, but
- // initial value allows jQuery popup to use logging.
+ log_level: 1, // Will be overridden from mkws_config, but
+ // initial value allows jQuery popup to use logging.
paz: undefined, // will be set up during initialisation
teams: {},
locale_lang: {
var M = mkws.M;
- if (type === 'Targets') {
- promoteTargets();
- } else if (type === 'Stat') {
- promoteStat();
- } else if (type === 'Termlists') {
- promoteTermlists();
- } else if (type === 'Pager') {
- promotePager();
- } else if (type === 'Records') {
- promoteRecords();
+ var type2fn = {
+ Targets: promoteTargets,
+ Stat: promoteStat,
+ Termlists: promoteTermlists,
+ Pager: promotePager,
+ Records: promoteRecords,
+ Navi: promoteNavi,
+ Sort: promoteSort,
+ Perpage: promotePerpage
+ };
+
+ var promote = type2fn[type];
+ if (promote) {
+ promote();
+ log("made " + type + " widget(node=" + node + ")");
} else {
- // ### Handle other types here
+ log("made UNENCAPSULATED widget(type=" + type + ", node=" + node + ")");
}
- team.debug("made widget(type=" + type + ", node=" + node);
return that;
+ function log(s) {
+ team.log(s);
+ }
+
// Functions follow for promoting the regular widget object into
// widgets of specific types. These could be moved outside of the
// widget object, or even into their own source files.
function promoteTargets() {
team.queue("targets").subscribe(function(data) {
- if (node.length === 0) alert("huh?!");
-
var table ='<table><thead><tr>' +
'<td>' + M('Target ID') + '</td>' +
'<td>' + M('Hits') + '</td>' +
function promoteTermlists() {
team.queue("termlists").subscribe(function(data) {
- mkws.debug("in termlist consumer");
if (!node) {
alert("termlists event when there are no termlists");
return;
var html = [];
for (var i = 0; i < data.hits.length; i++) {
var hit = data.hits[i];
- html.push('<div class="record" id="mkwsRecdiv_' + team.name() + '_' + hit.recid + '" >',
- renderSummary(hit),
- '</div>');
+ var divId = team.recordElementId(hit.recid[0]);
+ html.push('<div class="record mkwsTeam_' + team.name() + ' ' + divId + '">', renderSummary(hit), '</div>');
// ### At some point, we may be able to move the
// m_currentRecordId and m_currentRecordData members
// from the team object into this widget.
if (hit.recid == team.currentRecordId()) {
if (team.currentRecordData())
- html.push(renderDetails(team.currentRecordData()));
+ html.push(team.renderDetails(team.currentRecordData()));
}
}
$(node).html(html.join(''));
function renderSummary(hit)
{
var template = team.loadTemplate("Summary");
- hit._id = "mkwsRec_" + hit.recid;
- hit._onclick = "mkws.showDetails('" + team.name() + "', this.id);return false;"
+ hit._id = team.recordElementId(hit.recid[0]);
+ hit._onclick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;"
return template(hit);
}
});
}
+
+
+ function promoteNavi() {
+ team.queue("navi").subscribe(function() {
+ var filters = team.filters();
+ var text = "";
+
+ for (var i in filters) {
+ if (text) {
+ text += " | ";
+ }
+ var filter = filters[i];
+ if (filter.id) {
+ text += M('source') + ': <a class="crossout" href="#" onclick="mkws.delimitTarget(\'' + team.name() +
+ "', '" + filter.id + "'" + ');return false;">' + filter.name + '</a>';
+ } else {
+ text += M(filter.field) + ': <a class="crossout" href="#" onclick="mkws.delimitQuery(\'' + team.name() +
+ "', '" + filter.field + "', '" + filter.value + "'" +
+ ');return false;">' + filter.value + '</a>';
+ }
+ }
+
+ $(node).html(text);
+ });
+ }
+
+
+ function promoteSort() {
+ // It seems this and the Perpage widget doen't need to
+ // subscribe to anything, since they produce events rather
+ // than consuming them.
+ $(node).change(function () {
+ team.set_sortOrder($(node).val());
+ if (team.submitted()) {
+ team.resetPage();
+ team.reShow();
+ }
+ return false;
+ });
+ }
+
+
+ function promotePerpage() {
+ $(node).change(function() {
+ team.set_perpage($(node).val());
+ if (team.submitted()) {
+ team.resetPage();
+ team.reShow();
+ }
+ return false;
+ });
+ }
}
var m_currentPage = 1;
var m_currentRecordId = '';
var m_currentRecordData = null;
- var m_debugTime = {
+ var m_logTime = {
// Timestamps for logging
"start": $.now(),
"last": $.now()
var m_template = {};
that.name = function() { return m_teamName; }
+ that.submitted = function() { return m_submitted; }
that.perpage = function() { return m_perpage; }
that.totalRecordCount = function() { return m_totalRecordCount; }
that.currentPage = function() { return m_currentPage; }
that.currentRecordId = function() { return m_currentRecordId; }
that.currentRecordData = function() { return m_currentRecordData; }
+ that.filters = function() { return m_filters; }
+
+ that.set_sortOrder = function(val) { m_sortOrder = val };
+ that.set_perpage = function(val) { m_perpage = val };
+
- var debug = function (s) {
+ var log = function (s) {
var now = $.now();
- var timestamp = ((now - m_debugTime.start)/1000).toFixed(3) + " (+" + ((now - m_debugTime.last)/1000).toFixed(3) + ") "
- m_debugTime.last = now;
+ var timestamp = ((now - m_logTime.start)/1000).toFixed(3) + " (+" + ((now - m_logTime.last)/1000).toFixed(3) + ") "
+ m_logTime.last = now;
- mkws.debug(m_teamName + ": " + timestamp + s);
+ mkws.log(m_teamName + ": " + timestamp + s);
}
- that.debug = debug;
+ that.log = log;
- debug("start running MKWS");
+ log("start running MKWS");
m_sortOrder = mkws_config.sort_default;
m_perpage = mkws_config.perpage_default;
- debug("Create main pz2 object");
+ log("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
// pz2.js event handlers:
//
function onInit() {
- debug("init");
+ log("init");
m_paz.stat();
m_paz.bytarget();
}
function onBytarget(data) {
- debug("target");
+ log("target");
queue("targets").publish(data);
}
function onStat(data) {
- debug("stat");
+ log("stat");
queue("stat").publish(data);
}
function onTerm(data) {
- debug("term");
+ log("term");
queue("termlists").publish(data);
}
function onShow(data, teamName) {
- debug("show");
+ log("show");
m_totalRecordCount = data.merged;
queue("pager").publish(data);
queue("records").publish(data);
function onRecord(data, args, teamName) {
- debug("record");
+ log("record");
// FIXME: record is async!!
clearTimeout(m_paz.recordTimer);
- // in case on_show was faster to redraw element
- var detRecordDiv = document.getElementById('mkwsDet_' + teamName + '_' + data.recid);
- if (detRecordDiv) return;
+ // ##### restrict to current team
+ var detRecordDiv = document.getElementById(recordDetailsId(data.recid[0]));
+ if (detRecordDiv) {
+ // in case on_show was faster to redraw element
+ return;
+ }
m_currentRecordData = data;
- // Can't use jQuery's $('#x') syntax to find this ID, because it contains spaces.
- var recordDiv = document.getElementById('mkwsRecdiv_' + teamName + '_' + m_currentRecordData.recid);
+ var recordDiv = findnode('.' + recordElementId(m_currentRecordData.recid[0]));
var html = renderDetails(m_currentRecordData);
$(recordDiv).append(html);
}
+ // Used by promoteRecords() and onRecord()
+ function recordElementId(s) {
+ return 'mkwsRec_' + s.replace(/[^a-z0-9]/ig, '_');
+ }
+ that.recordElementId = recordElementId;
+
+ // Used by onRecord(), showDetails() and renderDetails()
+ function recordDetailsId(s) {
+ return 'mkwsDet_' + s.replace(/[^a-z0-9]/ig, '_');
+ }
+ that.recordElementId = recordElementId;
+
+
that.targetFiltered = function(id) {
for (var i = 0; i < m_filters.length; i++) {
if (m_filters[i].id === id ||
function newSearch(query, sortOrder, targets)
{
- debug("newSearch: " + query);
+ log("newSearch: " + query);
if (mkws_config.use_service_proxy && !mkws.authenticated) {
alert("searching before authentication");
}
m_filters = []
- redrawNavi();
- resetPage();
- loadSelect();
triggerSearch(query, sortOrder, targets);
switchView('records'); // In case it's configured to start off as hidden
m_submitted = true;
}
- function onSelectDdChange()
+ // limit by target functions
+ that.limitTarget = function (id, name)
{
- if (!m_submitted) return false;
- resetPage();
- loadSelect();
- m_paz.show(0, m_perpage, m_sortOrder);
+ log("limitTarget(id=" + id + ", name=" + name + ")");
+ m_filters.push({ id: id, name: name });
+ triggerSearch();
return false;
}
- function redrawNavi ()
+ // limit the query after clicking the facet
+ that.limitQuery = function (field, value)
{
- var navi = findnode('.mkwsNavi');
- if (!navi) return;
+ log("limitQuery(field=" + field + ", value=" + value + ")");
+ m_filters.push({ field: field, value: value });
+ triggerSearch();
+ return false;
+ }
+
- var text = "";
+ that.delimitTarget = function (id)
+ {
+ log("delimitTarget(id=" + id + ")");
+ var newFilters = [];
for (var i in m_filters) {
- if (text) {
- text += " | ";
- }
var filter = m_filters[i];
if (filter.id) {
- text += M('source') + ': <a class="crossout" href="#" onclick="mkws.delimitTarget(\'' + m_teamName +
- "', '" + filter.id + "'" + ');return false;">' + filter.name + '</a>';
+ log("delimitTarget() removing filter " + $.toJSON(filter));
} else {
- text += M(filter.field) + ': <a class="crossout" href="#" onclick="mkws.delimitQuery(\'' + m_teamName +
- "', '" + filter.field + "', '" + filter.value + "'" +
- ');return false;">' + filter.value + '</a>';
+ log("delimitTarget() keeping filter " + $.toJSON(filter));
+ newFilters.push(filter);
}
}
+ m_filters = newFilters;
- navi.html(text);
+ triggerSearch();
+ return false;
}
- function resetPage()
+ that.delimitQuery = function (field, value)
{
- m_currentPage = 1;
- m_totalRecordCount = 0;
+ log("delimitQuery(field=" + field + ", value=" + value + ")");
+ var newFilters = [];
+ for (var i in m_filters) {
+ var filter = m_filters[i];
+ if (filter.field &&
+ field == filter.field &&
+ value == filter.value) {
+ log("delimitQuery() removing filter " + $.toJSON(filter));
+ } else {
+ log("delimitQuery() keeping filter " + $.toJSON(filter));
+ newFilters.push(filter);
+ }
+ }
+ m_filters = newFilters;
+
+ triggerSearch();
+ return false;
}
- function loadSelect ()
+ function resetPage()
{
- var node = findnode('.mkwsSort');
- if (node.length && node.val() != m_sortOrder) {
- debug("changing m_sortOrder from " + m_sortOrder + " to " + node.val());
- m_sortOrder = node.val();
- }
- node = findnode('.mkwsPerpage');
- if (node.length && node.val() != m_perpage) {
- debug("changing m_perpage from " + m_perpage + " to " + node.val());
- m_perpage = node.val();
- }
+ m_currentPage = 1;
+ m_totalRecordCount = 0;
}
+ that.resetPage = resetPage;
function triggerSearch (query, sortOrder, targets)
{
+ resetPage();
+ queue("navi").publish();
+
var pp2filter = "";
var pp2limit = "";
if (pp2filter)
pp2filter += ",";
if (filter.id.match(/^[a-z:]+[=~]/)) {
- debug("filter '" + filter.id + "' already begins with SETTING OP");
+ log("filter '" + filter.id + "' already begins with SETTING OP");
} else {
filter.id = 'pz:id=' + filter.id;
}
params.limit = pp2limit;
}
- debug("triggerSearch(" + m_query + "): filters = " + $.toJSON(m_filters) + ", pp2filter = " + pp2filter + ", params = " + $.toJSON(params));
+ log("triggerSearch(" + m_query + "): filters = " + $.toJSON(m_filters) + ", pp2filter = " + pp2filter + ", params = " + $.toJSON(params));
// We can use: params.torusquery = "udb=NAME"
// Note: that won't work when running against raw pazpar2
}
- // limit by target functions
- that.limitTarget = function (id, name)
- {
- debug("limitTarget(id=" + id + ", name=" + name + ")");
- m_filters.push({ id: id, name: name });
- redrawNavi();
- resetPage();
- loadSelect();
- triggerSearch();
- return false;
- }
-
-
- // limit the query after clicking the facet
- that.limitQuery = function (field, value)
- {
- debug("limitQuery(field=" + field + ", value=" + value + ")");
- m_filters.push({ field: field, value: value });
- redrawNavi();
- resetPage();
- loadSelect();
- triggerSearch();
- return false;
- }
-
-
- that.delimitTarget = function (id)
- {
- debug("delimitTarget(id=" + id + ")");
- var newFilters = [];
- for (var i in m_filters) {
- var filter = m_filters[i];
- if (filter.id) {
- debug("delimitTarget() removing filter " + $.toJSON(filter));
- } else {
- debug("delimitTarget() keeping filter " + $.toJSON(filter));
- newFilters.push(filter);
- }
- }
- m_filters = newFilters;
-
- redrawNavi();
- resetPage();
- loadSelect();
- triggerSearch();
- return false;
+ that.reShow = function() {
+ m_paz.show(0, m_perpage, m_sortOrder);
}
- that.delimitQuery = function (field, value)
- {
- debug("delimitQuery(field=" + field + ", value=" + value + ")");
- var newFilters = [];
- for (var i in m_filters) {
- var filter = m_filters[i];
- if (filter.field &&
- field == filter.field &&
- value == filter.value) {
- debug("delimitQuery() removing filter " + $.toJSON(filter));
- } else {
- debug("delimitQuery() keeping filter " + $.toJSON(filter));
- newFilters.push(filter);
- }
- }
- m_filters = newFilters;
-
- redrawNavi();
- resetPage();
- loadSelect();
- triggerSearch();
- return false;
- }
-
that.showPage = function (pageNum)
{
alert("Unknown view '" + view + "'");
}
}
-
-
that.switchView = switchView;
// detailed record drawing
- that.showDetails = function (prefixRecId) {
- var recId = prefixRecId.replace('mkwsRec_', '');
+ that.showDetails = function (recId) {
var oldRecordId = m_currentRecordId;
m_currentRecordId = recId;
// remove current detailed view if any
- var detRecordDiv = document.getElementById('mkwsDet_' + m_teamName + '_' + oldRecordId);
+ // ##### restrict to current team
+ var detRecordDiv = document.getElementById(recordDetailsId(oldRecordId));
// lovin DOM!
if (detRecordDiv)
detRecordDiv.parentNode.removeChild(detRecordDiv);
return;
}
// request the record
- debug("showDetails() requesting record '" + recId + "'");
+ log("showDetails() requesting record '" + recId + "'");
m_paz.record(recId);
}
if (mkws_config.show_lang)
mkwsHtmlLang();
- debug("HTML search form");
+ log("HTML search form");
mkws.handleNodeWithTeam(findnode('.mkwsSearch'), function(tname) {
this.html('\
<form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_' + tname + '" action="" >\
</form>');
});
- debug("HTML records");
+ log("HTML records");
// If the team has a .mkwsResults, populate it in the usual
// way. If not, assume that it's a smarter application that
// defines its own subcomponents, some or all of the
// .mkwsPager
// .mkwsNavi
// .mkwsRecords
- if (findnode(".mkwsResults").length) {
- findnode(".mkwsResults").html('\
+ findnode(".mkwsResults").html('\
<table width="100%" border="0" cellpadding="6" cellspacing="0">\
<tr>\
<td class="mkwsTermlistContainer1 mkwsTeam_' + m_teamName + '" width="250" valign="top">\
</td>\
</tr>\
</table>');
- }
- var node = findnode(".mkwsRanking");
- if (node.length) {
- var ranking_data = '';
- ranking_data += '<form name="mkwsSelect" class="mkwsSelect mkwsTeam_' + m_teamName + '" action="" >';
- if (mkws_config.show_sort) {
- ranking_data += M('Sort by') + ' ' + mkwsHtmlSort() + ' ';
- }
- if (mkws_config.show_perpage) {
- ranking_data += M('and show') + ' ' + mkwsHtmlPerpage() + ' ' + M('per page') + '.';
- }
- ranking_data += '</form>';
-
- node.html(ranking_data);
+ var ranking_data = '<form name="mkwsSelect" class="mkwsSelect mkwsTeam_' + m_teamName + '" action="" >';
+ if (mkws_config.show_sort) {
+ ranking_data += M('Sort by') + ' ' + mkwsHtmlSort() + ' ';
}
+ if (mkws_config.show_perpage) {
+ ranking_data += M('and show') + ' ' + mkwsHtmlPerpage() + ' ' + M('per page') + '.';
+ }
+ ranking_data += '</form>';
+ findnode(".mkwsRanking").html(ranking_data);
mkwsHtmlSwitch();
- var node;
- node = findnode('.mkwsSearchForm');
- if (node.length)
- node.submit(onFormSubmitEventHandler);
- node = findnode('.mkwsSort');
- if (node.length)
- node.change(onSelectDdChange);
- node = findnode('.mkwsPerpage');
- if (node.length)
- node.change(onSelectDdChange);
+ findnode('.mkwsSearchForm').submit(onFormSubmitEventHandler);
// on first page, hide the termlist
$(document).ready(function() { findnode(".mkwsTermlists").hide(); });
- var motd = findnode(".mkwsMOTD");
var container = findnode(".mkwsMOTDContainer");
- if (motd.length && container.length) {
+ if (container.length) {
// Move the MOTD from the provided element down into the container
- motd.appendTo(container);
+ findnode(".mkwsMOTD").appendTo(container);
}
}
mkws_config.lang = lang;
}
- debug("Locale language: " + (mkws_config.lang ? mkws_config.lang : "none"));
+ log("Locale language: " + (mkws_config.lang ? mkws_config.lang : "none"));
return mkws_config.lang;
}
if (lang_options.length == 0 || toBeIncluded[lang_default])
list.push(lang_default);
- debug("Language menu for: " + list.join(", "));
+ log("Language menu for: " + list.join(", "));
/* the HTML part */
var data = "";
function mkwsHtmlSort() {
- debug("HTML sort, m_sortOrder = '" + m_sortOrder + "'");
+ log("HTML sort, m_sortOrder = '" + m_sortOrder + "'");
var sort_html = '<select class="mkwsSort mkwsTeam_' + m_teamName + '">';
for(var i = 0; i < mkws_config.sort_options.length; i++) {
function mkwsHtmlPerpage() {
- debug("HTML perpage, m_perpage = " + m_perpage);
+ log("HTML perpage, m_perpage = " + m_perpage);
var perpage_html = '<select class="mkwsPerpage mkwsTeam_' + m_teamName + '">';
for(var i = 0; i < mkws_config.perpage_options.length; i++) {
function mkwsHtmlSwitch() {
- debug("HTML switch for team " + m_teamName);
+ log("HTML switch for team " + m_teamName);
var node = findnode(".mkwsSwitch");
node.append($('<a href="#" onclick="mkws.switchView(\'' + m_teamName + '\', \'records\')">' + M('Records') + '</a>'));
node.append($("<span/>", { text: " | " }));
node.append($('<a href="#" onclick="mkws.switchView(\'' + m_teamName + '\', \'targets\')">' + M('Targets') + '</a>'));
- debug("HTML targets");
+ log("HTML targets");
var node = findnode(".mkwsTargets");
node.html('\
<div class="mkwsBytarget mkwsTeam_' + m_teamName + '">\
if (query.match(/^!param!/)) {
var param = query.replace(/^!param!/, '');
query = mkws.getParameterByName(param);
- debug("obtained query '" + query + "' from param '" + param + "'");
+ log("obtained query '" + query + "' from param '" + param + "'");
if (!query) {
alert("This page has a MasterKey widget that needs a query specified by the '" + param + "' parameter");
}
var index = query.replace(/^!path!/, '');
var path = window.location.pathname.split('/');
query = path[path.length - index];
- debug("obtained query '" + query + "' from path-component '" + index + "'");
+ log("obtained query '" + query + "' from path-component '" + index + "'");
if (!query) {
alert("This page has a MasterKey widget that needs a query specified by the path-component " + index);
}
}
- debug("node=" + node + ", class='" + node.className + "', query=" + query);
+ log("node=" + node + ", class='" + node.className + "', query=" + query);
var sortOrder = node.attr('sort');
var targets = node.attr('targets');
var s = "running auto search: '" + query + "'";
if (sortOrder) s += " sorted by '" + sortOrder + "'";
if (targets) s += " in targets '" + targets + "'";
- debug(s);
+ log(s);
newSearch(query, sortOrder, targets);
}
{
var template = loadTemplate("Record");
var details = template(data);
- return '<div class="details" id="mkwsDet_' + m_teamName + '_' + data.recid + '">' + details + '</div>';
+ return '<div class="details mkwsTeam_' + m_teamName + '" id="' + recordDetailsId(data.recid[0]) + '">' + details + '</div>';
}
+ that.renderDetails = renderDetails;
function loadTemplate(name)
}
template = Handlebars.compile(source);
- debug("compiled template '" + name + "'");
+ log("compiled template '" + name + "'");
m_template[name] = template;
}
}
return queues[id];
}
-
that.queue = queue;
// wrapper to call team() after page load
(function (j) {
- mkws.debug = function (string) {
- if (!mkws.debug_level)
+ mkws.log = function (string) {
+ if (!mkws.log_level)
return;
if (typeof console === "undefined" || typeof console.log === "undefined") { /* ARGH!!! old IE */
}
// you need to disable use strict at the top of the file!!!
- if (mkws.debug_level >= 3) {
+ if (mkws.log_level >= 3) {
console.log(arguments.callee.caller);
- } else if (mkws.debug_level >= 2) {
+ } else if (mkws.log_level >= 2) {
console.log(">>> called from function " + arguments.callee.caller.name + ' <<<');
}
console.log(string);
}
- var debug = mkws.debug;
+ var log = mkws.log;
mkws.handleNodeWithTeam = function(node, callback) {
// undefined, we don't get an error message, but this
// function and its callers, up several stack level,
// silently return. What a crock.
- mkws.debug("handleNodeWithTeam() called on node with no classes");
+ mkws.log("handleNodeWithTeam() called on node with no classes");
return;
}
var list = classes.split(/\s+/)
if ($(window).width() <= width &&
parent.hasClass("mkwsTermlistContainer1")) {
- debug("changing from wide to narrow: " + $(window).width());
+ log("changing from wide to narrow: " + $(window).width());
$(".mkwsTermlistContainer1").hide();
$(".mkwsTermlistContainer2").show();
for (var tname in mkws.teams) {
}
} else if ($(window).width() > width &&
parent.hasClass("mkwsTermlistContainer2")) {
- debug("changing from narrow to wide: " + $(window).width());
+ log("changing from narrow to wide: " + $(window).width());
$(".mkwsTermlistContainer1").show();
$(".mkwsTermlistContainer2").hide();
for (var tname in mkws.teams) {
lang_options: [], /* display languages links for given languages, [] for all */
facets: ["xtargets", "subject", "author"], /* display facets, in this order, [] for none */
responsive_design_width: undefined, /* a page with less pixel width considered as narrow */
- debug_level: 1, /* debug level for development: 0..2 */
+ log_level: 1, /* log level for development: 0..2 */
dummy: "dummy"
};
- /* Set global debug_level flag early so that debug() works */
- if (typeof mkws_config.debug_level !== 'undefined') {
- mkws.debug_level = mkws_config.debug_level;
- } else if (typeof config_default.debug_level !== 'undefined') {
- mkws.debug_level = config_default.debug_level;
+ /* Set global log_level flag early so that log() works */
+ if (typeof mkws_config.log_level !== 'undefined') {
+ mkws.log_level = mkws_config.log_level;
+ } else if (typeof config_default.log_level !== 'undefined') {
+ mkws.log_level = config_default.log_level;
}
// make sure the mkws_config is a valid hash
if (!$.isPlainObject(mkws_config)) {
- debug("ERROR: mkws_config is not an JS object, ignore it....");
+ log("ERROR: mkws_config is not an JS object, ignore it....");
mkws_config = {};
}
for (var k in config_default) {
if (typeof mkws_config[k] === 'undefined')
mkws_config[k] = config_default[k];
- //debug("Set config: " + k + ' => ' + mkws_config[k]);
+ //log("Set config: " + k + ' => ' + mkws_config[k]);
}
}
* for the site.
*/
function authenticateSession(auth_url, auth_domain, pp2_url) {
- debug("Run service proxy auth URL: " + auth_url);
+ log("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 + "'");
+ log("guessed auth_domain '" + auth_domain + "' from pp2_url '" + pp2_url + "'");
}
var request = new pzHttpRequest(auth_url, function(err) {
return;
}
- debug("Service proxy auth successfully done");
+ log("Service proxy auth successfully done");
mkws.authenticated = true;
runAutoSearches();
});
function runAutoSearches() {
- debug("running auto searches");
+ log("running auto searches");
for (var teamName in mkws.teams) {
mkws.teams[teamName].runAutoSearch();
$(document).ready(function() {
- debug("on load ready");
+ log("on load ready");
defaultMkwsConfig();
if (mkws_config.query_width < 5 || mkws_config.query_width > 150) {
- debug("Reset query width: " + mkws_config.query_width);
+ log("Reset query width: " + mkws_config.query_width);
mkws_config.query_width = 50;
}
var lang = key.replace(/^language_/, "");
// Copy custom languages into list
mkws.locale_lang[lang] = mkws_config[key];
- debug("Added locally configured language '" + lang + "'");
+ log("Added locally configured language '" + lang + "'");
}
}
}
// 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 independent links: " + mkws_config.pazpar2_url);
+ log("adjust protocol independent links: " + mkws_config.pazpar2_url);
}
// Backwards compatibility: set new magic class names on any
var node = $('#' + id);
if (node.attr('id')) {
node.addClass(id);
- debug("added magic class to '" + node.attr('id') + "'");
+ log("added magic class to '" + node.attr('id') + "'");
}
}
// specified, set the team to AUTO.
$('[class^="mkws"],[class*=" mkws"]').each(function () {
if (!this.className.match(/mkwsTeam_/)) {
- debug("adding AUTO team to node with class '" + this.className + "'");
+ log("adding AUTO team to node with class '" + this.className + "'");
$(this).addClass('mkwsTeam_AUTO');
}
});
mkws.handleNodeWithTeam(this, function(tname, type) {
if (!mkws.teams[tname]) {
mkws.teams[tname] = team(j, tname);
- debug("Made MKWS team '" + tname + "'");
+ log("Made MKWS team '" + tname + "'");
}
});
});
// Second pass: make the individual widget objects. This has
// to be done separately, and after the team-creation, since
// that sometimes makes new widget nodes (e.g. creating
- // mkwsTermlists instead mkwsResults.
+ // mkwsTermlists inside mkwsResults.
$('[class^="mkws"],[class*=" mkws"]').each(function () {
mkws.handleNodeWithTeam(this, function(tname, type) {
var myTeam = mkws.teams[tname];
});
});
var now = $.now();
- debug("Walking MKWS nodes took " + (now-then) + " ms");
+ log("Walking MKWS nodes took " + (now-then) + " ms");
if (mkws_config.use_service_proxy) {
authenticateSession(mkws_config.service_proxy_auth,