From: Mike Taylor Date: Fri, 24 Jan 2014 13:02:27 +0000 (+0000) Subject: Move mkws_config defaulting code out of team object, into a new global X-Git-Tag: 1.0.0~1612 X-Git-Url: http://jsfdemo.indexdata.com/?a=commitdiff_plain;h=e14aea2ca68c5b8975d53bab9877dac6370796f7;p=mkws-moved-to-github.git Move mkws_config defaulting code out of team object, into a new global function default_mkws_config(). --- diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index bed0258..597e55b 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -190,53 +190,6 @@ function _make_mkws_team($, teamName) { var debug = mkws.debug_function; // local alias debug("start running MKWS"); - - { - - /* default mkws config */ - var config_default = { - use_service_proxy: true, - pazpar2_url: "http://mkws.indexdata.com/service-proxy/", - service_proxy_auth: "http://mkws.indexdata.com/service-proxy-auth", - lang: "", - sort_options: [["relevance"], ["title:1", "title"], ["date:0", "newest"], ["date:1", "oldest"]], - perpage_options: [10, 20, 30, 50], - sort_default: "relevance", - perpage_default: 20, - query_width: 50, - show_lang: true, /* show/hide language menu */ - show_sort: true, /* show/hide sort menu */ - show_perpage: true, /* show/hide perpage menu */ - lang_options: [], /* display languages links for given languages, [] for all */ - facets: ["sources", "subjects", "authors"], /* 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 */ - - 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; - } - - // make sure the mkws_config is a valid hash - if (!$.isPlainObject(mkws_config)) { - debug("ERROR: mkws_config is not an JS object, ignore it...."); - mkws_config = {}; - } - - /* override standard config values by function parameters */ - 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]); - } - } - - m_sort = mkws_config.sort_default; debug("copied mkws_config.sort_default '" + mkws_config.sort_default + "' to m_sort"); @@ -1337,6 +1290,7 @@ function _mkws_jquery_plugin ($) { $(document).ready(function() { log("on load ready"); + default_mkws_config(); // Backwards compatibility: set new magic class names on any // elements that have the old magic IDs. @@ -1395,6 +1349,51 @@ function _mkws_jquery_plugin ($) { }); + function default_mkws_config() { + /* default mkws config */ + var config_default = { + use_service_proxy: true, + pazpar2_url: "http://mkws.indexdata.com/service-proxy/", + service_proxy_auth: "http://mkws.indexdata.com/service-proxy-auth", + lang: "", + sort_options: [["relevance"], ["title:1", "title"], ["date:0", "newest"], ["date:1", "oldest"]], + perpage_options: [10, 20, 30, 50], + sort_default: "relevance", + perpage_default: 20, + query_width: 50, + show_lang: true, /* show/hide language menu */ + show_sort: true, /* show/hide sort menu */ + show_perpage: true, /* show/hide perpage menu */ + lang_options: [], /* display languages links for given languages, [] for all */ + facets: ["sources", "subjects", "authors"], /* 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 */ + + 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; + } + + // make sure the mkws_config is a valid hash + if (!$.isPlainObject(mkws_config)) { + debug("ERROR: mkws_config is not an JS object, ignore it...."); + mkws_config = {}; + } + + /* override standard config values by function parameters */ + 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]); + } + } + + /* * Run service-proxy authentication in background (after page load). * The username/password is configured in the apache config file