From: Wolfram Schneider Date: Wed, 10 Jul 2013 15:28:39 +0000 (+0000) Subject: Merge remote branch 'origin/master' into wosch X-Git-Tag: 0.9.1~275 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=073be95d012b356da93f53b9d9b7e8a65bd181c9;hp=ce49539eee8276bb10adb90adeb7592d88a7a383;p=mkws-moved-to-github.git Merge remote branch 'origin/master' into wosch --- diff --git a/experiments/spclient/index-popup.html b/experiments/spclient/index-popup.html new file mode 100644 index 0000000..54a81f2 --- /dev/null +++ b/experiments/spclient/index-popup.html @@ -0,0 +1,77 @@ + + + + MKWS demo: popup search box + + + + + + + + + + + + + + + + +
+      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:
+
+[...]
+    
+ + diff --git a/tools/htdocs/README b/tools/htdocs/README index 0c4d98d..56afebc 100644 --- a/tools/htdocs/README +++ b/tools/htdocs/README @@ -94,6 +94,26 @@ Here is an example of all possible options 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 + + + +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 ------------------ diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index d29e1d5..c5f7d48 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -820,33 +820,138 @@ function M(word) { 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('
\ -
\ -
\ -
\ -
\ -
\ -
\ - Powered by MKWS © 2013 Index Data\ -
'); - - 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 = '
\ +
\ +
\ +
\ +
\ +
'; + + // new table layout + var table = '\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
'; + + var popup = '\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
' + + 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; @@ -864,5 +969,6 @@ function debug(string) { console.log(string); } + /* magic */ $(document).ready(function() { mkws_html_all(mkws_config) });