From dfbe3e8b84639dee6e88b6cb89e17a110355b732 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 28 Mar 2014 16:28:35 +0000 Subject: [PATCH] Each team now has its own config object, m_config, which inherits from the global mkws.config (which of course in turn inherits from the default set of parameters). All configuration information is now taken from the per-team config. --- src/mkws-team.js | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/mkws-team.js b/src/mkws-team.js index 4202cb7..7c1f4ec 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -27,6 +27,7 @@ function team($, teamName) { }; var m_paz; // will be initialised below var m_template = {}; + var m_config = Object.create(mkws.config); that.toString = function() { return '[Team ' + teamName + ']'; }; @@ -56,24 +57,24 @@ function team($, teamName) { log("start running MKWS"); - m_sortOrder = mkws.config.sort_default; - m_perpage = mkws.config.perpage_default; + m_sortOrder = m_config.sort_default; + m_perpage = m_config.perpage_default; 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 m_paz = new pz2({ "windowid": teamName, - "pazpar2path": mkws.config.pazpar2_url, - "usesessions" : mkws.config.use_service_proxy ? false : true, + "pazpar2path": m_config.pazpar2_url, + "usesessions" : m_config.use_service_proxy ? false : true, "oninit": onInit, "onbytarget": onBytarget, "onstat": onStat, - "onterm": (mkws.config.facets.length ? onTerm : undefined), + "onterm": (m_config.facets.length ? onTerm : undefined), "onshow": onShow, "onrecord": onRecord, "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way - "termlist": mkws.config.facets.join(',') + "termlist": m_config.facets.join(',') }); @@ -234,7 +235,7 @@ function team($, teamName) { { log("newSearch: " + query); - if (mkws.config.use_service_proxy && !mkws.authenticated) { + if (m_config.use_service_proxy && !mkws.authenticated) { alert("searching before authentication"); return; } @@ -361,13 +362,13 @@ function team($, teamName) { */ function mkwsHtmlAll() { mkwsSetLang(); - if (mkws.config.show_lang) + if (m_config.show_lang) mkwsHtmlLang(); log("HTML search form"); findnode('.mkwsSearch').html('\
\ - \ + \ \
'); @@ -402,10 +403,10 @@ function team($, teamName) { '); var ranking_data = '
'; - if (mkws.config.show_sort) { + if (m_config.show_sort) { ranking_data += M('Sort by') + ' ' + mkwsHtmlSort() + ' '; } - if (mkws.config.show_perpage) { + if (m_config.show_perpage) { ranking_data += M('and show') + ' ' + mkwsHtmlPerpage() + ' ' + M('per page') + '.'; } ranking_data += '
'; @@ -430,26 +431,26 @@ function team($, teamName) { function mkwsSetLang() { - var lang = getParameterByName("lang") || mkws.config.lang; + var lang = getParameterByName("lang") || m_config.lang; if (!lang || !mkws.locale_lang[lang]) { - mkws.config.lang = "" + m_config.lang = "" } else { - mkws.config.lang = lang; + m_config.lang = lang; } - log("Locale language: " + (mkws.config.lang ? mkws.config.lang : "none")); - return mkws.config.lang; + log("Locale language: " + (m_config.lang ? m_config.lang : "none")); + return m_config.lang; } /* create locale language menu */ function mkwsHtmlLang() { var lang_default = "en"; - var lang = mkws.config.lang || lang_default; + var lang = m_config.lang || lang_default; var list = []; /* display a list of configured languages, or all */ - var lang_options = mkws.config.lang_options || []; + var lang_options = m_config.lang_options || []; var toBeIncluded = {}; for (var i = 0; i < lang_options.length; i++) { toBeIncluded[lang_options[i]] = true; @@ -489,8 +490,8 @@ function team($, teamName) { log("HTML sort, m_sortOrder = '" + m_sortOrder + "'"); var sort_html = ''; - for(var i = 0; i < mkws.config.perpage_options.length; i++) { - var key = mkws.config.perpage_options[i]; + for(var i = 0; i < m_config.perpage_options.length; i++) { + var key = m_config.perpage_options[i]; perpage_html += '