--- /dev/null
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>MKWS demo: popup search box</title>
+
+ <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
+ <link rel="stylesheet" href="http://mkws.indexdata.com/mkwsStyle.css" />
+
+ <script type="text/javascript">
+ mkws_config = {
+ service_proxy_url : "/service-proxy/",
+ service_proxy_auth : "/service-proxy-auth/",
+ switch_menu: false,
+ lang_menu: false,
+ perpage_default: 10,
+ query_width: 50
+ };
+ </script>
+
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
+ <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
+
+ <script type="text/javascript" src="libjs-pz2/pz2api.1.js"></script>
+ <script type="text/javascript" src="mkws.js"></script>
+
+ </head>
+ <body>
+ <script type="text/javascript">
+ jQuery.pazpar2({ "layout":"popup", width: 800, height: 500 } );
+ </script>
+
+ <pre>
+ An embryonic MasterKey Widget Set
+=================================
+
+This directory contains an embryonic MasterKey Widget Set, based
+initially on "jsdemo" though now far removed from those beginnnings.
+
+
+How this works
+--------------
+
+The goal is to make it that as much of the searching functionality as
+possible is hosted on
+ http://mkws.indexdata.com/
+so that very simple websites such as
+ http://example.indexdata.com/
+can have MasterKey searching with minimal effort.
+
+The following files must be hosted on mkws.indexdata.com:
+ mkws.js
+ mkwsStyle.css
+ /libjs-pz2/pz2api.1.js (*)
+
+The following files make up the application:
+ index.html
+ favicon.ico [optional]
+ robots.txt [optional]
+
+(At present, the client application's configuruation also needs an
+Alias for /service-proxy/, to avoid cross-site scripting issues. We
+will fix this.)
+
+(*) if you don't have already installed libjs-pz2 on the machine, you can
+do it by installing a debian package or check it out from GIT:
+$ git clone ssh://git.indexdata.com:222/home/git/pub/libjs-pz2
+
+Configuring a client
+--------------------
+
+The application's HTML must contains the following elements as well as
+whatever makes up the application itself:
+
+[...]
+ </pre>
+ </body>
+</html>
Note: the mkws_config object which must be loaded before the mkws.js and pz2api.js files.
+
+jQuery plugin
+------------------
+
+The jQuery plugin version, consisting of a single line of JavaScript code
+
+ <script>jQuery.pazpar2();</script>
+
+put the code in your page at the position where the metasearch should occours.
+
+Here is an example of all possible options
+
+ jQuery.pazpar2({"layout": "popup", /* "table", "div", "popup", default is table */
+ "id_button": "input#mkwsButton", /* submit button id in search field */
+ "id_popup": "#mkwsPopup", /* interal id of popup window */
+ "width": 880, /* popup width, should be at least 800 */
+ "height": 760 /* popup height, should be at least 600 */
+ });
+
+
Supported Browsers
------------------
return mkws_locale_lang[lang][word] ? mkws_locale_lang[lang][word] : word;
}
-/* implement jQuery.parseQuerystring() for parsing URL parameters */
+/*
+ * implement jQuery plugins
+ */
jQuery.extend({
- parseQuerystring: function() {
- var nvpair = {};
- var qs = window.location.search.replace('?', '');
- var pairs = qs.split('&');
- $.each(pairs, function(i, v){
- var pair = v.split('=');
- nvpair[pair[0]] = pair[1];
- });
- return nvpair;
- },
- pazpar2: function(data) {
- document.write('<div id="mkwsSwitch"></div>\
- <div id="mkwsLang"></div>\
- <div id="mkwsSearch"></div>\
- <div id="mkwsResults"></div>\
- <div id="mkwsTargets"></div>\
- <div id="mkwsFooter">\
- <div id="mkwsStat"></div>\
- <span>Powered by MKWS © 2013 <a target="_new" href="http://www.indexdata.com">Index Data</a></span>\
- </div>');
-
- mkws_html_all(mkws_config);
- }
+ // implement jQuery.parseQuerystring() for parsing URL parameters
+ parseQuerystring: function() {
+ var nvpair = {};
+ var qs = window.location.search.replace('?', '');
+ var pairs = qs.split('&');
+ $.each(pairs, function(i, v){
+ var pair = v.split('=');
+ nvpair[pair[0]] = pair[1];
+ });
+ return nvpair;
+ },
+
+ debug2: function(string) { // delayed debug, internal variables are set after dom ready
+ setTimeout(function() { debug(string); }, 500);
+ },
+
+ // service-proxy or pazpar2
+ pazpar2: function(config) {
+ // simple layout
+ var div = '<div id="mkwsSwitch"></div>\
+ <div id="mkwsLang"></div>\
+ <div id="mkwsSearch"></div>\
+ <div id="mkwsResults"></div>\
+ <div id="mkwsTargets"></div>\
+ <div id="mkwsStat"></div>';
+
+ // new table layout
+ var table = '\
+ <style type="text/css">\
+ #mkwsTermlists div.facet {\
+ float:left;\
+ width: 30%;\
+ margin: 0.3em;\
+ }\
+ #mkwsStat {\
+ text-align: right;\
+ }\
+ </style>\
+ \
+ <table width="100%" border="0">\
+ <tr>\
+ <td>\
+ <div id="mkwsSwitch"></div>\
+ <div id="mkwsLang"></div>\
+ <div id="mkwsSearch"></div>\
+ </td>\
+ </tr>\
+ <tr>\
+ <td>\
+ <div style="height:500px; overflow: auto">\
+ <div id="mkwsPager"></div>\
+ <div id="mkwsNavi"></div>\
+ <div id="mkwsRecords"></div>\
+ <div id="mkwsTargets"></div>\
+ <div id="mkwsRanking"></div>\
+ </div>\
+ </td>\
+ </tr>\
+ <tr>\
+ <td>\
+ <div style="height:300px; overflow: hidden">\
+ <div id="mkwsTermlists"></div>\
+ </div>\
+ </td>\
+ </tr>\
+ <tr>\
+ <td>\
+ <div id="mkwsStat"></div>\
+ </td>\
+ </tr>\
+ </table>';
+
+ var popup = '\
+ <div id="mkwsSearch"></div>\
+ <div id="mkwsPopup">\
+ <div id="mkwsSwitch"></div>\
+ <div id="mkwsLang"></div>\
+ <div id="mkwsResults"></div>\
+ <div id="mkwsTargets"></div>\
+ <div id="mkwsStat"></div>\
+ </div>'
+
+ if (config && config.layout == 'div') {
+ this.debug2("jquery plugin layout: div");
+ document.write(div);
+ } else if (config && config.layout == 'popup') {
+ this.debug2("jquery plugin layout: popup");
+ document.write(popup);
+ $(document).ready( function() { init_popup(config); } );
+ } else {
+ this.debug2("jquery plugin layout: table");
+ document.write(table);
+ }
+ }
});
+function init_popup(obj) {
+ var config = obj ? obj : {};
+
+ var height = config.height || 760;
+ var width = config.width || 880;
+ var id_button = config.button || "input#mkwsButton";
+ var id_popup = config.popup || "#mkwsPopup";
+
+ debug("popup height: " + height + ", width: " + width);
+
+ $(id_popup).dialog({
+ closeOnEscape: true,
+ autoOpen: false,
+ height: height,
+ width: width,
+ modal: true,
+ resizable: true,
+ buttons: {
+ Cancel: function() {
+ $(this).dialog("close");
+ }
+ },
+ close: function() { }
+ });
+
+ $(id_button)
+ .button()
+ .click(function() {
+ $(id_popup).dialog("open");
+ });
+};
+
function debug(string) {
if (!mkws_debug)
return;
console.log(string);
}
+
/* magic */
$(document).ready(function() { mkws_html_all(mkws_config) });