m_sort = mkws_config.sort_default;
debug("copied mkws_config.sort_default '" + mkws_config.sort_default + "' to m_sort");
- // ### should be in global code
- if (mkws_config.query_width < 5 || mkws_config.query_width > 150) {
- debug("Reset query width: " + mkws_config.query_width);
- mkws_config.query_width = 50;
- }
-
- // ### should be in global code
- for (var key in mkws_config) {
- if (mkws_config.hasOwnProperty(key)) {
- if (key.match(/^language_/)) {
- var lang = key.replace(/^language_/, "");
- // Copy custom languages into list
- mkws.locale_lang[lang] = mkws_config[key];
- debug("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;
// Finds the node of the specified class within the current team
+ // Multiple OR-clauses separated by commas are handled
+ // More complex cases may not work
+ //
function findnode(selector, teamName) {
- teamName ||= m_teamName;
- return $(selector + '.mkwsTeam_' + m_teamName);
+ teamName = teamName || m_teamName;
+
+ selector = selector.split(',').map(function(s) {
+ return s + '.mkwsTeam_' + teamName;
+ }).join(',');
+
+ return $(selector);
}
// when search button pressed
- // ### This is closure, so can always just operate on its own team
function onFormSubmitEventHandler()
{
- mkws.handle_node_with_team(this, function (tname) {
- var val = findnode('.mkwsQuery').val();
- mkws.teams[tname].newSearch(val);
- });
-
+ var val = findnode('.mkwsQuery').val();
+ newSearch(val);
return false;
}
// ### won't need to be externally visible once onFormSubmitEventHandler() is fixed.
// ### doesn't need windowid
- that.newSearch = function(query, sort, targets, windowid)
+ function newSearch(query, sort, targets, windowid)
{
debug("newSearch: " + query);
resetPage();
loadSelect();
triggerSearch(query, sort, targets, windowid);
- that.switchView('records'); // In case it's configured to start off as hidden
+ switchView('records'); // In case it's configured to start off as hidden
m_submitted = true;
}
// switching view between targets and records
- that.switchView = function(view) {
+ function switchView(view) {
var targets = findnode('.mkwsTargets');
- // ### Fix next line to use findnode()
- var results = $('.mkwsResults.mkwsTeam_' + m_teamName + ',.mkwsRecords.mkwsTeam_' + m_teamName);
+ var results = findnode('.mkwsResults,.mkwsRecords');
var blanket = findnode('.mkwsBlanket');
var motd = findnode('.mkwsMOTD');
}
+ that.switchView = switchView;
+
+
// detailed record drawing
that.showDetails = function (prefixRecId) {
var recId = prefixRecId.replace('mkwsRec_', '');
// Fall back to generic template if there is no team-specific one
var node = findnode(".mkwsTemplate_" + name);
if (!node.length) {
- node = $(".mkwsTemplate_" + name + ".mkwsTeam_ALL");
+ node = findnode(".mkwsTemplate_" + name, "ALL");
}
var source = node.html();
// .mkwsPager
// .mkwsNavi
// .mkwsRecords
- if ($(".mkwsResults.mkwsTeam_" + m_teamName).length) {
- $(".mkwsResults.mkwsTeam_" + m_teamName).html('\
+ if (findnode(".mkwsResults").length) {
+ findnode(".mkwsResults").html('\
<table width="100%" border="0" cellpadding="6" cellspacing="0">\
<tr>\
<td class="mkwsTermlistContainer1 mkwsTeam_' + m_teamName + '" width="250" valign="top">\
if (targets) s += " in targets '" + targets + "'";
debug(s);
- this.newSearch(query, sort, targets, m_teamName);
+ newSearch(query, sort, targets, m_teamName);
}
debug("on load ready");
default_mkws_config();
+ if (mkws_config.query_width < 5 || mkws_config.query_width > 150) {
+ debug("Reset query width: " + mkws_config.query_width);
+ mkws_config.query_width = 50;
+ }
+
+ for (var key in mkws_config) {
+ if (mkws_config.hasOwnProperty(key)) {
+ if (key.match(/^language_/)) {
+ var lang = key.replace(/^language_/, "");
+ // Copy custom languages into list
+ mkws.locale_lang[lang] = mkws_config[key];
+ debug("Added locally configured language '" + lang + "'");
+ }
+ }
+ }
+
// Backwards compatibility: set new magic class names on any
// elements that have the old magic IDs.
var ids = [ "Switch", "Lang", "Search", "Pager", "Navi",