From: Mike Taylor Date: Mon, 27 Jan 2014 17:26:44 +0000 (+0000) Subject: Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws X-Git-Tag: 1.0.0~1580 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=79bf85e49546bd18791ba411b546852dead000e3;hp=154f186dd79df8e619fd079ec72d10e75bebb310;p=mkws-moved-to-github.git Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws --- diff --git a/examples/htdocs/mike.html b/examples/htdocs/mike.html index e503be0..e704dd5 100644 --- a/examples/htdocs/mike.html +++ b/examples/htdocs/mike.html @@ -19,11 +19,13 @@ -
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/examples/htdocs/mike2.html b/examples/htdocs/mike2.html deleted file mode 100644 index 0154b91..0000000 --- a/examples/htdocs/mike2.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - MKWS demo: Mike's playground - - - - - - - - -
-
-
-
-
-
- - diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 0a62b9b..6245215 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -863,11 +863,16 @@ function _make_mkws_team($, teamName) { // For some reason, doing this programmatically results in // document.mkwsSearchForm.mkwsQuery being undefined, hence the raw HTML. debug("HTML search form"); - $("#mkwsSearch").html('\ -
\ - \ - \ + $('.mkwsSearch').each(function (i, obj) { + var node = this; + mkws.handle_node_with_team(node, function(tname) { + $(node).html('\ +\ + \ + \
'); + }); + }); debug("HTML records"); // If the application has an #mkwsResults, populate it in the @@ -1294,36 +1299,19 @@ function _mkws_jquery_plugin ($) { } } - // Backwards compatibility: the special-case undefined team - // ### Will not be necessary when non-default teams are working - mkws.teams['AUTO'] = _make_mkws_team(j, "AUTO"); - log("Made the unnamed MKWS team"); - // Find all nodes with class (NOT id) mkwsRecords, and // determine their team from the mkwsTeam_* class. So: //
$('.mkwsResults, .mkwsRecords, .mkwsTermlists').each(function () { var node = this; - var classes = this.className; - var list = classes.split(/\s+/) - var tname; - for (var i = 0; i < list.length; i++) { - var cname = list[i]; - if (cname.match(/^mkwsTeam_/)) { - tname = cname.replace(/^mkwsTeam_/, ''); + mkws.handle_node_with_team(node, function(tname) { + if (mkws.teams[tname]) { + log("MKWS team '" + tname + "' already exists, skipping"); + } else { + mkws.teams[tname] = _make_mkws_team(j, tname); + log("Made MKWS team '" + tname + "'"); } - } - if (!tname) { - alert("No MKWS team specified for mkwsRecords element with classes '" + classes + "'"); - } else if (mkws.teams[tname]) { - log("MKWS team '" + tname + "' already exists, skipping"); - } else if (tname === "AUTO") { - // ### For now: later, this will be how the backwards-compatibility is done - log("Skipping MKWS team '" + tname + "'"); - } else { - mkws.teams[tname] = _make_mkws_team(j, tname); - log("Made MKWS team '" + tname + "'"); - } + }); }); if (mkws_config.use_service_proxy) { @@ -1337,6 +1325,22 @@ function _mkws_jquery_plugin ($) { }); + mkws.handle_node_with_team = function(node, callback) { + var classes = node.className; + var list = classes.split(/\s+/) + var tname; + for (var i = 0; i < list.length; i++) { + var cname = list[i]; + if (cname.match(/^mkwsTeam_/)) { + tname = cname.replace(/^mkwsTeam_/, ''); + } + } + if (!tname) + tname = "AUTO"; + callback(tname); + } + + function default_mkws_config() { /* default mkws config */ var config_default = {