<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>
+++ /dev/null
-<?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>
// 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
}
}
- // 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) {
});
+ 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 = {