\
@@ -994,7 +1008,7 @@ function team($, 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");
}
@@ -1002,20 +1016,20 @@ function team($, teamName) {
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);
}
@@ -1056,7 +1070,7 @@ function team($, teamName) {
{
var template = loadTemplate("Record");
var details = template(data);
- return '
' + details + '
';
+ return '
' + details + '
';
}
that.renderDetails = renderDetails;
@@ -1078,7 +1092,7 @@ function team($, teamName) {
}
template = Handlebars.compile(source);
- debug("compiled template '" + name + "'");
+ log("compiled template '" + name + "'");
m_template[name] = template;
}
@@ -1129,8 +1143,8 @@ function team($, teamName) {
// 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 */
@@ -1138,14 +1152,14 @@ function team($, teamName) {
}
// 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) {
@@ -1156,7 +1170,7 @@ function team($, teamName) {
// 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+/)
@@ -1182,7 +1196,7 @@ function team($, teamName) {
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) {
@@ -1193,7 +1207,7 @@ function team($, teamName) {
}
} 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) {
@@ -1352,21 +1366,25 @@ function team($, teamName) {
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
+ // Fall back to old "debug_level" setting for backwards compatibility
+ var tmp = mkws_config.log_level;
+ if (typeof(tmp) === 'undefined') tmp = mkws_config.debug_level;
+
+ if (typeof(tmp) !== 'undefined') {
+ mkws.log_level = tmp;
+ } 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 = {};
}
@@ -1374,7 +1392,7 @@ function team($, teamName) {
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]);
}
}
@@ -1385,11 +1403,11 @@ function team($, teamName) {
* 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) {
@@ -1408,7 +1426,7 @@ function team($, teamName) {
return;
}
- debug("Service proxy auth successfully done");
+ log("Service proxy auth successfully done");
mkws.authenticated = true;
runAutoSearches();
});
@@ -1416,7 +1434,7 @@ function team($, teamName) {
function runAutoSearches() {
- debug("running auto searches");
+ log("running auto searches");
for (var teamName in mkws.teams) {
mkws.teams[teamName].runAutoSearch();
@@ -1425,11 +1443,11 @@ function team($, teamName) {
$(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;
}
@@ -1439,7 +1457,7 @@ function team($, teamName) {
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 + "'");
}
}
}
@@ -1455,7 +1473,7 @@ function team($, teamName) {
// 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
@@ -1468,7 +1486,7 @@ function team($, teamName) {
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') + "'");
}
}
@@ -1476,7 +1494,7 @@ function team($, teamName) {
// 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');
}
});
@@ -1488,7 +1506,7 @@ function team($, teamName) {
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 + "'");
}
});
});
@@ -1503,7 +1521,7 @@ function team($, teamName) {
});
});
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,