From: Mike Taylor Date: Sat, 26 Apr 2014 00:26:23 +0000 (+0100) Subject: The widget.autosearch function now understands queries of the form X-Git-Tag: 1.0.0~829 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=a1a99d008c1bf102129b8cfd7ad15bf5168fc41d;p=mkws-moved-to-github.git The widget.autosearch function now understands queries of the form !var!name (as well as !param!name and !path!number) Allows the application to set the query into a named variable in whatever way it wishes, and have MKWS obtain it from that variable. Fixes bug MKWS-170. --- diff --git a/src/mkws-widgets.js b/src/mkws-widgets.js index 517850b..c677853 100644 --- a/src/mkws-widgets.js +++ b/src/mkws-widgets.js @@ -83,6 +83,13 @@ widget.autosearch = function(widget) { if (!query) { alert("This page has a MasterKey widget that needs a query specified by the path-component " + index); } + } else if (query.match(/^!var!/)) { + var name = query.replace(/^!var!/, ''); + query = window[name]; // It's ridiculous that this works + widget.log("obtained query '" + query + "' from variable '" + name + "'"); + if (!query) { + alert("This page has a MasterKey widget that needs a query specified by the '" + name + "' variable"); + } } var sortOrder = widget.config.sort;