X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=396a2a9e634997a7405e9309838f5f3533de7530;hb=d291399f4d3978b6fe23ac561ac1213816abea85;hp=177aa98aac24c3fb6051261b8d777dcfa22e03d3;hpb=912f0c2e3809d91dbbc3872c93367ef178e96965;p=mkws-moved-to-github.git diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 177aa98..396a2a9 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -72,7 +72,7 @@ Handlebars.registerHelper('index1', function(obj) { // Set up global mkws object. Contains truly global state such as SP -// authentication, and a hash of team objects, indexed by windowid. +// authentication, and a hash of team objects, indexed by team-name. // var mkws = { authenticated: false, @@ -228,24 +228,6 @@ function team($, teamName) { 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; @@ -466,21 +448,15 @@ function team($, teamName) { // 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) { debug("newSearch: " + query); @@ -493,8 +469,8 @@ function team($, teamName) { redraw_navi(); resetPage(); loadSelect(); - triggerSearch(query, sort, targets, windowid); - that.switchView('records'); // In case it's configured to start off as hidden + triggerSearch(query, sort, targets); + switchView('records'); // In case it's configured to start off as hidden m_submitted = true; } @@ -516,8 +492,7 @@ function team($, teamName) { } - // ### doesn't need windowid - function triggerSearch (query, sort, targets, windowid) + function triggerSearch (query, sort, targets) { var pp2filter = ""; var pp2limit = ""; @@ -556,9 +531,7 @@ function team($, teamName) { if (pp2limit) { params.limit = pp2limit; } - if (windowid) { - params.windowid = windowid; - } + debug("triggerSearch(" + m_query + "): filters = " + $.toJSON(m_filters) + ", pp2filter = " + pp2filter + ", params = " + $.toJSON(params)); // We can use: params.torusquery = "udb=NAME" @@ -758,7 +731,7 @@ function team($, teamName) { // switching view between targets and records - that.switchView = function(view) { + function switchView(view) { var targets = findnode('.mkwsTargets'); var results = findnode('.mkwsResults,.mkwsRecords'); var blanket = findnode('.mkwsBlanket'); @@ -790,6 +763,9 @@ function team($, teamName) { } + that.switchView = switchView; + + // detailed record drawing that.showDetails = function (prefixRecId) { var recId = prefixRecId.replace('mkwsRec_', ''); @@ -957,8 +933,8 @@ function team($, teamName) { // .mkwsPager // .mkwsNavi // .mkwsRecords - if ($(".mkwsResults.mkwsTeam_" + m_teamName).length) { - $(".mkwsResults.mkwsTeam_" + m_teamName).html('\ + if (findnode(".mkwsResults").length) { + findnode(".mkwsResults").html('\ \ \
\ @@ -1187,7 +1163,7 @@ function team($, teamName) { if (targets) s += " in targets '" + targets + "'"; debug(s); - this.newSearch(query, sort, targets, m_teamName); + newSearch(query, sort, targets); } @@ -1442,6 +1418,22 @@ function team($, 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",