Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws
authorMike Taylor <mike@indexdata.com>
Mon, 27 Jan 2014 17:26:44 +0000 (17:26 +0000)
committerMike Taylor <mike@indexdata.com>
Mon, 27 Jan 2014 17:26:44 +0000 (17:26 +0000)
examples/htdocs/mike.html
examples/htdocs/mike2.html [deleted file]
tools/htdocs/mkws.js

index e503be0..e704dd5 100644 (file)
     <script type="text/javascript" src="http://x.mkws.indexdata.com/mkws.js"></script>
   </head>
   <body>
-    <div id="mkwsSwitch"></div>
-    <div id="mkwsLang"></div>
-    <div id="mkwsSearch"></div>
-    <div id="mkwsResults"></div>
-    <div id="mkwsTargets"></div>
-    <div id="mkwsStat"></div>
+    <div class="mkwsSwitch"></div>
+    <div class="mkwsLang"></div>
+    <div class="mkwsSearch"></div>
+    <div class="mkwsSearch mkwsTeam_2"></div>
+    <div class="mkwsSearch mkwsTeam_foo"></div>
+    <div class="mkwsResults"></div>
+    <div class="mkwsTargets"></div>
+    <div class="mkwsStat"></div>
   </body>
 </html>
diff --git a/examples/htdocs/mike2.html b/examples/htdocs/mike2.html
deleted file mode 100644 (file)
index 0154b91..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    <title>MKWS demo: Mike's playground</title>
-    <link rel="stylesheet" type="text/css" href="http://x.mkws.indexdata.com/mkws.css" />
-    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
-    <script type="text/javascript" src="http://x.mkws.indexdata.com/jquery.json-2.4.js"></script>
-    <script type="text/javascript" src="http://x.mkws.indexdata.com/handlebars-v1.1.2.js"></script>
-    <script type="text/javascript" src="http://x.mkws.indexdata.com/pazpar2/js/pz2.js"></script>
-    <script type="text/javascript" src="http://x.mkws.indexdata.com/mkws.js"></script>
-  </head>
-  <body>
-    <div id="mkwsSwitch"></div>
-    <div id="mkwsLang"></div>
-    <div id="mkwsSearch"></div>
-    <div id="mkwsResults"></div>
-    <div id="mkwsTargets"></div>
-    <div id="mkwsStat"></div>
-  </body>
-</html>
index 0a62b9b..6245215 100644 (file)
@@ -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('\
-<form name="mkwsSearchForm" action="" >\
-  <input id="mkwsQuery" class="mkwsQuery mkwsTeam_AUTO" type="text" size="' + mkws_config.query_width + '" />\
-  <input id="mkwsButton" class="mkwsButton mkwsTeam_AUTO" type="submit" value="' + M('Search') + '" />\
+       $('.mkwsSearch').each(function (i, obj) {
+           var node = this;
+           mkws.handle_node_with_team(node, function(tname) {
+               $(node).html('\
+<form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_' + tname + '" action="" >\
+  <input id="mkwsQuery" class="mkwsQuery mkwsTeam_' + tname + '" type="text" size="' + mkws_config.query_width + '" />\
+  <input id="mkwsButton" class="mkwsButton mkwsTeam_' + tname + '" type="submit" value="' + M('Search') + '" />\
 </form>');
+           });
+       });
 
        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:
        //      <div class="mkwsRecords mkwsTeam_foo"/>
        $('.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 = {